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

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

215
src/ProjLib/ProjLib.cdl Executable file
View File

@@ -0,0 +1,215 @@
-- File: ProjLib.cdl
-- Created: Wed Aug 11 12:31:20 1993
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1993
package ProjLib
---Purpose: The projLib package first provides projection of
-- curves on a plane along a given Direction. The
-- result will be a 3D curve.
---Purpose: The ProjLib package provides projection of curves
-- on surfaces to compute the curve in the parametric
-- space.
--
-- It is assumed that the curve is on the surface.
--
-- It provides :
--
-- * Package methods to handle the easiest cases :
--
-- - Line, Circle, Ellipse, Parabola, Hyperbola on plane.
--
-- - Line, Circle on cylinder.
--
-- - Line, Circle on cone.
--
-- * Classes to handle the general cases :
--
-- - Plane.
--
-- - Cylinder.
--
-- - Cone.
--
-- - Sphere.
--
-- - Torus.
--
--
-- * A generic class to handle a Curve from Adaptor3d
-- on a Surface from Adaptor3d.
--
uses
GeomAbs, -- Geometry enumeration
gp, -- Elementary geometry
Geom,
Geom2d,
Adaptor2d, -- Curve and Surface interface.
Adaptor3d, -- Curve and Surface interface.
Extrema, -- for projection of points on surface.
GeomAdaptor,
TColgp,
TColStd,
TCollection,
math
is
-- ---------------------------------------------------------------
-- Classes computing the projection of a 3d curve on a surface.
-- The result will be a 3d curve.
--
-- Make an approximation if necessary
-- ---------------------------------------------------------------
class ProjectOnPlane ;
---Purpose: Project a curve on a plane.
class ProjectOnSurface ;
---Purpose: Project a curve on a surface. The result ( a 3D
-- Curve) will be an approximation
-- ---------------------------------------------------------------
-- Classes computing the PCurves of curves lying on a surface
--
-- Make an approximation if necessary
-- ---------------------------------------------------------------
class ComputeApprox;
---Purpose: Approximate the projection of a 3d curve on an
-- analytic surface and stores the result in Approx.
-- The result is a 2d curve.
class ComputeApproxOnPolarSurface ;
---Purpose: Approximate the projection of a 3d curve on an
-- polar surface and stores the result in Approx.
-- The result is a 2d curve. The evaluation of the
-- current point of the 2d curve is done with the
-- evaluation of the extrema P3d - Surface.
class ProjectedCurve ;
---Purpose: Compute the 2d-curve. Try to solve the particular
-- case if possible. Otherwize, an approximation is
-- done.
class HProjectedCurve instantiates
GenHCurve2d from Adaptor2d (ProjectedCurve);
---------------------------------------------
-- Normal projection of a curve on a surface
-- Computes the different parts
-----------------------------------------------
class SequenceOfHSequenceOfPnt
instantiates Sequence from TCollection (HSequenceOfPnt from TColgp);
class HSequenceOfHSequenceOfPnt
instantiates HSequence from TCollection (HSequenceOfPnt from TColgp,SequenceOfHSequenceOfPnt from ProjLib);
class CompProjectedCurve;
class HCompProjectedCurve
instantiates GenHCurve2d from Adaptor2d (CompProjectedCurve);
private class PrjResolve;
private class PrjFunc;
-- ------------------------------------------------------------
-- Projection of Curves on Surfaces.
--
-- This classes evaluate the 2d curve of a curve lying on a
-- surface in some particular case. See the description of this
-- classes to have more informations.
--
-- ------------------------------------------------------------
class Projector;
---Purpose: Root class for projections. Stores the result.
class Plane;
---Purpose: Projection on a plane.
class Cylinder;
---Purpose: Projection on a cylinder.
class Cone;
---Purpose: Projection on a cone.
class Sphere;
---Purpose: Projection on a sphere.
class Torus;
---Purpose: Projection on a torus.
-- methods
Project(Pl : Pln from gp;
P : Pnt from gp ) returns Pnt2d from gp;
Project(Pl : Pln from gp;
L : Lin from gp ) returns Lin2d from gp;
Project(Pl : Pln from gp;
C : Circ from gp ) returns Circ2d from gp;
Project(Pl : Pln from gp;
E : Elips from gp ) returns Elips2d from gp;
Project(Pl : Pln from gp;
P : Parab from gp ) returns Parab2d from gp;
Project(Pl : Pln from gp;
H : Hypr from gp ) returns Hypr2d from gp;
Project(Cy : Cylinder from gp;
P : Pnt from gp ) returns Pnt2d from gp;
Project(Cy : Cylinder from gp;
L : Lin from gp ) returns Lin2d from gp;
Project(Cy : Cylinder from gp;
Ci : Circ from gp ) returns Lin2d from gp;
Project(Co : Cone from gp;
P : Pnt from gp ) returns Pnt2d from gp;
Project(Co : Cone from gp;
L : Lin from gp ) returns Lin2d from gp;
Project(Co : Cone from gp;
Ci : Circ from gp ) returns Lin2d from gp;
Project(Sp : Sphere from gp;
P : Pnt from gp ) returns Pnt2d from gp;
Project(Sp : Sphere from gp;
Ci : Circ from gp ) returns Lin2d from gp;
Project(To : Torus from gp;
P : Pnt from gp ) returns Pnt2d from gp;
Project(To : Torus from gp;
Ci : Circ from gp ) returns Lin2d from gp;
end ProjLib;

210
src/ProjLib/ProjLib.cxx Executable file
View File

