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:
136
src/GeomProjLib/GeomProjLib.cdl
Executable file
136
src/GeomProjLib/GeomProjLib.cdl
Executable file
@@ -0,0 +1,136 @@
|
||||
-- File: GeomProjLib.cdl
|
||||
-- Created: Wed Aug 25 18:35:56 1993
|
||||
-- Author: Bruno DUMORTIER
|
||||
-- <dub@topsn3>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
package GeomProjLib
|
||||
|
||||
---Purpose: Projection of a curve on a surface.
|
||||
|
||||
uses
|
||||
gp,
|
||||
Geom,
|
||||
Geom2d
|
||||
|
||||
is
|
||||
|
||||
--
|
||||
-- package methods
|
||||
--
|
||||
|
||||
|
||||
Curve2d(C : Curve from Geom;
|
||||
First, Last : Real from Standard;
|
||||
S : Surface from Geom;
|
||||
UFirst,ULast,
|
||||
VFirst,VLast: Real from Standard ;
|
||||
Tolerance : in out Real from Standard )
|
||||
---Purpose: gives the 2d-curve of a 3d-curve lying on a
|
||||
-- surface ( uses GeomProjLib_ProjectedCurve )
|
||||
-- The 3dCurve is taken between the parametrization
|
||||
-- range [First, Last]
|
||||
-- <Tolerance> is used as input if the projection needs
|
||||
-- an approximation. In this case, the reached
|
||||
-- tolerance is set in <Tolerance> as output.
|
||||
-- WARNING : if the projection has failed, this
|
||||
-- method returns a null Handle.
|
||||
returns Curve from Geom2d;
|
||||
|
||||
Curve2d(C : Curve from Geom;
|
||||
First, Last : Real from Standard;
|
||||
S : Surface from Geom;
|
||||
Tolerance : in out Real from Standard )
|
||||
---Purpose: gives the 2d-curve of a 3d-curve lying on a
|
||||
-- surface ( uses GeomProjLib_ProjectedCurve )
|
||||
-- The 3dCurve is taken between the parametrization
|
||||
-- range [First, Last]
|
||||
-- <Tolerance> is used as input if the projection needs
|
||||
-- an approximation. In this case, the reached
|
||||
-- tolerance is set in <Tolerance> as output.
|
||||
-- WARNING : if the projection has failed, this
|
||||
-- method returns a null Handle.
|
||||
returns Curve from Geom2d;
|
||||
|
||||
Curve2d(C : Curve from Geom;
|
||||
First, Last : Real from Standard;
|
||||
S : Surface from Geom)
|
||||
---Purpose: gives the 2d-curve of a 3d-curve lying on a
|
||||
-- surface ( uses GeomProjLib_ProjectedCurve )
|
||||
-- The 3dCurve is taken between the parametrization
|
||||
-- range [First, Last]
|
||||
-- If the projection needs an approximation,
|
||||
-- Precision::PApproximation() is used.
|
||||
-- WARNING : if the projection has failed, this
|
||||
-- method returns a null Handle.
|
||||
returns Curve from Geom2d;
|
||||
|
||||
Curve2d(C : Curve from Geom;
|
||||
S : Surface from Geom )
|
||||
---Purpose: gives the 2d-curve of a 3d-curve lying on a
|
||||
-- surface ( uses GeomProjLib_ProjectedCurve ).
|
||||
-- If the projection needs an approximation,
|
||||
-- Precision::PApproximation() is used.
|
||||
-- WARNING : if the projection has failed, this
|
||||
-- method returns a null Handle.
|
||||
returns Curve from Geom2d;
|
||||
|
||||
Curve2d(C : Curve from Geom;
|
||||
S : Surface from Geom ;
|
||||
UDeb : Real from Standard ;
|
||||
UFin : Real from Standard ;
|
||||
VDeb : Real from Standard ;
|
||||
VFin : Real from Standard)
|
||||
|
||||
---Purpose: gives the 2d-curve of a 3d-curve lying on a
|
||||
-- surface ( uses GeomProjLib_ProjectedCurve ).
|
||||
-- If the projection needs an approximation,
|
||||
-- Precision::PApproximation() is used.
|
||||
-- WARNING : if the projection has failed, this
|
||||
-- method returns a null Handle.
|
||||
-- can expand a little the bounds of surface
|
||||
returns Curve from Geom2d;
|
||||
|
||||
Curve2d(C : Curve from Geom;
|
||||
S : Surface from Geom;
|
||||
UDeb : Real from Standard ;
|
||||
UFin : Real from Standard ;
|
||||
VDeb : Real from Standard ;
|
||||
VFin : Real from Standard ;
|
||||
Tolerance : in out Real from Standard )
|
||||
|
||||
---Purpose: gives the 2d-curve of a 3d-curve lying on a
|
||||
-- surface ( uses GeomProjLib_ProjectedCurve ).
|
||||
-- If the projection needs an approximation,
|
||||
-- Precision::PApproximation() is used.
|
||||
-- WARNING : if the projection has failed, this
|
||||
-- method returns a null Handle.
|
||||
-- can expand a little the bounds of surface
|
||||
returns Curve from Geom2d;
|
||||
|
||||
|
||||
Project(C : Curve from Geom;
|
||||
S : Surface from Geom )
|
||||
---Purpose: Constructs the 3d-curve from the normal
|
||||
-- projection of the Curve <C> on the surface <S>.
|
||||
-- WARNING : if the projection has failes returns a
|
||||
-- null Handle.
|
||||
returns Curve from Geom;
|
||||
|
||||
|
||||
ProjectOnPlane(Curve : Curve from Geom;
|
||||
Plane : Plane from Geom;
|
||||
Dir : Dir from gp ;
|
||||
KeepParametrization : Boolean from Standard)
|
||||
---Purpose: Constructs the 3d-curves from the projection
|
||||
-- of the curve <Curve> on the plane <Plane> along
|
||||
-- the direction <Dir>.
|
||||
-- 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.
|
||||
returns Curve from Geom;
|
||||
|
||||
end GeomProjLib;
|
412
src/GeomProjLib/GeomProjLib.cxx
Executable file
412
src/GeomProjLib/GeomProjLib.cxx
Executable file
@@ -0,0 +1,412 @@
|
||||
// File: GeomProjLib.cxx
|
||||
// Created: Wed Sep 21 10:38:50 1994
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@fuegox>
|
||||
|
||||
// Modified by skv - Wed Aug 11 17:26:03 2004 OCC6272
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <GeomProjLib.ixx>
|
||||
|
||||
#include <ProjLib_ProjectedCurve.hxx>
|
||||
#include <ProjLib_CompProjectedCurve.hxx>
|
||||
#include <ProjLib_ProjectOnPlane.hxx>
|
||||
#include <ProjLib_ProjectOnSurface.hxx>
|
||||
|
||||
#include <Approx_CurveOnSurface.hxx>
|
||||
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <GeomAdaptor_Surface.hxx>
|
||||
#include <GeomAdaptor_HCurve.hxx>
|
||||
#include <GeomAdaptor_HSurface.hxx>
|
||||
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Ellipse.hxx>
|
||||
#include <Geom_Parabola.hxx>
|
||||
#include <Geom_Hyperbola.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Geom2d_Circle.hxx>
|
||||
#include <Geom2d_Ellipse.hxx>
|
||||
#include <Geom2d_Parabola.hxx>
|
||||
#include <Geom2d_Hyperbola.hxx>
|
||||
#include <Geom2d_BezierCurve.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
|
||||
#include <gp_Pln.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
|
||||
#ifdef DRAW
|
||||
#include <DrawTrSurf.hxx>
|
||||
#endif
|
||||
#ifdef DEB
|
||||
static Standard_Boolean Affich = Standard_False;
|
||||
static Standard_Integer NBPROJ = 1;
|
||||
#endif
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Curve) GeomProjLib::Curve2d(const Handle(Geom_Curve)& C,
|
||||
const Standard_Real First,
|
||||
const Standard_Real Last,
|
||||
const Handle(Geom_Surface)& S,
|
||||
const Standard_Real UDeb,
|
||||
const Standard_Real UFin,
|
||||
const Standard_Real VDeb,
|
||||
const Standard_Real VFin,
|
||||
Standard_Real& Tolerance)
|
||||
{
|
||||
#ifdef DRAW
|
||||
if ( Affich) {
|
||||
//POP pour NT
|
||||
// char name[100];
|
||||
char* name = new char[100];
|
||||
sprintf(name,"PROJCURV_%d",NBPROJ);
|
||||
DrawTrSurf::Set(name,C);
|
||||
sprintf(name,"PROJSURF_%d",NBPROJ);
|
||||
DrawTrSurf::Set(name,S);
|
||||
NBPROJ++;
|
||||
}
|
||||
#endif
|
||||
|
||||
Tolerance = Max(Precision::PConfusion(),Tolerance);
|
||||
|
||||
GeomAdaptor_Curve AC(C,First,Last);
|
||||
GeomAdaptor_Surface AS(S,
|
||||
UDeb,
|
||||
UFin,
|
||||
VDeb,
|
||||
VFin);
|
||||
|
||||
Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(AS);
|
||||
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(AC);
|
||||
|
||||
ProjLib_ProjectedCurve Proj(HS,HC,Tolerance);
|
||||
|
||||
Handle(Geom2d_Curve) G2dC;
|
||||
|
||||
switch ( Proj.GetType()) {
|
||||
|
||||
case GeomAbs_Line:
|
||||
G2dC = new Geom2d_Line(Proj.Line());
|
||||
break;
|
||||
|
||||
case GeomAbs_Circle:
|
||||
G2dC = new Geom2d_Circle(Proj.Circle());
|
||||
break;
|
||||
|
||||
case GeomAbs_Ellipse:
|
||||
G2dC = new Geom2d_Ellipse(Proj.Ellipse());
|
||||
break;
|
||||
|
||||
case GeomAbs_Parabola:
|
||||
G2dC = new Geom2d_Parabola(Proj.Parabola());
|
||||
break;
|
||||
|
||||
case GeomAbs_Hyperbola:
|
||||
G2dC = new Geom2d_Hyperbola(Proj.Hyperbola());
|
||||
break;
|
||||
|
||||
case GeomAbs_BezierCurve:
|
||||
G2dC = Proj.Bezier();
|
||||
break;
|
||||
|
||||
case GeomAbs_BSplineCurve:
|
||||
G2dC = Proj.BSpline();
|
||||
break;
|
||||
|
||||
default:
|
||||
return G2dC;
|
||||
|
||||
}
|
||||
|
||||
if(G2dC.IsNull()) {
|
||||
Tolerance = Proj.GetTolerance();
|
||||
return G2dC;
|
||||
}
|
||||
|
||||
if ( C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)) ) {
|
||||
Handle(Geom_TrimmedCurve) CTrim = Handle(Geom_TrimmedCurve)::DownCast(C);
|
||||
Standard_Real U1 = CTrim->FirstParameter();
|
||||
Standard_Real U2 = CTrim->LastParameter();
|
||||
G2dC = new Geom2d_TrimmedCurve( G2dC, U1, U2);
|
||||
}
|
||||
|
||||
#ifdef DRAW
|
||||
if ( Affich) {
|
||||
static Standard_CString aprojcurv = "projcurv" ;
|
||||
DrawTrSurf::Set(aprojcurv,G2dC);
|
||||
}
|
||||
#endif
|
||||
Tolerance = Proj.GetTolerance();
|
||||
return G2dC;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Curve) GeomProjLib::Curve2d(const Handle(Geom_Curve)& C,
|
||||
const Standard_Real First,
|
||||
const Standard_Real Last,
|
||||
const Handle(Geom_Surface)& S,
|
||||
Standard_Real& Tolerance)
|
||||
{
|
||||
Standard_Real UFirst,
|
||||
ULast,
|
||||
VFirst,
|
||||
VLast ;
|
||||
|
||||
S->Bounds(UFirst,
|
||||
ULast,
|
||||
VFirst,
|
||||
VLast) ;
|
||||
return Curve2d(C,
|
||||
First,
|
||||
Last,
|
||||
S,
|
||||
UFirst,
|
||||
ULast,
|
||||
VFirst,
|
||||
VLast,
|
||||
Tolerance) ;
|
||||
}
|
||||
// Modified by skv - Wed Aug 11 17:26:03 2004 OCC6272 Begin
|
||||
// Add not implemented method.
|
||||
//=======================================================================
|
||||
//function : Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Curve) GeomProjLib::Curve2d( const Handle(Geom_Curve)& C,
|
||||
const Handle(Geom_Surface)& S,
|
||||
const Standard_Real UDeb,
|
||||
const Standard_Real UFin,
|
||||
const Standard_Real VDeb,
|
||||
const Standard_Real VFin)
|
||||
{
|
||||
Standard_Real First = C->FirstParameter();
|
||||
Standard_Real Last = C->LastParameter();
|
||||
Standard_Real Tol = Precision::PConfusion();
|
||||
return GeomProjLib::Curve2d(C,First,Last,S,UDeb,UFin,VDeb,VFin,Tol);
|
||||
}
|
||||
// Modified by skv - Wed Aug 11 17:26:03 2004 OCC6272 End
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Curve) GeomProjLib::Curve2d( const Handle(Geom_Curve)& C,
|
||||
const Handle(Geom_Surface)& S,
|
||||
const Standard_Real UDeb,
|
||||
const Standard_Real UFin,
|
||||
const Standard_Real VDeb,
|
||||
const Standard_Real VFin,
|
||||
Standard_Real& Tolerance)
|
||||
{
|
||||
Standard_Real First = C->FirstParameter();
|
||||
Standard_Real Last = C->LastParameter();
|
||||
return GeomProjLib::Curve2d(C,First,Last,S,UDeb,UFin,VDeb,VFin,Tolerance);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Curve) GeomProjLib::Curve2d( const Handle(Geom_Curve)& C,
|
||||
const Handle(Geom_Surface)& S)
|
||||
{
|
||||
Standard_Real First = C->FirstParameter();
|
||||
Standard_Real Last = C->LastParameter();
|
||||
Standard_Real Tol = Precision::PConfusion();
|
||||
return GeomProjLib::Curve2d(C,First,Last,S,Tol);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Curve) GeomProjLib::Curve2d( const Handle(Geom_Curve)& C,
|
||||
const Standard_Real First,
|
||||
const Standard_Real Last,
|
||||
const Handle(Geom_Surface)& S)
|
||||
{
|
||||
Standard_Real Tol = Precision::PConfusion();
|
||||
return GeomProjLib::Curve2d(C,First,Last,S,Tol);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Curve) GeomProjLib::Project( const Handle(Geom_Curve)& C,
|
||||
const Handle(Geom_Surface)& S)
|
||||
{
|
||||
GeomAdaptor_Curve AC(C);
|
||||
GeomAdaptor_Surface AS(S);
|
||||
|
||||
Handle(Geom_Curve) GC;
|
||||
|
||||
if ( AS.GetType() == GeomAbs_Plane) {
|
||||
ProjLib_ProjectOnPlane Proj( AS.Plane().Position());
|
||||
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(AC);
|
||||
Proj.Load(HC,Precision::PApproximation());
|
||||
|
||||
switch ( Proj.GetType()) {
|
||||
case GeomAbs_Line:
|
||||
GC = new Geom_Line(Proj.Line());
|
||||
break;
|
||||
|
||||
case GeomAbs_Circle:
|
||||
GC = new Geom_Circle(Proj.Circle());
|
||||
break;
|
||||
|
||||
case GeomAbs_Ellipse:
|
||||
GC = new Geom_Ellipse(Proj.Ellipse());
|
||||
break;
|
||||
|
||||
case GeomAbs_Parabola:
|
||||
GC = new Geom_Parabola(Proj.Parabola());
|
||||
break;
|
||||
|
||||
case GeomAbs_Hyperbola:
|
||||
GC = new Geom_Hyperbola(Proj.Hyperbola());
|
||||
break;
|
||||
|
||||
case GeomAbs_BezierCurve:
|
||||
GC = Proj.Bezier();
|
||||
break;
|
||||
|
||||
case GeomAbs_BSplineCurve:
|
||||
GC = Proj.BSpline();
|
||||
break;
|
||||
|
||||
default:
|
||||
return GC;
|
||||
|
||||
}
|
||||
|
||||
if ( C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||
Handle(Geom_TrimmedCurve) CTrim = Handle(Geom_TrimmedCurve)::DownCast(C);
|
||||
Standard_Real U1 = CTrim->FirstParameter();
|
||||
Standard_Real U2 = CTrim->LastParameter();
|
||||
GC = new Geom_TrimmedCurve( GC, U1, U2);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(AS);
|
||||
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(AC);
|
||||
// Standard_Real Tol = Precision::Approximation();
|
||||
// Standard_Real TolU = Precision::PApproximation();
|
||||
// Standard_Real TolV = Precision::PApproximation();
|
||||
Standard_Real Tol = 0.0001;
|
||||
Standard_Real TolU = Pow(Tol, 2./3);
|
||||
Standard_Real TolV = Pow(Tol, 2./3);
|
||||
ProjLib_CompProjectedCurve Proj(HS,HC,TolU,TolV,-1.);
|
||||
|
||||
#ifdef DEB
|
||||
Standard_Integer NbCurves = Proj.NbCurves();
|
||||
#else
|
||||
Proj.NbCurves();
|
||||
#endif
|
||||
Standard_Real f,l;
|
||||
Proj.Bounds(1,f,l);
|
||||
Handle(Adaptor2d_HCurve2d) HC2d = Proj.Trim(f,l,TolU);
|
||||
Approx_CurveOnSurface Approx(HC2d, HS, f, l, Tol,
|
||||
GeomAbs_C2,14,16,Standard_True);
|
||||
|
||||
// ici, on a toujours un type BSpline.
|
||||
if (Approx.IsDone() && Approx.HasResult())
|
||||
GC = Approx.Curve3d();
|
||||
}
|
||||
|
||||
return GC;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ProjectOnPlane
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Curve) GeomProjLib::ProjectOnPlane
|
||||
(const Handle(Geom_Curve)& Curve,
|
||||
const Handle(Geom_Plane)& Plane,
|
||||
const gp_Dir& Dir,
|
||||
const Standard_Boolean KeepParametrization)
|
||||
{
|
||||
GeomAdaptor_Curve AC(Curve);
|
||||
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(AC);
|
||||
|
||||
ProjLib_ProjectOnPlane Proj(Plane->Position(), Dir);
|
||||
Proj.Load(HC,Precision::Approximation(), KeepParametrization);
|
||||
|
||||
Handle(Geom_Curve) GC;
|
||||
|
||||
switch ( Proj.GetType()) {
|
||||
case GeomAbs_Line:
|
||||
GC = new Geom_Line(Proj.Line());
|
||||
break;
|
||||
|
||||
case GeomAbs_Circle:
|
||||
GC = new Geom_Circle(Proj.Circle());
|
||||
break;
|
||||
|
||||
case GeomAbs_Ellipse:
|
||||
GC = new Geom_Ellipse(Proj.Ellipse());
|
||||
break;
|
||||
|
||||
case GeomAbs_Parabola:
|
||||
GC = new Geom_Parabola(Proj.Parabola());
|
||||
break;
|
||||
|
||||
case GeomAbs_Hyperbola:
|
||||
GC = new Geom_Hyperbola(Proj.Hyperbola());
|
||||
break;
|
||||
|
||||
case GeomAbs_BezierCurve:
|
||||
GC = Proj.Bezier();
|
||||
break;
|
||||
|
||||
case GeomAbs_BSplineCurve:
|
||||
GC = Proj.BSpline();
|
||||
break;
|
||||
default:
|
||||
return GC;
|
||||
|
||||
}
|
||||
|
||||
if ( Curve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)) ) {
|
||||
Handle(Geom_TrimmedCurve) CTrim
|
||||
= Handle(Geom_TrimmedCurve)::DownCast(Curve);
|
||||
GC = new Geom_TrimmedCurve( GC, Proj.FirstParameter(),
|
||||
Proj.LastParameter());
|
||||
}
|
||||
|
||||
return GC;
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user