@@ -0,0 +1,210 @@
// File: ProjLib.cxx
// Created: Tue Aug 24 19:03:05 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
#include <ProjLib.ixx>
#include <ProjLib_Plane.hxx>
#include <ProjLib_Cylinder.hxx>
#include <ProjLib_Cone.hxx>
#include <ProjLib_Sphere.hxx>
#include <ProjLib_Torus.hxx>
#include <ElSLib.hxx>
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Pnt2d ProjLib::Project(const gp_Pln& Pl, const gp_Pnt& P)
{
Standard_Real U, V;
ElSLib::Parameters(Pl, P, U, V);
return gp_Pnt2d(U,V);
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Lin2d ProjLib::Project(const gp_Pln& Pl, const gp_Lin& L)
{
ProjLib_Plane Proj( Pl, L);
return Proj.Line();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Circ2d ProjLib::Project(const gp_Pln& Pl, const gp_Circ& C)
{
ProjLib_Plane Proj( Pl, C);
return Proj.Circle();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Elips2d ProjLib::Project(const gp_Pln& Pl, const gp_Elips& E)
{
ProjLib_Plane Proj( Pl, E);
return Proj.Ellipse();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Parab2d ProjLib::Project(const gp_Pln& Pl, const gp_Parab& P)
{
ProjLib_Plane Proj( Pl, P);
return Proj.Parabola();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Hypr2d ProjLib::Project(const gp_Pln& Pl, const gp_Hypr& H)
{
ProjLib_Plane Proj( Pl, H);
return Proj.Hyperbola();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Pnt2d ProjLib::Project(const gp_Cylinder& Cy, const gp_Pnt& P)
{
Standard_Real U, V;
ElSLib::Parameters(Cy, P, U, V);
return gp_Pnt2d(U,V);
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Lin2d ProjLib::Project(const gp_Cylinder& Cy, const gp_Lin& L)
{
ProjLib_Cylinder Proj( Cy, L);
return Proj.Line();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Lin2d ProjLib::Project(const gp_Cylinder& Cy, const gp_Circ& Ci)
{
ProjLib_Cylinder Proj( Cy, Ci);
return Proj.Line();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Pnt2d ProjLib::Project(const gp_Cone& Co, const gp_Pnt& P)
{
Standard_Real U, V;
ElSLib::Parameters(Co, P, U, V);
return gp_Pnt2d(U,V);
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Lin2d ProjLib::Project(const gp_Cone& Co, const gp_Lin& L)
{
ProjLib_Cone Proj( Co, L);
return Proj.Line();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Lin2d ProjLib::Project(const gp_Cone& Co, const gp_Circ& Ci)
{
ProjLib_Cone Proj( Co, Ci);
return Proj.Line();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Pnt2d ProjLib::Project(const gp_Sphere& Sp, const gp_Pnt& P)
{
Standard_Real U, V;
ElSLib::Parameters(Sp, P, U, V);
return gp_Pnt2d(U,V);
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Lin2d ProjLib::Project(const gp_Sphere& Sp, const gp_Circ& Ci)
{
ProjLib_Sphere Proj( Sp, Ci);
return Proj.Line();
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Pnt2d ProjLib::Project(const gp_Torus& To, const gp_Pnt& P)
{
Standard_Real U, V;
ElSLib::Parameters(To, P, U, V);
return gp_Pnt2d(U,V);
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
gp_Lin2d ProjLib::Project(const gp_Torus& To, const gp_Circ& Ci)
{
ProjLib_Torus Proj( To, Ci);
return Proj.Line();
}

View File

@@ -0,0 +1,217 @@
-- File: ProjLib_CompProjectedCurve.cdl
-- Created: Mon Sep 22 12:46:50 1997
-- Author: Roman BORISOV
-- <rbv@pronox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class CompProjectedCurve from ProjLib inherits Curve2d from Adaptor2d
uses
HSurface from Adaptor3d,
HCurve from Adaptor3d,
HCurve2d from Adaptor2d,
Pnt2d from gp,
Vec2d from gp,
Pnt from gp,
Array1OfReal from TColStd,
HSequenceOfHSequenceOfPnt from ProjLib,
Shape from GeomAbs,
HArray1OfBoolean from TColStd,
HArray1OfReal from TColStd,
CurveType from GeomAbs
raises
OutOfRange from Standard,
NoSuchObject from Standard,
DomainError from Standard,
NotImplemented from Standard
is
Create returns CompProjectedCurve;
Create(S : HSurface from Adaptor3d;
C : HCurve from Adaptor3d;
TolU, TolV: Real from Standard)
returns CompProjectedCurve;
---Purpose: try to find all solutions
Create(S : HSurface from Adaptor3d;
C : HCurve from Adaptor3d;
TolU, TolV, MaxDist: Real from Standard)
returns CompProjectedCurve;
---Purpose: this constructor tries to optimize the search using the
-- assamption that maximum distance between surface and curve less or
-- equal then MaxDist.
-- if MaxDist < 0 then algorithm works as above.
Init(me: in out)
---Purpose : computes a set of projected point and determine the
-- continuous parts of the projected curves. The points
-- corresponding to a projection on the bounds of the surface are
-- included in this set of points.
is static;
Load(me : in out;S : HSurface from Adaptor3d)
---Purpose: Changes the surface.
is static;
Load(me : in out; C : HCurve from Adaptor3d)
---Purpose: Changes the curve.
is static;
GetSurface(me) returns HSurface from Adaptor3d
---C++: return const &
is static;
GetCurve(me) returns HCurve from Adaptor3d
---C++: return const &
is static;
GetTolerance(me; TolU, TolV: in out Real)
is static;
--
-- Global methods - Apply to the whole curve.
--
NbCurves (me) returns Integer from Standard
---Purpose: returns the number of continuous part of the projected curve
is static;
Bounds(me; Index : in Integer from Standard;
Udeb,Ufin : out Real from Standard)
--- Purpose : returns the bounds of the continuous part corresponding to Index
raises NoSuchObject
is static;
IsSinglePnt(me; Index: Integer; P : out Pnt2d from gp ) returns Boolean from Standard
--- Purpose : returns True if part of projection with number Index is a single point and writes its coordinats in P
raises NoSuchObject
is static;
IsUIso(me; Index: Integer; U : out Real from Standard) returns Boolean from Standard
--- Purpose : returns True if part of projection with number Index is an u-isoparametric curve of input surface
raises NoSuchObject
is static;
IsVIso(me; Index: Integer; V : out Real from Standard) returns Boolean from Standard
--- Purpose : returns True if part of projection with number Index is an v-isoparametric curve of input surface
raises NoSuchObject
is static;
Value(me; U : Real from Standard) returns Pnt2d from gp
--- Purpose : Computes the point of parameter U on the curve.
is redefined static;
D0 (me; U : Real from Standard; P : out Pnt2d from gp)
--- Purpose : Computes the point of parameter U on the curve.
raises DomainError
is redefined static;
D1 (me; U : Real from Standard; P : out Pnt2d from gp ; V : out Vec2d from gp)
--- Purpose : Computes the point of parameter U on the curve with its
-- first derivative.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C1.
is redefined static;
D2 (me; U : Real from Standard; P : out Pnt2d from gp; V1, V2 : out Vec2d from gp)
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C2.
is redefined static;
DN (me; U : Real; N : Integer) returns Vec2d from gp
--- Purpose :
-- The returned vector gives the value of the derivative for the
-- order of derivation N.
raises
OutOfRange from Standard,
--- Purpose : Raised if N < 1.
NotImplemented from Standard
--- Purpose : Raised if N > 2.
is redefined static;
FirstParameter(me) returns Real
---Purpose: Returns the first parameter of the curve C
-- which has a projection on S.
is redefined static;
LastParameter(me) returns Real
---Purpose: Returns the last parameter of the curve C
-- which has a projection on S.
is redefined static;
NbIntervals(me; S : Shape from GeomAbs) returns Integer
---Purpose: Returns the number of intervals which define
-- an S continuous part of the projected curve
is redefined static;
Trim(me;FirstParam,LastParam,Tol : Real) returns HCurve2d from Adaptor2d
---Purpose: Returns a curve equivalent of <me> between
-- parameters <First> and <Last>. <Tol> is used to
-- test for 2d points confusion.
raises
OutOfRange from Standard
---Purpose: If <First> >= <Last>
is redefined static;
Intervals(me; T : in out Array1OfReal from TColStd;
S : Shape from GeomAbs)
---Purpose: Returns the parameters corresponding to
-- S discontinuities.
--
-- The array must provide enough room to accomodate
-- for the parameters. i.e. T.Length() > NbIntervals()
raises
OutOfRange from Standard
is redefined static;
BuildIntervals(me; S : Shape from GeomAbs)
raises
OutOfRange from Standard
is private;
MaxDistance(me; Index: Integer)
---Purpose: returns the maximum distance between
-- curve to project and surface
returns Real
raises NoSuchObject;
-- Methods for debugging
GetSequence(me) returns HSequenceOfHSequenceOfPnt from ProjLib
---C++: return const &
is static;
GetType(me) returns CurveType from GeomAbs
---Purpose: Returns the type of the curve in the current
-- interval : Line, Circle, Ellipse, Hyperbola,
-- Parabola, BezierCurve, BSplineCurve, OtherCurve.
is redefined static;
fields
mySurface : HSurface from Adaptor3d;
myCurve : HCurve from Adaptor3d;
myNbCurves : Integer from Standard;
mySequence : HSequenceOfHSequenceOfPnt from ProjLib;
myTolU : Real from Standard;
myTolV : Real from Standard;
myMaxDist : Real from Standard;
myUIso : HArray1OfBoolean from TColStd;
myVIso : HArray1OfBoolean from TColStd;
mySnglPnts : HArray1OfBoolean from TColStd;
myMaxDistance : HArray1OfReal from TColStd;
end CompProjectedCurve;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
-- File: ProjLib_ComputeApprox.cdl
-- Created: Tue Sep 7 16:30:36 1993
-- Author: Bruno DUMORTIER
-- <dub@topsn3>
---Copyright: Matra Datavision 1993
class ComputeApprox from ProjLib
uses
HCurve from Adaptor3d,
HSurface from Adaptor3d,
BSplineCurve from Geom2d,
BezierCurve from Geom2d
is
Create(C : HCurve from Adaptor3d ;
S : HSurface from Adaptor3d;
Tol : Real from Standard)
---Purpose: <Tol> is the tolerance with which the
-- approximation is performed.
returns ComputeApprox from ProjLib;
BSpline(me) returns BSplineCurve from Geom2d ;
Bezier(me) returns BezierCurve from Geom2d ;
Tolerance(me) returns Real from Standard;
---Purpose: returns the reached Tolerance.
fields
myTolerance : Real from Standard;
myBSpline : BSplineCurve from Geom2d ;
myBezier : BezierCurve from Geom2d ;
end ComputeApprox;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
-- File: ProjLib_ComputeApproxOnPolarSurface.cdl
-- Created: Fri Oct 7 11:03:17 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1994
class ComputeApproxOnPolarSurface from ProjLib
uses
HCurve from Adaptor3d,
HCurve2d from Adaptor2d,
HSurface from Adaptor3d,
BSplineCurve from Geom2d,
Curve from Geom2d
is
Create returns ComputeApproxOnPolarSurface from ProjLib;
Create(C : HCurve from Adaptor3d ;
S : HSurface from Adaptor3d ;
Tol : Real = 1.0e-4)
returns ComputeApproxOnPolarSurface from ProjLib;
-- Create(C : HCurve from Adaptor3d ;
-- S : HSurface from Adaptor3d)
---purpose: pour etre en phase avec ProjOnSurf
-- returns ComputeApproxOnPolarSurface from ProjLib;
Create(InitCurve2d : HCurve2d from Adaptor2d ;
C : HCurve from Adaptor3d ;
S : HSurface from Adaptor3d ;
Tol : Real)
returns ComputeApproxOnPolarSurface from ProjLib;
Create(InitCurve2d : HCurve2d from Adaptor2d ;
InitCurve2dBis : HCurve2d from Adaptor2d ;
C : HCurve from Adaptor3d ;
S : HSurface from Adaptor3d ;
Tol : Real)
returns ComputeApproxOnPolarSurface from ProjLib;
Perform(me : in out ; InitCurve2d : HCurve2d from Adaptor2d;
C : HCurve from Adaptor3d ;
S : HSurface from Adaptor3d )
returns BSplineCurve from Geom2d;
BuildInitialCurve2d(me : in out ; Curve : HCurve from Adaptor3d ;
S : HSurface from Adaptor3d )
returns HCurve2d from Adaptor2d;
ProjectUsingInitialCurve2d(me : in out ; Curve : HCurve from Adaptor3d ;
S : HSurface from Adaptor3d ;
InitCurve2d : HCurve2d from Adaptor2d )
returns BSplineCurve from Geom2d;
BSpline(me) returns BSplineCurve from Geom2d ;
Curve2d(me) returns Curve from Geom2d ;
IsDone(me) returns Boolean from Standard;
fields
myProjIsDone : Boolean from Standard;
myTolerance : Real from Standard;
myBSpline : BSplineCurve from Geom2d ;
my2ndCurve : Curve from Geom2d ;
-- myInitCurve2d : HCurve2d from Adaptor3d;
end ComputeApproxOnPolarSurface;

File diff suppressed because it is too large Load Diff

75
src/ProjLib/ProjLib_Cone.cdl Executable file
View File

@@ -0,0 +1,75 @@
-- File: ProjLib_Cone.cdl
-- Created: Tue Aug 24 11:18:15 1993
-- Author: Bruno DUMORTIER
-- <dub@topsn3>
---Copyright: Matra Datavision 1993
class Cone from ProjLib inherits Projector from ProjLib
---Purpose: Projects elementary curves on a cone.
uses
CurveType from GeomAbs,
Cone from gp,
Lin from gp,
Circ from gp,
Elips from gp,
Parab from gp,
Hypr from gp,
Lin2d from gp,
Circ2d from gp,
Elips2d from gp,
Parab2d from gp,
Hypr2d from gp
raises
NoSuchObject from Standard
is
Create returns Cone from ProjLib;
---Purpose: Undefined projection.
Create(Co : Cone from gp) returns Cone from ProjLib;
---Purpose: Projection on the cone <Co>.
Create(Co : Cone from gp;
L : Lin from gp) returns Cone from ProjLib;
---Purpose: Projection of the line <L> on the cone <Co>.
Create(Co : Cone from gp;
C : Circ from gp) returns Cone from ProjLib;
---Purpose: Projection of the circle <C> on the cone <Co>.
Init(me : in out;
Co : Cone from gp)
is static;
Project(me : in out;
L : Lin from gp)
is redefined;
Project(me : in out;
C : Circ from gp)
is redefined;
Project(me : in out;
E : Elips from gp)
is redefined;
Project(me : in out;
P : Parab from gp)
is redefined;
Project(me : in out;
H : Hypr from gp)
is redefined;
fields
myCone : Cone from gp;
end Cone;

228
src/ProjLib/ProjLib_Cone.cxx Executable file
View File

@@ -0,0 +1,228 @@
// File: ProjLib_Cone.cxx
// Created: Tue Aug 24 16:50:59 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
#include <ProjLib_Cone.ixx>
#include <Precision.hxx>
#include <gp.hxx>
#include <gp_Vec.hxx>
#include <gp_Trsf.hxx>
#include <gp_Vec2d.hxx>
#include <ElSLib.hxx>
//=======================================================================
//function : ProjLib_Cone
//purpose :
//=======================================================================
ProjLib_Cone::ProjLib_Cone()
{
}
//=======================================================================
//function : ProjLib_Cone
//purpose :
//=======================================================================
ProjLib_Cone::ProjLib_Cone(const gp_Cone& Co)
{
Init(Co);
}
//=======================================================================
//function : ProjLib_Cone
//purpose :
//=======================================================================
ProjLib_Cone::ProjLib_Cone(const gp_Cone& Co, const gp_Lin& L)
{
Init(Co);
Project(L);
}
//=======================================================================
//function : ProjLib_Cone
//purpose :
//=======================================================================
ProjLib_Cone::ProjLib_Cone(const gp_Cone& Co, const gp_Circ& C)
{
Init(Co);
Project(C);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void ProjLib_Cone::Init(const gp_Cone& Co)
{
myType = GeomAbs_OtherCurve;
myCone = Co;
myIsPeriodic = Standard_False;
isDone = Standard_False;
}
//=======================================================================
//function : EvalPnt2d / EvalDir2d
//purpose : returns the Projected Pnt / Dir in the parametrization range
// of myPlane.
//=======================================================================
#ifdef DEB
static gp_Pnt2d EvalPnt2d( const gp_Pnt& P, const gp_Cone& C)
{
gp_Vec OP( C.Location(),P);
Standard_Real X = OP.Dot(gp_Vec(C.Position().XDirection()));
Standard_Real Y = OP.Dot(gp_Vec(C.Position().YDirection()));
Standard_Real Z = OP.Dot(gp_Vec(C.Position().Direction()));
Standard_Real U,V;
if ( Abs(X) > Precision::PConfusion() ||
Abs(Y) > Precision::PConfusion() ) {
U = ATan2(Y,X);
}
else {
U = 0.;
}
V = Z / Cos(C.SemiAngle());
return gp_Pnt2d( U, Z);
}
#endif
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Cone::Project(const gp_Lin& L)
{
Standard_Real U,V;
// Compute V
V = gp_Vec(myCone.Location(),L.Location())
.Dot(gp_Vec(myCone.Position().Direction()));
V /= Cos( myCone.SemiAngle());
// Compute U
gp_Ax3 CPos = myCone.Position();
gp_Dir ZCone = CPos.XDirection() ^ CPos.YDirection();
gp_Ax3 RightHanded(CPos.Location(), ZCone, CPos.XDirection());
gp_Trsf T;
T.SetTransformation(RightHanded);
gp_Dir D = L.Position().Direction();
D.Transform(T);
if ( D.Z() < 0.) D.Reverse();
D.SetCoord(3, 0.);
U = gp::DX().AngleWithRef( D, gp::DZ());
Standard_Integer a1 =
(ZCone.IsEqual(CPos.Direction(), Precision::Angular())) ? 1 : -1;
Standard_Integer a2 =
(myCone.SemiAngle() > 0) ? 1 : -1;
if ( ( a1 * a2) == -1) U -= PI;
if ( U < 0.) U += 2.*PI;
gp_Pnt P;
gp_Vec Vu, Vv;
ElSLib::ConeD1(U, V, CPos, myCone.RefRadius(), myCone.SemiAngle(),
P, Vu, Vv);
if(Vv.IsParallel(gp_Vec(L.Position().Direction()), Precision::Angular())) {
myType = GeomAbs_Line;
gp_Pnt2d P2d(U,V);
Standard_Real Signe = L.Direction().Dot(myCone.Position().Direction());
Signe = (Signe > 0.) ? 1. : -1.;
gp_Dir2d D2d(0., Signe);
myLin = gp_Lin2d( P2d, D2d);
isDone = Standard_True;
}
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Cone::Project(const gp_Circ& C)
{
myType = GeomAbs_Line;
gp_Ax3 ConePos = myCone.Position();
gp_Ax3 CircPos = C.Position();
gp_Dir ZCone = ConePos.XDirection().Crossed(ConePos.YDirection());
gp_Dir ZCir = CircPos.XDirection().Crossed(CircPos.YDirection());
Standard_Real U, V;
Standard_Real x = ConePos.XDirection().Dot(CircPos.XDirection());
Standard_Real y = ConePos.YDirection().Dot(CircPos.XDirection());
Standard_Real z
= gp_Vec(myCone.Location(),C.Location()).Dot(ConePos.Direction());
// pour trouver le point U V, on reprend le code de ElSLib
// sans appliquer la Trsf au point ( aller retour inutile).
if ( x == 0.0 && y == 0.0 ) {
U = 0.;
}
else if ( -myCone.RefRadius() > z * Tan(myCone.SemiAngle())) {
U = ATan2(-y, -x);
}
else {
U = ATan2( y, x);
}
if ( U < 0.) U += 2*PI;
V = z / Cos(myCone.SemiAngle());
gp_Pnt2d P2d1 (U, V);
gp_Dir2d D2d;
if ( ZCone.Dot(ZCir) > 0.)
D2d.SetCoord(1., 0.);
else
D2d.SetCoord(-1., 0.);
myLin = gp_Lin2d(P2d1, D2d);
isDone = Standard_True;
}
void ProjLib_Cone::Project(const gp_Elips& E)
{
ProjLib_Projector::Project(E);
}
void ProjLib_Cone::Project(const gp_Parab& P)
{
ProjLib_Projector::Project(P);
}
void ProjLib_Cone::Project(const gp_Hypr& H)
{
ProjLib_Projector::Project(H);
}

View File

@@ -0,0 +1,79 @@
-- File: ProjLib_Cylinder.cdl
-- Created: Tue Aug 24 11:11:01 1993
-- Author: Bruno DUMORTIER
-- <dub@topsn3>
---Copyright: Matra Datavision 1993
class Cylinder from ProjLib inherits Projector from ProjLib
---Purpose: Projects elementary curves on a cylinder.
uses
CurveType from GeomAbs,
Cylinder from gp,
Lin from gp,
Circ from gp,
Elips from gp,
Parab from gp,
Hypr from gp,
Lin2d from gp,
Circ2d from gp,
Elips2d from gp,
Parab2d from gp,
Hypr2d from gp
raises
NoSuchObject from Standard
is
Create returns Cylinder from ProjLib;
---Purpose: Undefined projection.
Create(Cyl : Cylinder from gp) returns Cylinder from ProjLib;
---Purpose: Projection on the cylinder <Cyl>.
Create(Cyl : Cylinder from gp;
L : Lin from gp) returns Cylinder from ProjLib;
---Purpose: Projection of the line <L> on the cylinder <Cyl>.
Create(Cyl : Cylinder from gp;
C : Circ from gp) returns Cylinder from ProjLib;
---Purpose: Projection of the circle <C> on the cylinder <Cyl>.
Create(Cyl : Cylinder from gp;
E : Elips from gp) returns Cylinder from ProjLib;
---Purpose: Projection of the ellipse <E> on the cylinder <Cyl>.
Init(me : in out;
Cyl : Cylinder from gp)
is static;
Project(me : in out;
L : Lin from gp)
is redefined;
Project(me : in out;
C : Circ from gp)
is redefined;
Project(me : in out;
E : Elips from gp)
is redefined;
Project(me : in out;
P : Parab from gp)
is redefined;
Project(me : in out;
H : Hypr from gp)
is redefined;
fields
myCylinder : Cylinder from gp;
end Cylinder;

193
src/ProjLib/ProjLib_Cylinder.cxx Executable file
View File

@@ -0,0 +1,193 @@
// File: ProjLib_Cylinder.cxx
// Created: Tue Aug 24 15:08:40 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
#include <Standard_NotImplemented.hxx>
#include <ProjLib_Cylinder.ixx>
#include <Precision.hxx>
#include <gp_Pln.hxx>
#include <gp_Trsf.hxx>
#include <gp_Vec.hxx>
#include <gp_Ax3.hxx>
#include <gp_Vec2d.hxx>
//=======================================================================
//function : ProjLib_Cylinder
//purpose :
//=======================================================================
ProjLib_Cylinder::ProjLib_Cylinder()
{
}
//=======================================================================
//function : ProjLib_Cylinder
//purpose :
//=======================================================================
ProjLib_Cylinder::ProjLib_Cylinder(const gp_Cylinder& Cyl)
{
Init(Cyl);
}
//=======================================================================
//function : ProjLib_Cylinder
//purpose :
//=======================================================================
ProjLib_Cylinder::ProjLib_Cylinder(const gp_Cylinder& Cyl, const gp_Lin& L)
{
Init(Cyl);
Project(L);
}
//=======================================================================
//function : ProjLib_Cylinder
//purpose :
//=======================================================================
ProjLib_Cylinder::ProjLib_Cylinder(const gp_Cylinder& Cyl, const gp_Circ& C)
{
Init(Cyl);
Project(C);
}
//=======================================================================
//function : ProjLib_Cylinder
//purpose :
//=======================================================================
ProjLib_Cylinder::ProjLib_Cylinder(const gp_Cylinder& Cyl, const gp_Elips& E)
{
Init(Cyl);
Project(E);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void ProjLib_Cylinder::Init(const gp_Cylinder& Cyl)
{
myType = GeomAbs_OtherCurve;
myCylinder = Cyl;
myIsPeriodic = Standard_False;
isDone = Standard_False;
}
//=======================================================================
//function : EvalPnt2d / EvalDir2d
//purpose : returns the Projected Pnt / Dir in the parametrization range
// of myPlane.
//=======================================================================
static gp_Pnt2d EvalPnt2d( const gp_Pnt& P, const gp_Cylinder& Cy )
{
gp_Vec OP( Cy.Location(),P);
Standard_Real X = OP.Dot(gp_Vec(Cy.Position().XDirection()));
Standard_Real Y = OP.Dot(gp_Vec(Cy.Position().YDirection()));
Standard_Real Z = OP.Dot(gp_Vec(Cy.Position().Direction()));
Standard_Real U ;
if ( Abs(X) > Precision::PConfusion() ||
Abs(Y) > Precision::PConfusion() ) {
U = ATan2(Y,X);
}
else {
U = 0.;
}
return gp_Pnt2d( U, Z);
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Cylinder::Project(const gp_Lin& L)
{
myType = GeomAbs_Line;
gp_Pnt2d P2d = EvalPnt2d(L.Location(),myCylinder);
if ( P2d.X() < 0.) {
P2d.SetX(P2d.X()+2*PI);
}
Standard_Real Signe
= L.Direction().Dot(myCylinder.Position().Direction());
Signe = (Signe > 0.) ? 1. : -1.;
gp_Dir2d D2d(0., Signe);
myLin = gp_Lin2d( P2d, D2d);
isDone = Standard_True;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Cylinder::Project(const gp_Circ& C)
{
myType = GeomAbs_Line;
gp_Dir ZCyl = myCylinder.Position().XDirection().Crossed
(myCylinder.Position().YDirection());
gp_Dir ZCir = C.Position().XDirection().Crossed
(C.Position().YDirection());
Standard_Real U = myCylinder.Position().XDirection()
.AngleWithRef(C.Position().XDirection(), ZCyl);
gp_Vec OP( myCylinder.Location(),C.Location());
Standard_Real V = OP.Dot(gp_Vec(myCylinder.Position().Direction()));
gp_Pnt2d P2d1 (U, V);
gp_Dir2d D2d;
if ( ZCyl.Dot(ZCir) > 0.)
D2d.SetCoord(1., 0.);
else
D2d.SetCoord(-1., 0.);
myLin = gp_Lin2d(P2d1, D2d);
isDone = Standard_True;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
//void ProjLib_Cylinder::Project(const gp_Elips& E)
void ProjLib_Cylinder::Project(const gp_Elips& )
{
// Pour de vastes raisons de periodicite mal gerees,
// la projection d`une ellipse sur un cylindre sera passee aux approx.
}
void ProjLib_Cylinder::Project(const gp_Parab& P)
{
ProjLib_Projector::Project(P);
}
void ProjLib_Cylinder::Project(const gp_Hypr& H)
{
ProjLib_Projector::Project(H);
}

91
src/ProjLib/ProjLib_Plane.cdl Executable file
View File

@@ -0,0 +1,91 @@
-- File: ProjLib_Plane.cdl
-- Created: Wed Aug 11 15:05:32 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
class Plane from ProjLib inherits Projector from ProjLib
---Purpose: Projects elementary curves on a plane.
uses
CurveType from GeomAbs,
Pln from gp,
Lin from gp,
Circ from gp,
Elips from gp,
Parab from gp,
Hypr from gp,
Lin2d from gp,
Circ2d from gp,
Elips2d from gp,
Parab2d from gp,
Hypr2d from gp
raises
NoSuchObject from Standard
is
Create returns Plane from ProjLib;
---Purpose: Undefined projection.
Create(Pl : Pln from gp) returns Plane from ProjLib;
---Purpose: Projection on the plane <Pl>.
Create(Pl : Pln from gp;
L : Lin from gp) returns Plane from ProjLib;
---Purpose: Projection of the line <L> on the plane <Pl>.
Create(Pl : Pln from gp;
C : Circ from gp) returns Plane from ProjLib;
---Purpose: Projection of the circle <C> on the plane <Pl>.
Create(Pl : Pln from gp;
E : Elips from gp) returns Plane from ProjLib;
---Purpose: Projection of the ellipse <E> on the plane <Pl>.
Create(Pl : Pln from gp;
P : Parab from gp) returns Plane from ProjLib;
---Purpose: Projection of the parabola <P> on the plane <Pl>.
Create(Pl : Pln from gp;
H : Hypr from gp) returns Plane from ProjLib;
---Purpose: Projection of the hyperbola <H> on the plane <Pl>.
Init(me : in out;
Pl : Pln from gp)
is static;
Project(me : in out;
L : Lin from gp)
is redefined;
Project(me : in out;
C : Circ from gp)
is redefined;
Project(me : in out;
E : Elips from gp)
is redefined;
Project(me : in out;
P : Parab from gp)
is redefined;
Project(me : in out;
H : Hypr from gp)
is redefined;
fields
myPlane : Pln from gp;
end Plane;

215
src/ProjLib/ProjLib_Plane.cxx Executable file
View File

@@ -0,0 +1,215 @@
// File: ProjLib_Plane.cxx
// Created: Tue Aug 24 12:10:05 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
#include <ProjLib_Plane.ixx>
#include <gp_Vec.hxx>
//=======================================================================
//function : ProjLib_Plane
//purpose :
//=======================================================================
ProjLib_Plane::ProjLib_Plane()
{
}
//=======================================================================
//function : ProjLib_Plane
//purpose :
//=======================================================================
ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl)
{
Init(Pl);
}
//=======================================================================
//function : ProjLib_Plane
//purpose :
//=======================================================================
ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Lin& L)
{
Init(Pl);
Project(L);
}
//=======================================================================
//function : ProjLib_Plane
//purpose :
//=======================================================================
ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Circ& C)
{
Init(Pl);
Project(C);
}
//=======================================================================
//function : ProjLib_Plane
//purpose :
//=======================================================================
ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Elips& E)
{
Init(Pl);
Project(E);
}
//=======================================================================
//function : ProjLib_Plane
//purpose :
//=======================================================================
ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Parab& P)
{
Init(Pl);
Project(P);
}
//=======================================================================
//function : ProjLib_Plane
//purpose :
//=======================================================================
ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Hypr& H)
{
Init(Pl);
Project(H);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void ProjLib_Plane::Init(const gp_Pln& Pl)
{
myType = GeomAbs_OtherCurve;
isDone = Standard_False;
myIsPeriodic = Standard_False;
myPlane = Pl;
}
//=======================================================================
//function : EvalPnt2d / EvalDir2d
//purpose : returns the Projected Pnt / Dir in the parametrization range
// of myPlane.
//=======================================================================
static gp_Pnt2d EvalPnt2d( const gp_Pnt P, const gp_Pln& Pl)
{
gp_Vec OP( Pl.Location(),P);
return gp_Pnt2d( OP.Dot(gp_Vec(Pl.Position().XDirection())),
OP.Dot(gp_Vec(Pl.Position().YDirection())));
}
static gp_Dir2d EvalDir2d( const gp_Dir& D, const gp_Pln& Pl)
{
return gp_Dir2d( D.Dot(Pl.Position().XDirection()),
D.Dot(Pl.Position().YDirection()));
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Plane::Project(const gp_Lin& L)
{
myType = GeomAbs_Line;
myLin = gp_Lin2d(EvalPnt2d(L.Location() ,myPlane),
EvalDir2d(L.Direction(),myPlane) );
isDone = Standard_True;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Plane::Project(const gp_Circ& C)
{
myType = GeomAbs_Circle;
gp_Pnt2d P2d = EvalPnt2d(C.Location(),myPlane);
gp_Dir2d X2d = EvalDir2d(C.Position().XDirection(),myPlane);
gp_Dir2d Y2d = EvalDir2d(C.Position().YDirection(),myPlane);
gp_Ax22d Ax(P2d,X2d,Y2d);
myCirc = gp_Circ2d(Ax, C.Radius());
myIsPeriodic = Standard_True;
isDone = Standard_True;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Plane::Project(const gp_Elips& E)
{
myType = GeomAbs_Ellipse;
gp_Pnt2d P2d = EvalPnt2d(E.Location(),myPlane);
gp_Dir2d X2d = EvalDir2d(E.Position().XDirection(),myPlane);
gp_Dir2d Y2d = EvalDir2d(E.Position().YDirection(),myPlane);
gp_Ax22d Ax(P2d,X2d,Y2d);
myElips = gp_Elips2d(Ax,E.MajorRadius(),E.MinorRadius());
myIsPeriodic = Standard_True;
isDone = Standard_True;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Plane::Project(const gp_Parab& P)
{
myType = GeomAbs_Parabola;
gp_Pnt2d P2d = EvalPnt2d(P.Location(),myPlane);
gp_Dir2d X2d = EvalDir2d(P.Position().XDirection(),myPlane);
gp_Dir2d Y2d = EvalDir2d(P.Position().YDirection(),myPlane);
gp_Ax22d Ax(P2d,X2d,Y2d);
myParab = gp_Parab2d(Ax,P.Focal());
isDone = Standard_True;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Plane::Project(const gp_Hypr& H)
{
myType = GeomAbs_Hyperbola;
gp_Pnt2d P2d = EvalPnt2d(H.Location(),myPlane);
gp_Dir2d X2d = EvalDir2d(H.Position().XDirection(),myPlane);
gp_Dir2d Y2d = EvalDir2d(H.Position().YDirection(),myPlane);
gp_Ax22d Ax(P2d,X2d,Y2d);
myHypr = gp_Hypr2d(Ax,H.MajorRadius(),H.MinorRadius());
isDone = Standard_True;
}

70
src/ProjLib/ProjLib_PrjFunc.cdl Executable file
View File

@@ -0,0 +1,70 @@
-- File: ProjLib_NbIntFunc.cdl
-- Created: Thu Nov 6 12:10:36 1997
-- Author: Roman BORISOV
-- <rbv@redfox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1997
private class PrjFunc from ProjLib inherits FunctionSetWithDerivatives from math
---Purpose:
uses
Vector from math,
Matrix from math,
CurvePtr from Adaptor3d,
SurfacePtr from Adaptor3d,
Pnt2d from gp
raises ConstructionError
is
Create (C: CurvePtr from Adaptor3d; FixVal: Real from Standard; S: SurfacePtr from Adaptor3d; Fix: Integer)
returns PrjFunc
raises ConstructionError;
NbVariables(me)
---Purpose: returns the number of variables of the function.
returns Integer;
NbEquations(me)
---Purpose: returns the number of equations of the function.
returns Integer;
Value(me: in out; X: Vector from math; F: out Vector from math)
---Purpose: computes the values <F> of the Functions for the
-- variable <X>.
-- Returns True if the computation was done successfully,
-- False otherwise.
returns Boolean;
Derivatives(me: in out; X: Vector from math; D: out Matrix from math)
---Purpose: returns the values <D> of the derivatives for the
-- variable <X>.
-- Returns True if the computation was done successfully,
-- False otherwise.
returns Boolean;
Values(me: in out; X: Vector from math; F: out Vector from math; D: out Matrix from math)
---Purpose: returns the values <F> of the functions and the derivatives
-- <D> for the variable <X>.
-- Returns True if the computation was done successfully,
-- False otherwise.
returns Boolean;
Solution(me) returns Pnt2d from gp;
---Purpose: returns point on surface
fields
myCurve : CurvePtr from Adaptor3d;
mySurface : SurfacePtr from Adaptor3d;
myt : Real from Standard;
myU, myV : Real from Standard;
myFix : Integer from Standard;
myNorm : Real from Standard;
end PrjFunc;

126
src/ProjLib/ProjLib_PrjFunc.cxx Executable file
View File

@@ -0,0 +1,126 @@
// File: ProjLib_NbIntFunc.cxx
// Created: Thu Nov 6 12:18:13 1997
// Author: Roman BORISOV
// <rbv@redfox.nnov.matra-dtv.fr>
#include <ProjLib_PrjFunc.ixx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <Adaptor3d_Surface.hxx>
#include <Adaptor3d_Curve.hxx>
ProjLib_PrjFunc::ProjLib_PrjFunc(const Adaptor3d_CurvePtr & C,const Standard_Real FixVal,const Adaptor3d_SurfacePtr & S, const Standard_Integer Fix) : myCurve(C), mySurface(S), myt(0), myU(0), myV(0), myFix(Fix)
{
myNorm=Min(1.,Min(mySurface->UResolution(1.),mySurface->VResolution(1.)));
// myNorm=1.;
switch(myFix) {
case 1: myt = FixVal; break;
case 2: myU = FixVal; break;
case 3: myV = FixVal; break;
default: Standard_ConstructionError::Raise();
}
}
Standard_Integer ProjLib_PrjFunc::NbVariables() const
{
return 2;
}
Standard_Integer ProjLib_PrjFunc::NbEquations() const
{
return 2;
}
Standard_Boolean ProjLib_PrjFunc::Value(const math_Vector& X,math_Vector& F)
{
math_Matrix D (1,2,1,2);
return Values(X,F,D);
}
Standard_Boolean ProjLib_PrjFunc::Derivatives(const math_Vector& X,math_Matrix& D)
{
math_Vector F(1,2);
return Values(X,F,D);
}
Standard_Boolean ProjLib_PrjFunc::Values(const math_Vector& X,math_Vector& F,math_Matrix& D)
{
Standard_Real u = 0., v = 0., t = 0.;
switch(myFix) {
case 1:
t = myt;
u = X(1);
v = X(2);
break;
case 2:
t = X(1);
u = myU;
v = X(2);
break;
case 3:
t = X(1);
u = X(2);
v = myV;
}
/* if(X(1) > mySup.X() || X(1) < myInf.X()) return Standard_False;
if(X(2) > mySup.Y() || X(2) < myInf.Y()) return Standard_False;
*/
gp_Pnt S, C;
gp_Vec DS1_u, DS1_v, DS2_u, DS2_uv, DS2_v, DC1_t;
myCurve->D1(t, C, DC1_t);
mySurface->D2(u, v, S, DS1_u, DS1_v, DS2_u, DS2_v, DS2_uv);
gp_Vec V(C, S);
F(1) = V*DS1_u*myNorm;
F(2) = V*DS1_v*myNorm;
switch(myFix) {
case 1:
D(1, 1) = (DS1_u.SquareMagnitude() + V*DS2_u)*myNorm; // dE1/du
D(1, 2) = (DS1_v*DS1_u + V*DS2_uv)*myNorm; // dE1/dv
D(2, 1) = D(1, 2); // dE2/du
D(2, 2) = (DS1_v.SquareMagnitude() + V*DS2_v)*myNorm; // dE2/dv
break;
case 2:
D(1, 1) = (-DC1_t*DS1_u)*myNorm; // dE1/dt
D(1, 2) = (DS1_v*DS1_u + V*DS2_uv)*myNorm; // dE1/dv
D(2, 1) = (-DC1_t*DS1_v)*myNorm; // dE2/dt
D(2, 2) = (DS1_v.SquareMagnitude() + V*DS2_v)*myNorm; // dE2/dv
break;
case 3:
D(1, 1) = -DC1_t*DS1_u*myNorm; // dE1/dt
D(1, 2) = (DS1_u.SquareMagnitude() + V*DS2_u)*myNorm; // dE1/du
D(2, 1) = -DC1_t*DS1_v*myNorm; // dE2/dt
D(2, 2) = (DS1_v*DS1_u + V*DS2_uv)*myNorm;// dE2/du
}
/* cout<<"F = ("<<F(1)<<", "<<F(2)<<")"<<endl;
cout<<"dE1/dt = "<<D(1,1)<<endl;
cout<<"dE1/dv = "<<D(1,2)<<endl;
cout<<"dE2/dt = "<<D(2,1)<<endl;
cout<<"dE2/dv = "<<D(2,2)<<endl;
*/
myU = u;
myV = v;
myt = t;
return Standard_True;
}
gp_Pnt2d ProjLib_PrjFunc::Solution() const
{
switch(myFix) {
case 1: return gp_Pnt2d(myU, myV);
case 2: return gp_Pnt2d(myt, myV);
case 3: return gp_Pnt2d(myt, myU);
}
// pout NT, meme si on n'y passe pas.
return gp_Pnt2d(0.,0.);
}

View File

@@ -0,0 +1,59 @@
-- File: ProjLib_PrjResolve.cdl
-- Created: Thu Nov 6 13:47:17 1997
-- Author: Roman BORISOV
-- <rbv@redfox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1997
private class PrjResolve from ProjLib
---Purpose:
uses
Pnt2d from gp,
Surface from Adaptor3d,
Curve from Adaptor3d,
SurfacePtr from Adaptor3d,
CurvePtr from Adaptor3d
raises
DomainError from Standard,
ConstructionError,
NotDone from StdFail
is
Create (C: Curve from Adaptor3d; S: Surface from Adaptor3d; Fix: Integer)
returns PrjResolve
raises ConstructionError;
Perform(me: in out; t, U, V: Real; Tol, Inf, Sup: Pnt2d; FTol: Real from Standard = -1; StrictInside: Boolean from Standard = Standard_False)
---Purpose: Calculates the ort from C(t) to S with a close point.
-- The close point is defined by the parameter values
-- U0 and V0.
-- The function F(u,v)=distance(S(u,v),C(t)) has an
-- extremum when gradient(F)=0. The algorithm searchs
-- a zero near the close point.
raises DomainError;
-- if U0,V0 are outside the definition ranges of the
-- surface.
IsDone (me) returns Boolean
---Purpose: Returns True if the distance is found.
is static;
Solution (me) returns Pnt2d from gp
---Purpose: Returns the point of the extremum distance.
raises NotDone from StdFail
-- if IsDone(me)=False.
is static;
fields
myCurve : CurvePtr from Adaptor3d;
mySurface : SurfacePtr from Adaptor3d;
myDone : Boolean from Standard;
mySolution : Pnt2d from gp;
myFix : Integer from Standard;
end PrjResolve;

View File

@@ -0,0 +1,119 @@
// File: ProjLib_PrjResolve.cxx
// Created: Thu Nov 6 14:02:04 1997
// Author: Roman BORISOV
// <rbv@redfox.nnov.matra-dtv.fr>
#include <ProjLib_PrjResolve.ixx>
#include <ProjLib_PrjFunc.hxx>
#include <math_FunctionSetRoot.hxx>
#include <math_NewtonFunctionSetRoot.hxx>
ProjLib_PrjResolve::ProjLib_PrjResolve(const Adaptor3d_Curve& C,const Adaptor3d_Surface& S,const Standard_Integer Fix) : myFix(Fix)
{
if (myFix > 3 || myFix < 1) Standard_ConstructionError::Raise();
mySolution = gp_Pnt2d(0.,0.);
myCurve = (Adaptor3d_CurvePtr)&C;
mySurface = (Adaptor3d_SurfacePtr)&S;
}
// void ProjLib_PrjResolve::Perform(const Standard_Real t, const Standard_Real U, const Standard_Real V, const gp_Pnt2d& Tol2d, const gp_Pnt2d& Inf, const gp_Pnt2d& Sup, const Standard_Real FuncTol, const Standard_Boolean StrictInside)
void ProjLib_PrjResolve::Perform(const Standard_Real t, const Standard_Real U, const Standard_Real V, const gp_Pnt2d& Tol2d, const gp_Pnt2d& Inf, const gp_Pnt2d& Sup, const Standard_Real FuncTol, const Standard_Boolean )
{
myDone = Standard_False;
Standard_Real FixVal = 0.;
gp_Pnt2d ExtInf(0.,0.), ExtSup(0.,0.);
Standard_Real ExtU = 10*Tol2d.X(), ExtV = 10*Tol2d.Y();
math_Vector Tol(1, 2), Start(1, 2), BInf(1, 2), BSup(1, 2);
ExtInf.SetCoord(Inf.X() - ExtU, Inf.Y() - ExtV);
ExtSup.SetCoord(Sup.X() + ExtU, Sup.Y() + ExtV);
BInf(1) = ExtInf.X();
BInf(2) = ExtInf.Y();
BSup(1) = ExtSup.X();
BSup(2) = ExtSup.Y();
Tol(1) = Tol2d.X();
Tol(2) = Tol2d.Y();
switch(myFix) {
case 1:
Start(1) = U;
Start(2) = V;
FixVal = t;
break;
case 2:
Start(1) = t;
Start(2) = V;
FixVal = U;
break;
case 3:
Start(1) = t;
Start(2) = U;
FixVal = V;
}
ProjLib_PrjFunc F(myCurve, FixVal, mySurface, myFix);
// Standard_Integer option = 1;//2;
// if (option == 1) {
// math_FunctionSetRoot S1 (F, Start,Tol, BInf, BSup);
// if (!S1.IsDone()) { return; }
// }
// else {
math_NewtonFunctionSetRoot SR (F, Tol, 1.e-10);
SR.Perform(F, Start, BInf, BSup);
// if (!SR.IsDone()) { return; }
if (!SR.IsDone()) {
math_FunctionSetRoot S1 (F, Start,Tol, BInf, BSup);
if (!S1.IsDone()) { return; }
}
mySolution.SetXY(F.Solution().XY());
// computation of myDone
myDone = Standard_True;
Standard_Real ExtraU , ExtraV;
// if(!StrictInside) {
ExtraU = Tol2d.X();
ExtraV = Tol2d.Y();
// }
if (Abs(mySolution.X()-Inf.X()) < Tol2d.X()) mySolution.SetX(Inf.X());
if (Abs(mySolution.X()-Sup.X()) < Tol2d.X()) mySolution.SetX(Sup.X());
if (Abs(mySolution.Y()-Inf.Y()) < Tol2d.Y()) mySolution.SetY(Inf.Y());
if (Abs(mySolution.Y()-Sup.Y()) < Tol2d.Y()) mySolution.SetY(Sup.Y());
if (mySolution.X() < Inf.X() - ExtraU ||
mySolution.X() > Sup.X() + ExtraU ||
mySolution.Y() < Inf.Y() - ExtraV ||
mySolution.Y() > Sup.Y() + ExtraV) myDone = Standard_False;
else if (FuncTol > 0) {
math_Vector X(1,2,0.), FVal(1,2,0.);
X(1) = mySolution.X();
X(2) = mySolution.Y();
F.Value(X, FVal);
#ifdef DEB
Standard_Real FuncVal= FVal(1)*FVal(1) + FVal(2)*FVal(2);
#endif
if ((FVal(1)*FVal(1) + FVal(2)*FVal(2)) > FuncTol) myDone = Standard_False;
}
}
Standard_Boolean ProjLib_PrjResolve::IsDone() const
{
return myDone;
}
gp_Pnt2d ProjLib_PrjResolve::Solution() const
{
if (!IsDone()) StdFail_NotDone::Raise();
return mySolution;
}

View File

@@ -0,0 +1,302 @@
-- File: ProjLib_ProjectOnPlane.cdl
-- Created: Fri Sep 2 15:56:32 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1994
class ProjectOnPlane from ProjLib inherits Curve from Adaptor3d
---Purpose: Class used to project a 3d curve on a plane. The
-- result will be a 3d curve.
--
-- You can ask the projected curve to have the same
-- parametrization as the original curve.
--
-- The projection can be done along every direction not
-- parallel to the plane.
--
uses
Shape from GeomAbs,
CurveType from GeomAbs,
Dir from gp,
Ax3 from gp,
Vec from gp,
Pnt from gp,
Circ from gp,
Elips from gp,
Hypr from gp,
Parab from gp,
Lin from gp,
Curve from Adaptor3d,
HCurve from GeomAdaptor,
HCurve from Adaptor3d,
BezierCurve from Geom,
BSplineCurve from Geom,
Array1OfPnt from TColgp,
Array1OfReal from TColStd,
Array1OfInteger from TColStd
raises
OutOfRange from Standard,
NoSuchObject from Standard,
DomainError from Standard,
ConstructionError from Standard,
NotImplemented from Standard
is
Create returns ProjectOnPlane from ProjLib;
---Purpose: Empty constructor.
Create( Pl : Ax3 from gp)
---Purpose: The projection will be normal to the Plane defined
-- by the Ax3 <Pl>.
returns ProjectOnPlane from ProjLib;
Create( Pl : Ax3 from gp;
D : Dir from gp )
returns ProjectOnPlane from ProjLib
---Purpose: The projection will be along the direction <D> on
-- the plane defined by the Ax3 <Pl>.
raises
ConstructionError from Standard;
---Purpose: raises if the direction <D> is parallel to the
-- plane <Pl>.
Load(me : in out;
C : HCurve from Adaptor3d;
Tolerance : Real from Standard;
KeepParametrization : Boolean from Standard = Standard_True)
---Purpose: Sets the Curve and perform the projection. if
-- <KeepParametrization> is true, the parametrization
-- of the Projected Curve <PC> will be the same as
-- the parametrization of the initial curve <C>. It
-- meens: proj(C(u)) = PC(u) for each u. Otherwize,
-- the parametrization may change.
is static;
GetPlane(me) returns Ax3 from gp
---C++: return const &
is static;
GetDirection (me) returns Dir from gp
---C++: return const &
is static;
GetCurve(me) returns HCurve from Adaptor3d
---C++: return const &
is static;
--
-- Global methods - Apply to the whole curve.
--
FirstParameter(me) returns Real
is redefined static;
LastParameter(me) returns Real
is redefined static;
Continuity(me) returns Shape from GeomAbs
is redefined static;
NbIntervals(me: in out; S : Shape from GeomAbs) returns Integer
---Purpose: If necessary, breaks the curve in intervals of
-- continuity <S>. And returns the number of
-- intervals.
is redefined static;
Intervals(me: in out; T : in out Array1OfReal from TColStd;
S : Shape from GeomAbs)
---Purpose: Stores in <T> the parameters bounding the intervals
-- of continuity <S>.
--
-- The array must provide enough room to accomodate
-- for the parameters. i.e. T.Length() > NbIntervals()
raises
OutOfRange from Standard
is redefined static;
Trim(me; First, Last, Tol : Real) returns HCurve from Adaptor3d
---Purpose: Returns a curve equivalent of <me> between
-- parameters <First> and <Last>. <Tol> is used to
-- test for 3d points confusion.
raises
OutOfRange from Standard
---Purpose: If <First> >= <Last>
is redefined static;
IsClosed(me) returns Boolean
is redefined static;
IsPeriodic(me) returns Boolean
is redefined static;
Period(me) returns Real
raises
DomainError from Standard -- if the curve is not periodic
is redefined static;
Value(me; U : Real) returns Pnt from gp
--- Purpose : Computes the point of parameter U on the curve.
is redefined static;
D0 (me; U : Real; P : out Pnt from gp)
--- Purpose : Computes the point of parameter U on the curve.
is redefined static;
D1 (me; U : Real; P : out Pnt from gp ; V : out Vec from gp)
--- Purpose : Computes the point of parameter U on the curve with its
-- first derivative.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C1.
is redefined static;
D2 (me; U : Real; P : out Pnt from gp; V1, V2 : out Vec from gp)
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C2.
is redefined static;
D3 (me; U : Real; P : out Pnt from gp; V1, V2, V3 : out Vec from gp)
--- Purpose :
-- Returns the point P of parameter U, the first, the second
-- and the third derivative.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C3.
is redefined static;
DN (me; U : Real; N : Integer) returns Vec from gp
--- Purpose :
-- The returned vector gives the value of the derivative for the
-- order of derivation N.
raises
DomainError from Standard,
--- Purpose : Raised if the continuity of the current interval
-- is not CN.
OutOfRange from Standard
--- Purpose : Raised if N < 1.
is redefined static;
Resolution(me; R3d : Real) returns Real
---Purpose : Returns the parametric resolution corresponding
-- to the real space resolution <R3d>.
is redefined static;
GetType(me) returns CurveType from GeomAbs
---Purpose: Returns the type of the curve in the current
-- interval : Line, Circle, Ellipse, Hyperbola,
-- Parabola, BezierCurve, BSplineCurve, OtherCurve.
is redefined static;
--
-- The following methods must be called when GetType returned
-- the corresponding type.
--
Line(me) returns Lin from gp
raises
NoSuchObject from Standard
is redefined static;
Circle(me) returns Circ from gp
raises
NoSuchObject from Standard
is redefined static;
Ellipse(me) returns Elips from gp
raises
NoSuchObject from Standard
is redefined static;
Hyperbola(me) returns Hypr from gp
raises
NoSuchObject from Standard
is redefined static;
Parabola(me) returns Parab from gp
raises
NoSuchObject from Standard
is redefined static;
Degree(me) returns Integer
raises
NoSuchObject from Standard
is redefined static;
IsRational(me) returns Boolean
raises
NoSuchObject from Standard
is redefined static;
NbPoles(me) returns Integer
raises
NoSuchObject from Standard
is redefined static;
NbKnots(me) returns Integer
raises
NoSuchObject from Standard
is redefined static;
Bezier(me) returns BezierCurve from Geom
raises
NoSuchObject from Standard
is redefined static;
---Purpose: Warning ! this will NOT make a copy of the
-- Bezier Curve : If you want to modify
-- the Curve please make a copy yourself
-- Also it will NOT trim the surface to
-- myFirst/Last.
BSpline(me) returns BSplineCurve from Geom
raises
NoSuchObject from Standard
is redefined static;
---Purpose: Warning ! this will NOT make a copy of the
-- BSpline Curve : If you want to modify
-- the Curve please make a copy yourself
-- Also it will NOT trim the surface to
-- myFirst/Last.
fields
myCurve : HCurve from Adaptor3d ;
myPlane : Ax3 from gp;
myDirection : Dir from gp;
myKeepParam : Boolean from Standard;
myFirstPar : Real from Standard;
myLastPar : Real from Standard;
myTolerance : Real from Standard;
-- the tolerance to make the approximation if
-- necessary
myType : CurveType from GeomAbs;
myResult : HCurve from GeomAdaptor ;
myIsApprox : Boolean from Standard;
-- the result of the approximation
end ProjectOnPlane;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
-- File: ProjLib_ProjectOnSurface.cdl
-- Created: Thu Sep 15 15:35:59 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1994
class ProjectOnSurface from ProjLib
uses
HCurve from Adaptor3d,
HSurface from Adaptor3d,
BSplineCurve from Geom
is
Create
---Purpose: Create an empty projector.
returns ProjectOnSurface from ProjLib;
Create( S : HSurface from Adaptor3d)
---Purpose: Create a projector normaly to the surface <S>.
returns ProjectOnSurface from ProjLib;
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~ProjLib_ProjectOnSurface(){Delete() ; }"
Load(me : in out; S : HSurface from Adaptor3d)
---Purpose: Set the Surface to <S>.
-- To compute the projection, you have to Load the Curve.
is static;
Load(me : in out; C : HCurve from Adaptor3d; Tolerance : Real)
---Purpose: Compute the projection of the curve <C> on the Surface.
is static;
IsDone(me) returns Boolean ;
BSpline(me) returns BSplineCurve from Geom
is static ;
fields
myCurve : HCurve from Adaptor3d ;
mySurface : HSurface from Adaptor3d ;
myTolerance : Real ;
myIsDone : Boolean ;
myResult : BSplineCurve from Geom ;
end ProjectOnSurface;

View File

@@ -0,0 +1,248 @@
// File: ProjLib_ProjectOnSurface.gxx
// Created: Thu Sep 15 15:45:43 1994
// Author: Bruno DUMORTIER
// <dub@fuegox>
#include <ProjLib_ProjectOnSurface.ixx>
#include <AppCont_Function.hxx>
#include <Approx_FitAndDivide.hxx>
#include <AppParCurves_MultiCurve.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Extrema_POnSurf.hxx>
#include <Precision.hxx>
#include <BSplCLib.hxx>
#include <PLib.hxx>
#include <Adaptor3d_HCurve.hxx>
#include <Handle_Adaptor3d_HCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Handle_Geom_BSplineCurve.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Extrema_ExtPS.hxx>
//=======================================================================
//function : OnSurface_Value
//purpose : Evaluate current point of the projected curve
//=======================================================================
static gp_Pnt OnSurface_Value(const Standard_Real U,
const Handle(Adaptor3d_HCurve)& myCurve,
Extrema_ExtPS * myExtPS)
{
// on essaie de rendre le point solution le plus proche.
myExtPS->Perform(myCurve->Value(U));
Standard_Real Dist2Min = RealLast();
Standard_Integer Index = 0;
for ( Standard_Integer i = 1; i <= myExtPS->NbExt(); i++) {
if ( myExtPS->SquareDistance(i) < Dist2Min) {
Index = i;
Dist2Min = myExtPS->SquareDistance(Index);
}
}
if ( Index == 0 ) {
cout << " Extrema non trouve pour U = " << U << endl;
return gp_Pnt(0.,0.,0.);
}
else {
return (myExtPS->Point(Index)).Value();
}
}
//=======================================================================
//function : OnSurface_D1
//purpose :
//=======================================================================
static Standard_Boolean OnSurface_D1(const Standard_Real , // U,
gp_Pnt& , // P,
gp_Vec& , // V,
const Handle(Adaptor3d_HCurve)& , // myCurve,
Extrema_ExtPS *) // myExtPS)
{
return Standard_False;
}
//=======================================================================
// class : ProjLib_OnSurface
//purpose : Use to approximate the projection on a plane
//=======================================================================
class ProjLib_OnSurface : public AppCont_Function
{
Handle(Adaptor3d_HCurve) myCurve;
Extrema_ExtPS *myExtPS;
public :
ProjLib_OnSurface(const Handle(Adaptor3d_HCurve) & C,
const Handle(Adaptor3d_HSurface) & S)
: myCurve(C)
{Standard_Real U = myCurve->FirstParameter();
gp_Pnt P = myCurve->Value(U);
Standard_Real Tol = Precision::PConfusion();
myExtPS = new Extrema_ExtPS(P,S->Surface(),Tol,Tol);}
~ProjLib_OnSurface() { delete myExtPS; }
Standard_Real FirstParameter() const
{return myCurve->FirstParameter();}
Standard_Real LastParameter() const
{return myCurve->LastParameter();}
gp_Pnt Value( const Standard_Real t) const
{return OnSurface_Value(t,myCurve,myExtPS);}
Standard_Boolean D1(const Standard_Real t, gp_Pnt& P, gp_Vec& V) const
{return OnSurface_D1(t,P,V,myCurve,myExtPS);}
};
//=====================================================================//
// //
// D E S C R I P T I O N O F T H E C L A S S : //
// //
// P r o j L i b _ A p p r o x P r o j e c t O n P l a n e //
// //
//=====================================================================//
//=======================================================================
//function : ProjLib_ProjectOnSurface
//purpose :
//=======================================================================
ProjLib_ProjectOnSurface::ProjLib_ProjectOnSurface() :
myIsDone(Standard_False)
{
}
//=======================================================================
//function : ProjLib_ProjectOnSurface
//purpose :
//=======================================================================
ProjLib_ProjectOnSurface::ProjLib_ProjectOnSurface
(const Handle(Adaptor3d_HSurface)& S ) :
myIsDone(Standard_False)
{
mySurface = S;
}
void ProjLib_ProjectOnSurface::Load(const Handle(Adaptor3d_HCurve)& C,
const Standard_Real Tolerance)
{
myTolerance = Tolerance ;
myCurve = C;
myIsDone = Standard_False ;
if (!mySurface.IsNull()) {
ProjLib_OnSurface F(myCurve, mySurface);
Standard_Integer Deg1, Deg2;
Deg1 = 8; Deg2 = 8;
Approx_FitAndDivide Fit(F,Deg1,Deg2,Precision::Approximation(),
Precision::PApproximation(),Standard_True);
Standard_Integer i;
Standard_Integer NbCurves = Fit.NbMultiCurves();
Standard_Integer MaxDeg = 0;
// Pour transformer la MultiCurve en BSpline, il faut que toutes
// les Bezier la constituant aient le meme degre -> Calcul de MaxDeg
Standard_Integer NbPoles = 1;
for (i = 1; i <= NbCurves; i++) {
Standard_Integer Deg = Fit.Value(i).Degree();
MaxDeg = Max ( MaxDeg, Deg);
}
NbPoles = MaxDeg * NbCurves + 1; //Poles sur la BSpline
TColgp_Array1OfPnt Poles( 1, NbPoles);
TColgp_Array1OfPnt TempPoles( 1, MaxDeg + 1); //pour augmentation du degre
TColStd_Array1OfReal Knots( 1, NbCurves + 1); //Noeuds de la BSpline
Standard_Integer Compt = 1;
for (i = 1; i <= Fit.NbMultiCurves(); i++) {
Fit.Parameters(i, Knots(i), Knots(i+1));
AppParCurves_MultiCurve MC = Fit.Value( i); //Charge la Ieme Curve
TColgp_Array1OfPnt LocalPoles( 1, MC.Degree() + 1);//Recupere les poles
MC.Curve(1, Poles);
//Augmentation eventuelle du degre
Standard_Integer Inc = MaxDeg - MC.Degree();
if ( Inc > 0) {
BSplCLib::IncreaseDegree( Inc, LocalPoles, PLib::NoWeights(),
TempPoles, PLib::NoWeights());
//mise a jour des poles de la PCurve
for (Standard_Integer j = 1 ; j <= MaxDeg + 1; j++) {
Poles.SetValue( Compt, TempPoles( j));
Compt++;
}
}
else {
//mise a jour des poles de la PCurve
for (Standard_Integer j = 1 ; j <= MaxDeg + 1; j++) {
Poles.SetValue( Compt, LocalPoles( j));
Compt++;
}
}
Compt--;
}
//mise a jour des fields de ProjLib_Approx
Standard_Integer NbKnots = NbCurves + 1;
TColStd_Array1OfInteger Mults( 1, NbKnots);
Mults.SetValue( 1, MaxDeg + 1);
for ( i = 2; i <= NbCurves; i++) {
Mults.SetValue( i, MaxDeg);
}
Mults.SetValue(NbKnots, MaxDeg + 1);
myResult =
new Geom_BSplineCurve(Poles,
Knots,
Mults,
MaxDeg,
Standard_False) ;
myIsDone = Standard_True ;
}
}
void ProjLib_ProjectOnSurface::Delete()
{}
//=======================================================================
//function : BSpline
//purpose :
//=======================================================================
Handle(Geom_BSplineCurve) ProjLib_ProjectOnSurface::BSpline() const
{
Standard_NoSuchObject_Raise_if
(!myIsDone,
"ProjLib_ProjectOnSurface:BSpline");
return myResult ;
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean ProjLib_ProjectOnSurface::IsDone() const
{
return myIsDone;
}

View File

@@ -0,0 +1,273 @@
-- File: ProjLib_ProjectedCurve.cdl
-- Created: Wed Aug 25 15:07:07 1993
-- Author: Bruno DUMORTIER
-- <dub@topsn3>
---Copyright: Matra Datavision 1993
class ProjectedCurve from ProjLib inherits Curve2d from Adaptor2d
uses
Projector from ProjLib,
Shape from GeomAbs,
CurveType from GeomAbs,
Vec2d from gp,
Pnt2d from gp,
Circ2d from gp,
Elips2d from gp,
Hypr2d from gp,
Parab2d from gp,
Lin2d from gp,
HCurve from Adaptor3d,
HCurve2d from Adaptor2d,
HSurface from Adaptor3d,
BezierCurve from Geom2d,
BSplineCurve from Geom2d,
Array1OfReal from TColStd
raises
OutOfRange from Standard,
NoSuchObject from Standard,
DomainError from Standard,
NotImplemented from Standard
is
Create returns ProjectedCurve;
Create(S : HSurface from Adaptor3d)
returns ProjectedCurve;
Create(S : HSurface from Adaptor3d;
C : HCurve from Adaptor3d)
returns ProjectedCurve;
Create(S : HSurface from Adaptor3d;
C : HCurve from Adaptor3d;
Tol : Real from Standard)
returns ProjectedCurve;
Load(me : in out ; Tolerance : Real)
---Purpose: Changes the tolerance used to project
-- the curve on the surface
is static;
Load(me : in out; S : HSurface from Adaptor3d)
---Purpose: Changes the Surface.
is static;
Load(me : in out; C : HCurve from Adaptor3d)
---Purpose: Changes the Curve.
is static;
GetSurface(me) returns HSurface from Adaptor3d
---C++: return const &
is static;
GetCurve(me) returns HCurve from Adaptor3d
---C++: return const &
is static;
GetTolerance(me) returns Real from Standard
---Purpose: returns the tolerance reached if an approximation
-- is Done.
is static;
--
-- Global methods - Apply to the whole curve.
--
FirstParameter(me) returns Real
is redefined static;
LastParameter(me) returns Real
is redefined static;
Continuity(me) returns Shape from GeomAbs
is redefined static;
NbIntervals(me ; S : Shape from GeomAbs) returns Integer
---Purpose: If necessary, breaks the curve in intervals of
-- continuity <S>. And returns the number of
-- intervals.
is redefined static;
Intervals(me; T : in out Array1OfReal from TColStd;
S : Shape from GeomAbs)
---Purpose: Stores in <T> the parameters bounding the intervals
-- of continuity <S>.
--
-- The array must provide enough room to accomodate
-- for the parameters. i.e. T.Length() > NbIntervals()
raises
OutOfRange from Standard
is redefined static;
Trim(me; First, Last, Tol : Real) returns HCurve2d from Adaptor2d
---Purpose: Returns a curve equivalent of <me> between
-- parameters <First> and <Last>. <Tol> is used to
-- test for 3d points confusion.
raises
OutOfRange from Standard
---Purpose: If <First> >= <Last>
is redefined static;
IsClosed(me) returns Boolean
is redefined static;
IsPeriodic(me) returns Boolean
is redefined static;
Period(me) returns Real
raises
DomainError from Standard -- if the curve is not periodic
is redefined static;
Value(me; U : Real) returns Pnt2d from gp
--- Purpose : Computes the point of parameter U on the curve.
is redefined static;
D0 (me; U : Real; P : out Pnt2d from gp)
--- Purpose : Computes the point of parameter U on the curve.
is redefined static;
D1 (me; U : Real; P : out Pnt2d from gp ; V : out Vec2d from gp)
--- Purpose : Computes the point of parameter U on the curve with its
-- first derivative.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C1.
is redefined static;
D2 (me; U : Real; P : out Pnt2d from gp; V1, V2 : out Vec2d from gp)
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C2.
is redefined static;
D3 (me; U : Real; P : out Pnt2d from gp; V1, V2, V3 : out Vec2d from gp)
--- Purpose :
-- Returns the point P of parameter U, the first, the second
-- and the third derivative.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C3.
is redefined static;
DN (me; U : Real; N : Integer) returns Vec2d from gp
--- Purpose :
-- The returned vector gives the value of the derivative for the
-- order of derivation N.
raises
DomainError from Standard,
--- Purpose : Raised if the continuity of the current interval
-- is not CN.
OutOfRange from Standard
--- Purpose : Raised if N < 1.
is redefined static;
Resolution(me; R3d : Real) returns Real
---Purpose : Returns the parametric resolution corresponding
-- to the real space resolution <R3d>.
is redefined static;
GetType(me) returns CurveType from GeomAbs
---Purpose: Returns the type of the curve in the current
-- interval : Line, Circle, Ellipse, Hyperbola,
-- Parabola, BezierCurve, BSplineCurve, OtherCurve.
is redefined static;
--
-- The following methods must be called when GetType returned
-- the corresponding type.
--
Line(me) returns Lin2d from gp
raises
NoSuchObject from Standard
is redefined static;
Circle(me) returns Circ2d from gp
raises
NoSuchObject from Standard
is redefined static;
Ellipse(me) returns Elips2d from gp
raises
NoSuchObject from Standard
is redefined static;
Hyperbola(me) returns Hypr2d from gp
raises
NoSuchObject from Standard
is redefined static;
Parabola(me) returns Parab2d from gp
raises
NoSuchObject from Standard
is redefined static;
Degree(me) returns Integer
raises
NoSuchObject from Standard
is redefined static;
IsRational(me) returns Boolean
raises
NoSuchObject from Standard
is redefined static;
NbPoles(me) returns Integer
raises
NoSuchObject from Standard
is redefined static;
NbKnots(me) returns Integer
raises
NoSuchObject from Standard
is redefined static;
Bezier(me) returns BezierCurve from Geom2d
raises
NoSuchObject from Standard
is redefined static;
---Purpose: Warning ! This will NOT make a copy of the -- Bezier Curve -
-- If you want to modify -- the Curve please make a copy
-- yourself -- Also it will NOT trim the surface to --
-- myFirst/Last.
BSpline(me) returns BSplineCurve from Geom2d
raises
NoSuchObject from Standard
is redefined static;
---Purpose: Warning ! This will NOT make a copy of the BSpline Curve - If
-- you want to modify the Curve please make a copy
-- yourself Also it will NOT trim the surface to
-- myFirst/Last.
fields
myTolerance : Real ;
mySurface : HSurface from Adaptor3d ;
myCurve : HCurve from Adaptor3d ;
myResult : Projector from ProjLib ;
end ProjectedCurve;

File diff suppressed because it is too large Load Diff

159
src/ProjLib/ProjLib_Projector.cdl Executable file
View File

@@ -0,0 +1,159 @@
-- File: ProjLib_Projector.cdl
-- Created: Wed Aug 11 17:34:28 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
class Projector from ProjLib
---Purpose: Root class for projection algorithms, stores the result.
uses
CurveType from GeomAbs,
Lin from gp,
Circ from gp,
Elips from gp,
Parab from gp,
Hypr from gp,
Lin2d from gp,
Circ2d from gp,
Elips2d from gp,
Parab2d from gp,
Hypr2d from gp,
BezierCurve from Geom2d,
BSplineCurve from Geom2d
raises
NoSuchObject from Standard,
NotImplemented from Standard
is
Create ;
---Purpose: Sets the type to OtherCurve
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~ProjLib_Projector(){Delete() ; }"
IsDone(me) returns Boolean from Standard
is static;
Done(me : in out)
---Purpose: Set isDone = Standard_True;
is static;
GetType(me) returns CurveType from GeomAbs
is static;
SetBSpline(me : in out; C : BSplineCurve from Geom2d)
is static;
SetBezier(me : in out; C : BezierCurve from Geom2d)
is static;
SetType(me : in out; Type : CurveType from GeomAbs)
is static;
IsPeriodic(me)
returns Boolean from Standard
is static;
SetPeriodic(me: in out)
is static;
Line(me) returns Lin2d from gp
---C++: return const &
raises
NoSuchObject from Standard
is static;
Circle(me) returns Circ2d from gp
---C++: return const &
raises
NoSuchObject from Standard
is static;
Ellipse(me) returns Elips2d from gp
---C++: return const &
raises
NoSuchObject from Standard
is static;
Hyperbola(me) returns Hypr2d from gp
---C++: return const &
raises
NoSuchObject from Standard
is static;
Parabola(me) returns Parab2d from gp
---C++: return const &
raises
NoSuchObject from Standard
is static;
Bezier(me) returns BezierCurve from Geom2d
raises
NoSuchObject from Standard
is static;
BSpline(me) returns BSplineCurve from Geom2d
raises
NoSuchObject from Standard
is static;
Project(me : in out;
L : Lin from gp)
is virtual;
Project(me : in out;
C : Circ from gp)
is virtual;
Project(me : in out;
E : Elips from gp)
is virtual;
Project(me : in out;
P : Parab from gp)
is virtual;
Project(me : in out;
H : Hypr from gp)
is virtual;
UFrame(me : in out;
CFirst, CLast : Real from Standard; -- Bounds of the curve
UFirst, Period : Real from Standard) -- UBounds of the surface
---Purpose: Translates the 2d curve
-- to set the part of the curve [CFirst, CLast]
-- in the range [ UFirst, UFirst + Period [
is static;
VFrame(me : in out;
CFirst, CLast : Real from Standard; -- Bounds of the curve
VFirst, Period : Real from Standard) -- VBounds of the surface
---Purpose: Translates the 2d curve
-- to set the part of the curve [CFirst, CLast]
-- in the range [ VFirst, VFirst + Period [
is static;
fields
myType : CurveType from GeomAbs is protected;
myLin : Lin2d from gp is protected;
myCirc : Circ2d from gp is protected;
myElips : Elips2d from gp is protected;
myHypr : Hypr2d from gp is protected;
myParab : Parab2d from gp is protected;
myBSpline : BSplineCurve from Geom2d is protected;
myBezier : BezierCurve from Geom2d is protected;
myIsPeriodic : Boolean from Standard is protected;
isDone : Boolean from Standard is protected;
end Projector;

304
src/ProjLib/ProjLib_Projector.cxx Executable file
View File

@@ -0,0 +1,304 @@
// File: ProjLib_Projector.cxx
// Created: Tue Aug 24 12:05:40 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
// Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272
#include <ProjLib_Projector.ixx>
#include <ElCLib.hxx>
//=======================================================================
//function : ProjLib_Projector
//purpose :
//=======================================================================
ProjLib_Projector::ProjLib_Projector()
{}
//=======================================================================
void ProjLib_Projector::Delete()
{}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean ProjLib_Projector::IsDone() const
{
return isDone;
}
//=======================================================================
//function : Done
//purpose :
//=======================================================================
void ProjLib_Projector::Done()
{
isDone = Standard_True;
}
//=======================================================================
//function : GetType
//purpose :
//=======================================================================
GeomAbs_CurveType ProjLib_Projector::GetType() const
{
return myType;
}
//=======================================================================
//function : SetType
//purpose :
//=======================================================================
void ProjLib_Projector::SetType( const GeomAbs_CurveType Type)
{
myType = Type;
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean ProjLib_Projector::IsPeriodic() const
{
return myIsPeriodic;
}
//=======================================================================
//function : SetPeriodic
//purpose :
//=======================================================================
void ProjLib_Projector::SetPeriodic()
{
myIsPeriodic = Standard_True;
}
//=======================================================================
//function : Line
//purpose :
//=======================================================================
const gp_Lin2d& ProjLib_Projector::Line()const
{
if (myType != GeomAbs_Line)
Standard_NoSuchObject::Raise("ProjLib_Projector::Line");
return myLin;
}
//=======================================================================
//function : Circle
//purpose :
//=======================================================================
const gp_Circ2d& ProjLib_Projector::Circle()const
{
if (myType != GeomAbs_Circle)
Standard_NoSuchObject::Raise("ProjLib_Projector::Circle");
return myCirc;
}
//=======================================================================
//function : Ellipse
//purpose :
//=======================================================================
const gp_Elips2d& ProjLib_Projector::Ellipse()const
{
if (myType != GeomAbs_Ellipse)
Standard_NoSuchObject::Raise("ProjLib_Projector::Ellipse");
return myElips;
}
//=======================================================================
//function : Hyperbola
//purpose :
//=======================================================================
const gp_Hypr2d& ProjLib_Projector::Hyperbola()const
{
if (myType != GeomAbs_Hyperbola)
Standard_NoSuchObject::Raise("ProjLib_Projector::Hyperbola");
return myHypr;
}
//=======================================================================
//function : Parabola
//purpose :
//=======================================================================
const gp_Parab2d& ProjLib_Projector::Parabola()const
{
if (myType != GeomAbs_Parabola)
Standard_NoSuchObject::Raise("ProjLib_Projector::Parabola");
return myParab;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Projector::Project(const gp_Lin& )
{
myType = GeomAbs_OtherCurve;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Projector::Project(const gp_Circ& )
{
myType = GeomAbs_OtherCurve;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Projector::Project(const gp_Elips& )
{
myType = GeomAbs_OtherCurve;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Projector::Project(const gp_Parab& )
{
myType = GeomAbs_OtherCurve;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Projector::Project(const gp_Hypr& )
{
myType = GeomAbs_OtherCurve;
}
//=======================================================================
//function : UFrame
//purpose :
//=======================================================================
void ProjLib_Projector::UFrame(const Standard_Real CFirst,
// const Standard_Real CLast,
const Standard_Real ,
const Standard_Real UFirst,
const Standard_Real Period)
{
if (myType == GeomAbs_Line) {
// Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
// if ( myLin.Direction().Y() == 0.) {
// Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
// gp_Pnt2d PFirst, PLast;
gp_Pnt2d PFirst;
PFirst = ElCLib::Value(CFirst,myLin);
//PLast = ElCLib::Value(CLast ,myLin);
//Standard_Real U = Min( PFirst.X(), PLast.X());
Standard_Real U = PFirst.X();
Standard_Real NewU = ElCLib::InPeriod(U,UFirst, UFirst + Period);
myLin.Translate(gp_Vec2d(NewU-U,0.));
}
}
//=======================================================================
//function : VFrame
//purpose :
//=======================================================================
void ProjLib_Projector::VFrame(const Standard_Real CFirst,
// const Standard_Real CLast,
const Standard_Real ,
const Standard_Real VFirst,
const Standard_Real Period)
{
if (myType == GeomAbs_Line) {
// Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
// if ( myLin.Direction().X() == 0.) {
// Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
// gp_Pnt2d PFirst, PLast;
gp_Pnt2d PFirst;
PFirst = ElCLib::Value(CFirst,myLin);
//PLast = ElCLib::Value(CLast ,myLin);
//Standard_Real V = Min( PFirst.Y(), PLast.Y());
Standard_Real V = PFirst.Y();
Standard_Real NewV = ElCLib::InPeriod(V,VFirst, VFirst + Period);
myLin.Translate(gp_Vec2d(0.,NewV-V));
}
}
//=======================================================================
//function : SetBezier
//purpose :
//=======================================================================
void ProjLib_Projector::SetBezier(const Handle(Geom2d_BezierCurve)& C)
{
myBezier = C ;
}
//=======================================================================
//function : Bezier
//purpose :
//=======================================================================
Handle(Geom2d_BezierCurve)ProjLib_Projector::Bezier() const
{
return myBezier ;
}
//=======================================================================
//function : SetBSpline
//purpose :
//=======================================================================
void ProjLib_Projector::SetBSpline(const Handle(Geom2d_BSplineCurve)& C)
{
myBSpline = C ;
}
//=======================================================================
//function : BSpline
//purpose :
//=======================================================================
Handle(Geom2d_BSplineCurve) ProjLib_Projector::BSpline() const
{
return myBSpline ;
}

77
src/ProjLib/ProjLib_Sphere.cdl Executable file
View File

@@ -0,0 +1,77 @@
-- File: ProjLib_Sphere.cdl
-- Created: Tue Aug 24 11:23:41 1993
-- Author: Bruno DUMORTIER
-- <dub@topsn3>
---Copyright: Matra Datavision 1993
class Sphere from ProjLib inherits Projector from ProjLib
---Purpose: Projects elementary curves on a sphere.
uses
CurveType from GeomAbs,
Sphere from gp,
Lin from gp,
Circ from gp,
Elips from gp,
Parab from gp,
Hypr from gp,
Lin2d from gp,
Circ2d from gp,
Elips2d from gp,
Parab2d from gp,
Hypr2d from gp
raises
NoSuchObject from Standard
is
Create returns Sphere from ProjLib;
---Purpose: Undefined projection.
Create(Sp : Sphere from gp) returns Sphere from ProjLib;
---Purpose: Projection on the sphere <Sp>.
Create(Sp : Sphere from gp;
C : Circ from gp) returns Sphere from ProjLib;
---Purpose: Projection of the circle <C> on the sphere <Sp>.
Init(me : in out;
Sp : Sphere from gp)
is static;
Project(me : in out;
L : Lin from gp)
is redefined;
Project(me : in out;
C : Circ from gp)
is redefined;
Project(me : in out;
E : Elips from gp)
is redefined;
Project(me : in out;
P : Parab from gp)
is redefined;
Project(me : in out;
H : Hypr from gp)
is redefined;
SetInBounds(me: in out;
U : Real from Standard)
---Purpose: Set the point of parameter U on C in the natural
-- restrictions of the sphere.
is static;
fields
mySphere : Sphere from gp;
end Sphere;

252
src/ProjLib/ProjLib_Sphere.cxx Executable file
View File

@@ -0,0 +1,252 @@
// File: ProjLib_Sphere.cxx
// Created: Tue Aug 24 17:18:17 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
// Modified by skv - Tue Aug 1 16:29:59 2006 OCC13116
#include <Standard_NotImplemented.hxx>
#include <ProjLib_Sphere.ixx>
#include <ElCLib.hxx>
#include <Precision.hxx>
#include <gp.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
#include <gp_Trsf2d.hxx>
#include <StdFail_NotDone.hxx>
//=======================================================================
//function : ProjLib_Sphere
//purpose :
//=======================================================================
ProjLib_Sphere::ProjLib_Sphere()
{
}
//=======================================================================
//function : ProjLib_Sphere
//purpose :
//=======================================================================
ProjLib_Sphere::ProjLib_Sphere(const gp_Sphere& Sp)
{
Init(Sp);
}
//=======================================================================
//function : ProjLib_Sphere
//purpose :
//=======================================================================
ProjLib_Sphere::ProjLib_Sphere(const gp_Sphere& Sp, const gp_Circ& C)
{
Init(Sp);
Project(C);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void ProjLib_Sphere::Init(const gp_Sphere& Sp)
{
myType = GeomAbs_OtherCurve;
mySphere = Sp;
myIsPeriodic = Standard_False;
isDone = Standard_False;
}
//=======================================================================
//function : EvalPnt2d / EvalDir2d
//purpose : returns the Projected Pnt / Dir in the parametrization range
// of mySphere.
// P is a point on a sphere with the same Position as Sp,
// but with a radius equal to 1. ( in order to avoid to divide
// by Radius)
// / X = cosV cosU U = Atan(Y/X)
// P = | Y = cosV sinU ==>
// \ Z = sinV V = ASin( Z)
//=======================================================================
static gp_Pnt2d EvalPnt2d( const gp_Vec P, const gp_Sphere& Sp)
{
Standard_Real X = P.Dot(gp_Vec(Sp.Position().XDirection()));
Standard_Real Y = P.Dot(gp_Vec(Sp.Position().YDirection()));
Standard_Real Z = P.Dot(gp_Vec(Sp.Position().Direction()));
Standard_Real U,V;
if ( Abs(X) > Precision::PConfusion() ||
Abs(Y) > Precision::PConfusion() ) {
Standard_Real UU = ATan2(Y,X);
U = ElCLib::InPeriod(UU, 0., 2*PI);
}
else {
U = 0.;
}
if ( Z > 1.)
Z = 1.;
else if ( Z < -1.)
Z = -1.;
V = ASin ( Z);
return gp_Pnt2d( U, V);
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Sphere::Project(const gp_Circ& C)
{
gp_Pnt O; // O Location of Sp;
gp_Dir Xc, Yc, Zc; // X Y Z Direction of C;
gp_Dir Xs, Ys, Zs; // X Y Z Direction of Sp;
//Check the validity :
// Xc & Yc must be perpendicular to Zs ->IsoV;
// O,Zs is in the Plane O,Xc,Yc; ->IsoU;
O = mySphere.Location();
Xc = C.Position().XDirection();
Yc = C.Position().YDirection();
Zc = Xc ^ Yc;
Xs = mySphere.Position().XDirection();
Ys = mySphere.Position().YDirection();
Zs = mySphere.Position().Direction();
Standard_Boolean isIsoU, isIsoV;
Standard_Real Tol = 1.e-8;
isIsoU = Zc.IsNormal(Zs,Tol) && O.IsEqual(C.Location(),Tol);
isIsoV = Xc.IsNormal(Zs,Tol) && Yc.IsNormal(Zs,Tol);
gp_Pnt2d P2d1, P2d2;
gp_Dir2d D2d;
if ( isIsoU) {
myType = GeomAbs_Line;
P2d1 = EvalPnt2d(gp_Vec(Xc),mySphere);
P2d2 = EvalPnt2d(gp_Vec(Yc),mySphere);
if (isIsoU && (Abs(P2d1.Y()-PI/2.) < Precision::PConfusion() ||
Abs(P2d1.Y()+PI/2.) < Precision::PConfusion() )) {
// then P1 is on the apex of the sphere and U is undefined
// The value of U is given by P2d2.Y() .
P2d1.SetX(P2d2.X());
}
else if ( Abs( Abs(P2d1.X()-P2d2.X()) - PI) < Precision::PConfusion()) {
// then we have U2 = U1 + PI; V2;
// we have to assume that U1 = U2
// so V2 = PI - V2;
P2d2.SetX( P2d1.X());
if (P2d2.Y() < 0.)
P2d2.SetY( -PI - P2d2.Y());
else
P2d2.SetY( PI - P2d2.Y());
}
else {
P2d2.SetX( P2d1.X());
}
D2d = gp_Dir2d(gp_Vec2d(P2d1,P2d2));
isDone = Standard_True;
}
else if ( isIsoV) {
myType = GeomAbs_Line;
//P2d(U,V) :first point of the PCurve.
Standard_Real U = Xs.AngleWithRef(Xc, Xs^Ys);
if (U<0)
U += 2*PI;
Standard_Real Z = gp_Vec(O,C.Location()).Dot(Zs);
Standard_Real V = ASin(Z/mySphere.Radius());
P2d1 = gp_Pnt2d(U,V);
D2d = gp_Dir2d((Xc^Yc).Dot(Xs^Ys) ,0.);
isDone = Standard_True;
}
myLin = gp_Lin2d(P2d1, D2d);
}
void ProjLib_Sphere::Project(const gp_Lin& L)
{
ProjLib_Projector::Project(L);
}
void ProjLib_Sphere::Project(const gp_Elips& E)
{
ProjLib_Projector::Project(E);
}
void ProjLib_Sphere::Project(const gp_Parab& P)
{
ProjLib_Projector::Project(P);
}
void ProjLib_Sphere::Project(const gp_Hypr& H)
{
ProjLib_Projector::Project(H);
}
//=======================================================================
//function : SetInBounds
//purpose :
//=======================================================================
void ProjLib_Sphere::SetInBounds(const Standard_Real U)
{
StdFail_NotDone_Raise_if( !isDone, "ProjLib_Sphere:SetInBounds");
// first set the y of the first point in -pi/2 pi/2
Standard_Real newY, Y = ElCLib::Value(U,myLin).Y();
newY = ElCLib::InPeriod( Y, -PI, PI);
myLin.Translate(gp_Vec2d(0.,newY-Y));
gp_Pnt2d P = ElCLib::Value(U,myLin);
gp_Trsf2d Trsf;
gp_Ax2d Axis;
Standard_Real Tol = 1.e-7;
gp_Dir2d D2d = myLin.Direction();
// Modified by skv - Tue Aug 1 16:29:59 2006 OCC13116 Begin
// if ((P.Y() > PI/2) ||
if ((P.Y() - PI/2 > Tol) ||
// Modified by skv - Tue Aug 1 16:29:59 2006 OCC13116 End
(Abs(P.Y()-PI/2)<Tol && D2d.IsEqual(gp::DY2d(),Tol))) {
Axis = gp_Ax2d( gp_Pnt2d( 0., PI/2.), gp::DX2d());
}
// Modified by skv - Tue Aug 1 16:29:59 2006 OCC13116 Begin
// else if ((P.Y() < -PI/2) ||
else if ((P.Y() + PI/2 < -Tol) ||
// Modified by skv - Tue Aug 1 16:29:59 2006 OCC13116 End
(Abs(P.Y()+PI/2)<Tol && D2d.IsOpposite(gp::DY2d(),Tol))) {
Axis = gp_Ax2d( gp_Pnt2d( 0., -PI/2.), gp::DX2d());
}
else
return;
Trsf.SetMirror(Axis);
myLin.Transform(Trsf);
myLin.Translate(gp_Vec2d(PI,0.));
// il faut maintenant recadrer en U
Standard_Real newX, X = ElCLib::Value(U,myLin).X();
newX = ElCLib::InPeriod( X, 0., 2.*PI);
myLin.Translate(gp_Vec2d(newX-X,0.));
}

71
src/ProjLib/ProjLib_Torus.cdl Executable file
View File

@@ -0,0 +1,71 @@
-- File: ProjLib_Torus.cdl
-- Created: Tue Aug 24 11:26:33 1993
-- Author: Bruno DUMORTIER
-- <dub@topsn3>
---Copyright: Matra Datavision 1993
class Torus from ProjLib inherits Projector from ProjLib
---Purpose: Projects elementary curves on a torus.
uses
CurveType from GeomAbs,
Torus from gp,
Lin from gp,
Circ from gp,
Elips from gp,
Parab from gp,
Hypr from gp,
Lin2d from gp,
Circ2d from gp,
Elips2d from gp,
Parab2d from gp,
Hypr2d from gp
raises
NoSuchObject from Standard
is
Create returns Torus from ProjLib;
---Purpose: Undefined projection.
Create(To : Torus from gp) returns Torus from ProjLib;
---Purpose: Projection on the torus <To>.
Create(To : Torus from gp;
C : Circ from gp) returns Torus from ProjLib;
---Purpose: Projection of the circle <C> on the torus <To>.
Init(me : in out;
To : Torus from gp)
is static;
Project(me : in out;
L : Lin from gp)
is redefined;
Project(me : in out;
C : Circ from gp)
is redefined;
Project(me : in out;
E : Elips from gp)
is redefined;
Project(me : in out;
P : Parab from gp)
is redefined;
Project(me : in out;
H : Hypr from gp)
is redefined;
fields
myTorus : Torus from gp;
end Torus;

198
src/ProjLib/ProjLib_Torus.cxx Executable file
View File

@@ -0,0 +1,198 @@
// File: ProjLib_Torus.cxx
// Created: Tue Aug 24 18:50:08 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
#include <ProjLib_Torus.ixx>
#include <Precision.hxx>
#include <gp.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
#include <gp_Dir2d.hxx>
#include <Precision.hxx>
//=======================================================================
//function : ProjLib_Torus
//purpose :
//=======================================================================
ProjLib_Torus::ProjLib_Torus()
{
}
//=======================================================================
//function : ProjLib_Torus
//purpose :
//=======================================================================
ProjLib_Torus::ProjLib_Torus(const gp_Torus& To)
{
Init(To);
}
//=======================================================================
//function : ProjLib_Torus
//purpose :
//=======================================================================
ProjLib_Torus::ProjLib_Torus(const gp_Torus& To, const gp_Circ& C)
{
Init(To);
Project(C);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void ProjLib_Torus::Init(const gp_Torus& To)
{
myType = GeomAbs_OtherCurve;
myTorus = To;
myIsPeriodic = Standard_False;
isDone = Standard_False;
}
//=======================================================================
//function : EvalPnt2d / EvalDir2d
//purpose : returns the Projected Pnt / Dir in the parametrization range
// of myPlane.
// P is a point on a torus with the same Position as To,
// but with a major an minor radius equal to 1.
// ( in order to avoid to divide by Radius)
// / X = (1+cosV)*cosU U = Atan(Y/X)
// P = | Y = (1+cosV)*sinU ==>
// \ Z = sinV V = ASin( Z)
//=======================================================================
static gp_Pnt2d EvalPnt2d( const gp_Vec& Ve, const gp_Torus& To)
{
Standard_Real X = Ve.Dot(gp_Vec(To.Position().XDirection()));
Standard_Real Y = Ve.Dot(gp_Vec(To.Position().YDirection()));
Standard_Real U,V;
if ( Abs(X) > Precision::PConfusion() ||
Abs(Y) > Precision::PConfusion() ) {
U = ATan2(Y,X);
}
else {
U = 0.;
}
V = 0.;
return gp_Pnt2d( U, V);
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void ProjLib_Torus::Project(const gp_Circ& C)
{
myType = GeomAbs_Line;
gp_Vec Xc( C.Position().XDirection());
gp_Vec Yc( C.Position().YDirection());
gp_Vec Xt( myTorus.Position().XDirection());
gp_Vec Yt( myTorus.Position().YDirection());
gp_Vec Zt( myTorus.Position().Direction());
gp_Vec OC( myTorus.Location(), C.Location());
// if (OC.Magnitude() < Precision::Confusion() ||
// OC.IsParallel(myTorus.Position().Direction(),
// Precision::Angular())) {
if (OC.Magnitude() < Precision::Confusion() ||
C.Position().Direction().IsParallel(myTorus.Position().Direction(),
Precision::Angular())) {
// Iso V
gp_Pnt2d P1 = EvalPnt2d( Xc, myTorus); // evaluate U1
gp_Pnt2d P2 = EvalPnt2d( Yc, myTorus); // evaluate U2
Standard_Real Z = OC.Dot(myTorus.Position().Direction());
Z /= myTorus.MinorRadius();
Standard_Real V;
if ( Z > 1.) {
V = PI/2.; // protection stupide
} // contre les erreurs de calcul
else if ( Z < -1.) { // il arrive que Z soit legerement
V = -PI/2; // superieur a 1.
}
else {
V = ASin(Z);
}
if (C.Radius() < myTorus.MajorRadius()) {
V = PI - V;
}
else if ( V < 0.) {
V += 2*PI;
}
P1.SetY(V);
P2.SetY(V);
gp_Vec2d V2d ( P1, P2);
// Normalement Abs( P1.X() - P2.X()) = PI/2
// Si != PI/2, on a traverse la periode => On reverse la Direction
if ( Abs( P1.X() - P2.X()) > PI) V2d.Reverse();
gp_Dir2d D2( V2d);
if ( P1.X() < 0)
P1.SetX( 2*PI + P1.X());
myLin = gp_Lin2d( P1, D2);
}
else {
// Iso U -> U = angle( Xt, OC)
Standard_Real U = Xt.AngleWithRef( OC, Xt^Yt);
if ( U < 0.)
U += 2*PI;
// Origine de la droite
Standard_Real V1 = OC.AngleWithRef(Xc, OC^Zt);
if ( V1 < 0.)
V1 += 2*PI;
gp_Pnt2d P1( U, V1);
// Direction de la droite
gp_Dir2d D2 = gp::DY2d();
if ( ((OC^Zt)*(Xc^Yc)) < 0.) {
D2.Reverse();
}
myLin = gp_Lin2d( P1, D2);
}
isDone = Standard_True;
}
void ProjLib_Torus::Project(const gp_Lin& L)
{
ProjLib_Projector::Project(L);
}
void ProjLib_Torus::Project(const gp_Elips& E)
{
ProjLib_Projector::Project(E);
}
void ProjLib_Torus::Project(const gp_Parab& P)
{
ProjLib_Projector::Project(P);
}
void ProjLib_Torus::Project(const gp_Hypr& H)
{
ProjLib_Projector::Project(H);
}