mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
77
src/GeomTools/GeomTools.cdl
Executable file
77
src/GeomTools/GeomTools.cdl
Executable file
@@ -0,0 +1,77 @@
|
||||
-- File: GeomTools.cdl
|
||||
-- Created: Fri Aug 28 18:54:27 1992
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@phylox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
package GeomTools
|
||||
|
||||
---Purpose: The GeomTools package provides utilities for Geometry.
|
||||
--
|
||||
-- * SurfaceSet, CurveSet, Curve2dSet : Tools used
|
||||
-- for dumping, writing and reading.
|
||||
--
|
||||
-- * Methods to dump, write, read curves and surfaces.
|
||||
|
||||
uses
|
||||
Geom,
|
||||
Geom2d,
|
||||
TColStd,
|
||||
Message
|
||||
|
||||
is
|
||||
|
||||
class UndefinedTypeHandler;
|
||||
--
|
||||
-- Dump, Write, Read tools
|
||||
|
||||
class SurfaceSet;
|
||||
---Purpose: A set of Surfaces from Geom.
|
||||
|
||||
class CurveSet;
|
||||
---Purpose: A set of Curves from Geom.
|
||||
|
||||
class Curve2dSet;
|
||||
---Purpose: A set of Curves from Geom2d.
|
||||
|
||||
--
|
||||
-- Methods
|
||||
--
|
||||
|
||||
Dump(S : Surface from Geom; OS : in out OStream);
|
||||
---Purpose: Dumps the surface on the stream.
|
||||
|
||||
Write(S : Surface from Geom; OS : in out OStream);
|
||||
---Purpose: Writes the surface on the stream.
|
||||
|
||||
Read(S : in out Surface from Geom; IS : in out IStream);
|
||||
---Purpose: Reads the surface from the stream.
|
||||
|
||||
|
||||
Dump(C : Curve from Geom; OS : in out OStream);
|
||||
---Purpose: Dumps the Curve on the stream.
|
||||
|
||||
Write(C : Curve from Geom; OS : in out OStream);
|
||||
---Purpose: Writes the Curve on the stream.
|
||||
|
||||
Read(C : in out Curve from Geom; IS : in out IStream);
|
||||
---Purpose: Reads the Curve from the stream.
|
||||
|
||||
|
||||
Dump(C : Curve from Geom2d; OS : in out OStream);
|
||||
---Purpose: Dumps the Curve on the stream.
|
||||
|
||||
Write(C : Curve from Geom2d; OS : in out OStream);
|
||||
---Purpose: Writes the Curve on the stream.
|
||||
|
||||
Read(C : in out Curve from Geom2d; IS : in out IStream);
|
||||
---Purpose: Reads the Curve from the stream.
|
||||
|
||||
SetUndefinedTypeHandler(aHandler: UndefinedTypeHandler from GeomTools);
|
||||
|
||||
GetUndefinedTypeHandler returns UndefinedTypeHandler from GeomTools;
|
||||
|
||||
end GeomTools;
|
||||
|
||||
|
79
src/GeomTools/GeomTools.cxx
Executable file
79
src/GeomTools/GeomTools.cxx
Executable file
@@ -0,0 +1,79 @@
|
||||
// File: GeomTools.cxx
|
||||
// Created: Thu Jan 21 19:59:19 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@phylox>
|
||||
|
||||
#include <GeomTools.ixx>
|
||||
|
||||
#include <GeomTools_SurfaceSet.hxx>
|
||||
#include <GeomTools_CurveSet.hxx>
|
||||
#include <GeomTools_Curve2dSet.hxx>
|
||||
#include <GeomTools_UndefinedTypeHandler.hxx>
|
||||
|
||||
static Handle(GeomTools_UndefinedTypeHandler) theActiveHandler = new GeomTools_UndefinedTypeHandler;
|
||||
|
||||
void GeomTools::Dump(const Handle(Geom_Surface)& S, Standard_OStream& OS)
|
||||
{
|
||||
GeomTools_SurfaceSet::PrintSurface(S,OS);
|
||||
}
|
||||
|
||||
void GeomTools::Write(const Handle(Geom_Surface)& S, Standard_OStream& OS)
|
||||
{
|
||||
GeomTools_SurfaceSet::PrintSurface(S,OS,Standard_True);
|
||||
}
|
||||
|
||||
void GeomTools::Read(Handle(Geom_Surface)& S, Standard_IStream& IS)
|
||||
{
|
||||
GeomTools_SurfaceSet::ReadSurface(IS,S);
|
||||
}
|
||||
|
||||
void GeomTools::Dump(const Handle(Geom_Curve)& C, Standard_OStream& OS)
|
||||
{
|
||||
GeomTools_CurveSet::PrintCurve(C,OS);
|
||||
}
|
||||
|
||||
void GeomTools::Write(const Handle(Geom_Curve)& C, Standard_OStream& OS)
|
||||
{
|
||||
GeomTools_CurveSet::PrintCurve(C,OS,Standard_True);
|
||||
}
|
||||
|
||||
void GeomTools::Read(Handle(Geom_Curve)& C, Standard_IStream& IS)
|
||||
{
|
||||
GeomTools_CurveSet::ReadCurve(IS,C);
|
||||
}
|
||||
|
||||
void GeomTools::Dump(const Handle(Geom2d_Curve)& C, Standard_OStream& OS)
|
||||
{
|
||||
GeomTools_Curve2dSet::PrintCurve2d(C,OS);
|
||||
}
|
||||
|
||||
void GeomTools::Write(const Handle(Geom2d_Curve)& C, Standard_OStream& OS)
|
||||
{
|
||||
GeomTools_Curve2dSet::PrintCurve2d(C,OS,Standard_True);
|
||||
}
|
||||
|
||||
void GeomTools::Read(Handle(Geom2d_Curve)& C, Standard_IStream& IS)
|
||||
{
|
||||
GeomTools_Curve2dSet::ReadCurve2d(IS,C);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetUndefinedTypeHandler
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools::SetUndefinedTypeHandler(const Handle(GeomTools_UndefinedTypeHandler)& aHandler)
|
||||
{
|
||||
if(!aHandler.IsNull())
|
||||
theActiveHandler = aHandler;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetUndefinedTypeHandler
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(GeomTools_UndefinedTypeHandler) GeomTools::GetUndefinedTypeHandler()
|
||||
{
|
||||
return theActiveHandler;
|
||||
}
|
90
src/GeomTools/GeomTools_Curve2dSet.cdl
Executable file
90
src/GeomTools/GeomTools_Curve2dSet.cdl
Executable file
@@ -0,0 +1,90 @@
|
||||
-- File: GeomTools_Curve2dSet.cdl
|
||||
-- Created: Mon Jul 19 15:27:18 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@nonox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class Curve2dSet from GeomTools
|
||||
|
||||
---Purpose: Stores a set of Curves from Geom2d.
|
||||
|
||||
uses
|
||||
Curve from Geom2d,
|
||||
IndexedMapOfTransient from TColStd,
|
||||
ProgressIndicator from Message
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
Create returns Curve2dSet from GeomTools;
|
||||
---Purpose: Returns an empty set of Curves.
|
||||
|
||||
Clear(me : in out)
|
||||
---Purpose: Clears the content of the set.
|
||||
is static;
|
||||
|
||||
Add(me : in out; C : Curve from Geom2d) returns Integer
|
||||
---Purpose: Incorporate a new Curve in the set and returns
|
||||
-- its index.
|
||||
is static;
|
||||
|
||||
Curve2d(me; I : Integer) returns Curve from Geom2d
|
||||
---Purpose: Returns the Curve of index <I>.
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
is static;
|
||||
|
||||
Index(me; C : Curve from Geom2d) returns Integer
|
||||
---Purpose: Returns the index of <L>.
|
||||
is static;
|
||||
|
||||
Dump(me; OS : in out OStream)
|
||||
---Purpose: Dumps the content of me on the stream <OS>.
|
||||
is static;
|
||||
|
||||
Write(me; OS : in out OStream)
|
||||
---Purpose: Writes the content of me on the stream <OS> in a
|
||||
-- format that can be read back by Read.
|
||||
is static;
|
||||
|
||||
Read(me : in out; IS : in out IStream)
|
||||
---Purpose: Reads the content of me from the stream <IS>. me
|
||||
-- is first cleared.
|
||||
--
|
||||
is static;
|
||||
|
||||
--
|
||||
-- class methods to write an read curves
|
||||
--
|
||||
|
||||
PrintCurve2d(myclass; C : Curve from Geom2d;
|
||||
OS : in out OStream;
|
||||
compact : Boolean = Standard_False);
|
||||
---Purpose: Dumps the curve on the stream, if compact is True
|
||||
-- use the compact format that can be read back.
|
||||
|
||||
ReadCurve2d(myclass; IS : in out IStream;
|
||||
C : in out Curve from Geom2d)
|
||||
returns IStream;
|
||||
---Purpose: Reads the curve from the stream. The curve is
|
||||
-- assumed to have been writtent with the Print
|
||||
-- method (compact = True).
|
||||
--
|
||||
---C++: return &
|
||||
|
||||
SetProgress(me : in out; PR : ProgressIndicator from Message);
|
||||
|
||||
GetProgress(me) returns ProgressIndicator from Message;
|
||||
|
||||
fields
|
||||
|
||||
myMap : IndexedMapOfTransient from TColStd;
|
||||
myProgress : ProgressIndicator from Message;
|
||||
|
||||
end Curve2dSet;
|
||||
|
||||
|
873
src/GeomTools/GeomTools_Curve2dSet.cxx
Executable file
873
src/GeomTools/GeomTools_Curve2dSet.cxx
Executable file
@@ -0,0 +1,873 @@
|
||||
// File: GeomTools_Curve2dSet.cxx
|
||||
// Created: Mon Jul 19 16:58:19 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@nonox>
|
||||
|
||||
#include <Standard_Stream.hxx>
|
||||
#include <GeomTools_Curve2dSet.ixx>
|
||||
#include <GeomTools.hxx>
|
||||
#include <GeomTools_UndefinedTypeHandler.hxx>
|
||||
|
||||
#include <Geom2d_Circle.hxx>
|
||||
#include <Geom2d_Line.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 <Geom2d_OffsetCurve.hxx>
|
||||
|
||||
#include <gp_Lin2d.hxx>
|
||||
#include <gp_Circ2d.hxx>
|
||||
#include <gp_Elips2d.hxx>
|
||||
#include <gp_Parab2d.hxx>
|
||||
#include <gp_Hypr2d.hxx>
|
||||
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Message_ProgressSentry.hxx>
|
||||
|
||||
#define LINE 1
|
||||
#define CIRCLE 2
|
||||
#define ELLIPSE 3
|
||||
#define PARABOLA 4
|
||||
#define HYPERBOLA 5
|
||||
#define BEZIER 6
|
||||
#define BSPLINE 7
|
||||
#define TRIMMED 8
|
||||
#define OFFSET 9
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GeomTools_Curve2dSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
GeomTools_Curve2dSet::GeomTools_Curve2dSet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_Curve2dSet::Clear()
|
||||
{
|
||||
myMap.Clear();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer GeomTools_Curve2dSet::Add(const Handle(Geom2d_Curve)& S)
|
||||
{
|
||||
return myMap.Add(S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Curve) GeomTools_Curve2dSet::Curve2d
|
||||
(const Standard_Integer I)const
|
||||
{
|
||||
if (I <= 0 || I > myMap.Extent())
|
||||
return Handle(Geom2d_Curve)();
|
||||
|
||||
return Handle(Geom2d_Curve)::DownCast(myMap(I));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Index
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer GeomTools_Curve2dSet::Index
|
||||
(const Handle(Geom2d_Curve)& S)const
|
||||
{
|
||||
return myMap.FindIndex(S);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const gp_Pnt2d P,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
OS << P.X();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << P.Y();
|
||||
OS << " ";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const gp_Dir2d D,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
OS << D.X();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << D.Y();
|
||||
OS << " ";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom2d_Line)& L,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << LINE << " ";
|
||||
else
|
||||
OS << "Line";
|
||||
|
||||
gp_Lin2d C2d = L->Lin2d();
|
||||
if (!compact) OS << "\n Origin :";
|
||||
Print(C2d.Location(),OS,compact);
|
||||
if (!compact) OS << "\n Axis :";
|
||||
Print(C2d.Direction(),OS,compact);
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom2d_Circle)& C,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << CIRCLE << " ";
|
||||
else
|
||||
OS << "Circle";
|
||||
|
||||
gp_Circ2d C2d = C->Circ2d();
|
||||
if (!compact) OS << "\n Center :";
|
||||
Print(C2d.Location(),OS,compact);
|
||||
if (!compact) OS << "\n XAxis :";
|
||||
Print(C2d.XAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n YAxis :";
|
||||
Print(C2d.YAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n Radius :";
|
||||
OS << C2d.Radius();
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom2d_Ellipse)& E,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << ELLIPSE << " ";
|
||||
else
|
||||
OS << "Ellipse";
|
||||
|
||||
gp_Elips2d C2d = E->Elips2d();
|
||||
if (!compact) OS << "\n Center :";
|
||||
Print(C2d.Location(),OS,compact);
|
||||
if (!compact) OS << "\n XAxis :";
|
||||
Print(C2d.XAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n YAxis :";
|
||||
Print(C2d.YAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n Radii :";
|
||||
OS << C2d.MajorRadius();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << C2d.MinorRadius();
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom2d_Parabola)& P,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << PARABOLA << " ";
|
||||
else
|
||||
OS << "Parabola";
|
||||
|
||||
gp_Parab2d C2d = P->Parab2d();
|
||||
if (!compact) OS << "\n Center :";
|
||||
Print(C2d.Location(),OS,compact);
|
||||
if (!compact) OS << "\n XAxis :";
|
||||
Print(C2d.Axis().XAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n YAxis :";
|
||||
Print(C2d.Axis().YAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n Focal :";
|
||||
OS << C2d.Focal();
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom2d_Hyperbola)& H,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << HYPERBOLA << " ";
|
||||
else
|
||||
OS << "Hyperbola";
|
||||
|
||||
gp_Hypr2d C2d = H->Hypr2d();
|
||||
if (!compact) OS << "\n Center :";
|
||||
Print(C2d.Location(),OS,compact);
|
||||
if (!compact) OS << "\n XAxis :";
|
||||
Print(C2d.XAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n YAxis :";
|
||||
Print(C2d.YAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n Radii :";
|
||||
OS << C2d.MajorRadius();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << C2d.MinorRadius();
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom2d_BezierCurve)& B,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << BEZIER << " ";
|
||||
else
|
||||
OS << "BezierCurve";
|
||||
|
||||
Standard_Boolean rational = B->IsRational();
|
||||
if (compact)
|
||||
OS << (rational ? 1 : 0) << " ";
|
||||
else {
|
||||
if (rational)
|
||||
OS << " rational";
|
||||
}
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i,degree = B->Degree();
|
||||
if (!compact) OS << "\n Degree :";
|
||||
OS << degree << " ";
|
||||
|
||||
for (i = 1; i <= degree+1; i++) {
|
||||
if (!compact) OS << "\n "<<setw(2)<<i<<" : ";
|
||||
Print(B->Pole(i),OS,compact);
|
||||
if (rational)
|
||||
OS << " " << B->Weight(i);
|
||||
if (compact)
|
||||
OS << " ";
|
||||
}
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom2d_BSplineCurve)& B,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << BSPLINE << " ";
|
||||
else
|
||||
OS << "BSplineCurve";
|
||||
|
||||
|
||||
Standard_Boolean rational = B->IsRational();
|
||||
if (compact)
|
||||
OS << (rational ? 1 : 0) << " ";
|
||||
else {
|
||||
if (rational)
|
||||
OS << " rational";
|
||||
}
|
||||
|
||||
Standard_Boolean periodic = B->IsPeriodic();
|
||||
if (compact)
|
||||
OS << (periodic ? 1 : 0) << " ";
|
||||
else {
|
||||
if (periodic)
|
||||
OS << " periodic";
|
||||
}
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i,degree,nbpoles,nbknots;
|
||||
degree = B->Degree();
|
||||
nbpoles = B->NbPoles();
|
||||
nbknots = B->NbKnots();
|
||||
if (!compact) OS << "\n Degree ";
|
||||
else OS << " ";
|
||||
OS << degree;
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << nbpoles;
|
||||
if (!compact) OS << " Poles,";
|
||||
OS << " ";
|
||||
OS << nbknots << " ";
|
||||
if (!compact) OS << " Knots";
|
||||
|
||||
if (!compact) OS << "Poles :\n";
|
||||
for (i = 1; i <= nbpoles; i++) {
|
||||
if (!compact) OS << "\n "<<setw(2)<<i<<" : ";
|
||||
else OS << " ";
|
||||
Print(B->Pole(i),OS,compact);
|
||||
if (rational)
|
||||
OS << " " << B->Weight(i);
|
||||
}
|
||||
OS << "\n";
|
||||
|
||||
if (!compact) OS << "Knots :\n";
|
||||
for (i = 1; i <= nbknots; i++) {
|
||||
if (!compact) OS << "\n "<<setw(2)<<i<<" : ";
|
||||
else OS << " ";
|
||||
OS << B->Knot(i) << " " << B->Multiplicity(i);
|
||||
}
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom2d_TrimmedCurve)& C,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << TRIMMED << " ";
|
||||
else
|
||||
OS << "Trimmed curve\n";
|
||||
if (!compact) OS << "Parameters : ";
|
||||
OS << C->FirstParameter() << " " << C->LastParameter() << "\n";
|
||||
if (!compact) OS << "Basis curve :\n";
|
||||
GeomTools_Curve2dSet::PrintCurve2d(C->BasisCurve(),OS,compact);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom2d_OffsetCurve)& C,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << OFFSET << " ";
|
||||
else
|
||||
OS << "OffsetCurve";
|
||||
if (!compact) OS << "Offset : ";
|
||||
OS << C->Offset() << "\n";
|
||||
if (!compact) OS << "Basis curve :\n";
|
||||
GeomTools_Curve2dSet::PrintCurve2d(C->BasisCurve(),OS,compact);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PrintCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_Curve2dSet::PrintCurve2d(const Handle(Geom2d_Curve)& C,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
Handle(Standard_Type) TheType = C->DynamicType();
|
||||
|
||||
if ( TheType == STANDARD_TYPE(Geom2d_Circle)) {
|
||||
Print(Handle(Geom2d_Circle)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType ==STANDARD_TYPE(Geom2d_Line)) {
|
||||
Print(Handle(Geom2d_Line)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_Ellipse)) {
|
||||
Print(Handle(Geom2d_Ellipse)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_Parabola)) {
|
||||
Print(Handle(Geom2d_Parabola)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_Hyperbola)) {
|
||||
Print(Handle(Geom2d_Hyperbola)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_BezierCurve)) {
|
||||
Print(Handle(Geom2d_BezierCurve)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_BSplineCurve)) {
|
||||
Print(Handle(Geom2d_BSplineCurve)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
|
||||
Print(Handle(Geom2d_TrimmedCurve)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_OffsetCurve)) {
|
||||
Print(Handle(Geom2d_OffsetCurve)::DownCast(C),OS,compact);
|
||||
}
|
||||
else {
|
||||
GeomTools::GetUndefinedTypeHandler()->PrintCurve2d(C,OS,compact);
|
||||
//if (!compact)
|
||||
// OS << "****** UNKNOWN CURVE2d TYPE ******\n";
|
||||
//else
|
||||
// cout << "****** UNKNOWN CURVE2d TYPE ******" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_Curve2dSet::Dump(Standard_OStream& OS)const
|
||||
{
|
||||
Standard_Integer i, nbsurf = myMap.Extent();
|
||||
OS << "\n -------\n";
|
||||
OS << "Dump of "<< nbsurf << " Curve2ds ";
|
||||
OS << "\n -------\n\n";
|
||||
|
||||
for (i = 1; i <= nbsurf; i++) {
|
||||
OS << setw(4) << i << " : ";
|
||||
PrintCurve2d(Handle(Geom2d_Curve)::DownCast(myMap(i)),OS,Standard_False);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_Curve2dSet::Write(Standard_OStream& OS)const
|
||||
{
|
||||
int prec = OS.precision(17);
|
||||
|
||||
Standard_Integer i, nbsurf = myMap.Extent();
|
||||
OS << "Curve2ds "<< nbsurf << "\n";
|
||||
//OCC19559
|
||||
Handle(Message_ProgressIndicator) progress = GetProgress();
|
||||
Message_ProgressSentry PS(progress, "2D Curves", 0, nbsurf, 1);
|
||||
|
||||
for (i = 1; i <= nbsurf && PS.More(); i++, PS.Next()) {
|
||||
if ( !myProgress.IsNull() )
|
||||
progress->Show();
|
||||
PrintCurve2d(Handle(Geom2d_Curve)::DownCast(myMap(i)),OS,Standard_True);
|
||||
}
|
||||
|
||||
OS.precision(prec);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadPnt2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS, gp_Pnt2d& P)
|
||||
{
|
||||
Standard_Real X=0.,Y=0.;
|
||||
IS >> X >> Y;
|
||||
P.SetCoord(X,Y);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadDir2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS, gp_Dir2d& D)
|
||||
{
|
||||
Standard_Real X=0.,Y=0.;
|
||||
IS >> X >> Y;
|
||||
D.SetCoord(X,Y);
|
||||
return IS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom2d_Line)& L)
|
||||
{
|
||||
gp_Pnt2d P(0.,0.);
|
||||
gp_Dir2d AX(1.,0.);
|
||||
IS >> P >> AX;
|
||||
L = new Geom2d_Line(P,AX);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom2d_Circle)& C)
|
||||
{
|
||||
gp_Pnt2d P(0.,0.);
|
||||
gp_Dir2d AX(1.,0.),AY(1.,0.);
|
||||
Standard_Real R=0.;
|
||||
IS >> P >> AX >> AY >> R;
|
||||
C = new Geom2d_Circle(gp_Ax22d(P,AX,AY),R);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom2d_Ellipse)& E)
|
||||
{
|
||||
gp_Pnt2d P(0.,0.);
|
||||
gp_Dir2d AX(1.,0.),AY(1.,0.);
|
||||
Standard_Real R1=0.,R2=0.;
|
||||
IS >> P >> AX >> AY >> R1 >> R2;
|
||||
E = new Geom2d_Ellipse(gp_Ax22d(P,AX,AY),R1,R2);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom2d_Parabola)& C)
|
||||
{
|
||||
gp_Pnt2d P(0.,0.);
|
||||
gp_Dir2d AX(1.,0.),AY(1.,0.);
|
||||
Standard_Real R1=0.;
|
||||
IS >> P >> AX >> AY >> R1;
|
||||
C = new Geom2d_Parabola(gp_Ax22d(P,AX,AY),R1);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom2d_Hyperbola)& H)
|
||||
{
|
||||
gp_Pnt2d P(0.,0.);
|
||||
gp_Dir2d AX(1.,0.),AY(1.,0.);
|
||||
Standard_Real R1=0.,R2=0.;
|
||||
IS >> P >> AX >> AY >> R1 >> R2;
|
||||
H = new Geom2d_Hyperbola(gp_Ax22d(P,AX,AY),R1,R2);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom2d_BezierCurve)& B)
|
||||
{
|
||||
Standard_Boolean rational=Standard_False;
|
||||
IS >> rational;
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i=0,degree=0;
|
||||
IS >> degree;
|
||||
|
||||
TColgp_Array1OfPnt2d poles(1,degree+1);
|
||||
TColStd_Array1OfReal weights(1,degree+1);
|
||||
|
||||
for (i = 1; i <= degree+1; i++) {
|
||||
IS >> poles(i);
|
||||
if (rational)
|
||||
IS >> weights(i);
|
||||
}
|
||||
|
||||
if (rational)
|
||||
B = new Geom2d_BezierCurve(poles,weights);
|
||||
else
|
||||
B = new Geom2d_BezierCurve(poles);
|
||||
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom2d_BSplineCurve)& B)
|
||||
{
|
||||
Standard_Boolean rational=Standard_False,periodic=Standard_False;
|
||||
IS >> rational >> periodic;
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i=0,degree=0,nbpoles=0,nbknots=0;
|
||||
IS >> degree >> nbpoles >> nbknots;
|
||||
|
||||
TColgp_Array1OfPnt2d poles(1,nbpoles);
|
||||
TColStd_Array1OfReal weights(1,nbpoles);
|
||||
|
||||
for (i = 1; i <= nbpoles; i++) {
|
||||
IS >> poles(i);
|
||||
if (rational)
|
||||
IS >> weights(i);
|
||||
}
|
||||
|
||||
TColStd_Array1OfReal knots(1,nbknots);
|
||||
TColStd_Array1OfInteger mults(1,nbknots);
|
||||
|
||||
for (i = 1; i <= nbknots; i++) {
|
||||
IS >> knots(i) >> mults(i);
|
||||
}
|
||||
|
||||
if (rational)
|
||||
B = new Geom2d_BSplineCurve(poles,weights,knots,mults,degree,periodic);
|
||||
else
|
||||
B = new Geom2d_BSplineCurve(poles,knots,mults,degree,periodic);
|
||||
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom2d_TrimmedCurve)& C)
|
||||
{
|
||||
Standard_Real p1=0.,p2=0.;
|
||||
IS >> p1 >> p2;
|
||||
Handle(Geom2d_Curve) BC;
|
||||
GeomTools_Curve2dSet::ReadCurve2d(IS,BC);
|
||||
C = new Geom2d_TrimmedCurve(BC,p1,p2);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom2d_OffsetCurve)& C)
|
||||
{
|
||||
Standard_Real p=0.;
|
||||
IS >> p;
|
||||
Handle(Geom2d_Curve) BC;
|
||||
GeomTools_Curve2dSet::ReadCurve2d(IS,BC);
|
||||
C = new Geom2d_OffsetCurve(BC,p);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS,
|
||||
Handle(Geom2d_Curve)& C)
|
||||
{
|
||||
Standard_Integer ctype;
|
||||
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
IS >> ctype;
|
||||
switch (ctype) {
|
||||
|
||||
case LINE :
|
||||
{
|
||||
Handle(Geom2d_Line) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case CIRCLE :
|
||||
{
|
||||
Handle(Geom2d_Circle) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case ELLIPSE :
|
||||
{
|
||||
Handle(Geom2d_Ellipse) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case PARABOLA :
|
||||
{
|
||||
Handle(Geom2d_Parabola) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case HYPERBOLA :
|
||||
{
|
||||
Handle(Geom2d_Hyperbola) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case BEZIER :
|
||||
{
|
||||
Handle(Geom2d_BezierCurve) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case BSPLINE :
|
||||
{
|
||||
Handle(Geom2d_BSplineCurve) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case TRIMMED :
|
||||
{
|
||||
Handle(Geom2d_TrimmedCurve) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case OFFSET :
|
||||
{
|
||||
Handle(Geom2d_OffsetCurve) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
Handle(Geom2d_Curve) CC;
|
||||
GeomTools::GetUndefinedTypeHandler()->ReadCurve2d(ctype,IS,CC);
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
#ifdef DEB
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
cout <<"EXCEPTION in GeomTools_Curve2dSet::ReadCurve2d(..)!!!" << endl;
|
||||
cout << anExc << endl;
|
||||
#endif
|
||||
C = NULL;
|
||||
}
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_Curve2dSet::Read(Standard_IStream& IS)
|
||||
{
|
||||
char buffer[255];
|
||||
IS >> buffer;
|
||||
if (strcmp(buffer,"Curve2ds")) {
|
||||
cout << "Not a Curve2d table"<<endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom2d_Curve) C;
|
||||
Standard_Integer i, nbcurve;
|
||||
IS >> nbcurve;
|
||||
//OCC19559
|
||||
Handle(Message_ProgressIndicator) progress = GetProgress();
|
||||
Message_ProgressSentry PS(progress, "2D Curves", 0, nbcurve, 1);
|
||||
|
||||
for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
|
||||
if ( !myProgress.IsNull() )
|
||||
progress->Show();
|
||||
|
||||
GeomTools_Curve2dSet::ReadCurve2d(IS,C);
|
||||
myMap.Add(C);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetProgress
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Message_ProgressIndicator) GeomTools_Curve2dSet::GetProgress() const
|
||||
{
|
||||
return myProgress;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetProgress
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_Curve2dSet::SetProgress(const Handle(Message_ProgressIndicator)& PR)
|
||||
{
|
||||
myProgress = PR;
|
||||
}
|
||||
|
||||
|
91
src/GeomTools/GeomTools_CurveSet.cdl
Executable file
91
src/GeomTools/GeomTools_CurveSet.cdl
Executable file
@@ -0,0 +1,91 @@
|
||||
-- File: GeomTools_CurveSet.cdl
|
||||
-- Created: Mon Jul 19 15:26:39 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@nonox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
|
||||
class CurveSet from GeomTools
|
||||
|
||||
---Purpose: Stores a set of Curves from Geom.
|
||||
|
||||
uses
|
||||
Curve from Geom,
|
||||
IndexedMapOfTransient from TColStd,
|
||||
ProgressIndicator from Message
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
Create returns CurveSet from GeomTools;
|
||||
---Purpose: Returns an empty set of Curves.
|
||||
|
||||
Clear(me : in out)
|
||||
---Purpose: Clears the content of the set.
|
||||
is static;
|
||||
|
||||
Add(me : in out; C : Curve from Geom) returns Integer
|
||||
---Purpose: Incorporate a new Curve in the set and returns
|
||||
-- its index.
|
||||
is static;
|
||||
|
||||
Curve(me; I : Integer) returns Curve from Geom
|
||||
---Purpose: Returns the Curve of index <I>.
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
is static;
|
||||
|
||||
Index(me; C : Curve from Geom) returns Integer
|
||||
---Purpose: Returns the index of <L>.
|
||||
is static;
|
||||
|
||||
Dump(me; OS : in out OStream)
|
||||
---Purpose: Dumps the content of me on the stream <OS>.
|
||||
is static;
|
||||
|
||||
Write(me; OS : in out OStream)
|
||||
---Purpose: Writes the content of me on the stream <OS> in a
|
||||
-- format that can be read back by Read.
|
||||
is static;
|
||||
|
||||
Read(me : in out; IS : in out IStream)
|
||||
---Purpose: Reads the content of me from the stream <IS>. me
|
||||
-- is first cleared.
|
||||
--
|
||||
is static;
|
||||
|
||||
--
|
||||
-- class methods to write an read curves
|
||||
--
|
||||
|
||||
PrintCurve(myclass; C : Curve from Geom;
|
||||
OS : in out OStream;
|
||||
compact : Boolean = Standard_False);
|
||||
---Purpose: Dumps the curve on the stream, if compact is True
|
||||
-- use the compact format that can be read back.
|
||||
|
||||
ReadCurve(myclass; IS : in out IStream;
|
||||
C : in out Curve from Geom)
|
||||
returns IStream;
|
||||
---Purpose: Reads the curve from the stream. The curve is
|
||||
-- assumed to have been writtent with the Print
|
||||
-- method (compact = True).
|
||||
--
|
||||
---C++: return &
|
||||
|
||||
SetProgress(me : in out; PR : ProgressIndicator from Message);
|
||||
|
||||
GetProgress(me) returns ProgressIndicator from Message;
|
||||
|
||||
fields
|
||||
|
||||
myMap : IndexedMapOfTransient from TColStd;
|
||||
myProgress : ProgressIndicator from Message;
|
||||
|
||||
end CurveSet;
|
||||
|
||||
|
892
src/GeomTools/GeomTools_CurveSet.cxx
Executable file
892
src/GeomTools/GeomTools_CurveSet.cxx
Executable file
@@ -0,0 +1,892 @@
|
||||
// File: GeomTools_CurveSet.cxx
|
||||
// Created: Mon Jul 19 16:57:45 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@nonox>
|
||||
|
||||
#include <Standard_Stream.hxx>
|
||||
#include <GeomTools_CurveSet.ixx>
|
||||
#include <GeomTools.hxx>
|
||||
#include <GeomTools_UndefinedTypeHandler.hxx>
|
||||
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Line.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 <Geom_OffsetCurve.hxx>
|
||||
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <gp_Elips.hxx>
|
||||
#include <gp_Parab.hxx>
|
||||
#include <gp_Hypr.hxx>
|
||||
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Message_ProgressSentry.hxx>
|
||||
|
||||
#define LINE 1
|
||||
#define CIRCLE 2
|
||||
#define ELLIPSE 3
|
||||
#define PARABOLA 4
|
||||
#define HYPERBOLA 5
|
||||
#define BEZIER 6
|
||||
#define BSPLINE 7
|
||||
#define TRIMMED 8
|
||||
#define OFFSET 9
|
||||
|
||||
//=======================================================================
|
||||
//function : GeomTools_CurveSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
GeomTools_CurveSet::GeomTools_CurveSet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_CurveSet::Clear()
|
||||
{
|
||||
myMap.Clear();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer GeomTools_CurveSet::Add(const Handle(Geom_Curve)& C)
|
||||
{
|
||||
return (C.IsNull()) ? 0 : myMap.Add(C);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Curve) GeomTools_CurveSet::Curve
|
||||
(const Standard_Integer I)const
|
||||
{
|
||||
if (I <= 0 || I > myMap.Extent())
|
||||
return Handle(Geom_Curve)();
|
||||
return Handle(Geom_Curve)::DownCast(myMap(I));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Index
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer GeomTools_CurveSet::Index
|
||||
(const Handle(Geom_Curve)& S)const
|
||||
{
|
||||
return S.IsNull() ? 0 : myMap.FindIndex(S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const gp_Pnt P,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
OS << P.X();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << P.Y();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << P.Z();
|
||||
OS << " ";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const gp_Dir D,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
OS << D.X();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << D.Y();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << D.Z();
|
||||
OS << " ";
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom_Line)& L,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << LINE << " ";
|
||||
else
|
||||
OS << "Line";
|
||||
|
||||
gp_Lin C = L->Lin();
|
||||
if (!compact) OS << "\n Origin :";
|
||||
Print(C.Location(),OS,compact);
|
||||
if (!compact) OS << "\n Axis :";
|
||||
Print(C.Direction(),OS,compact);
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom_Circle)& CC,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << CIRCLE << " ";
|
||||
else
|
||||
OS << "Circle";
|
||||
|
||||
gp_Circ C = CC->Circ();
|
||||
if (!compact) OS << "\n Center :";
|
||||
Print(C.Location(),OS,compact);
|
||||
if (!compact) OS << "\n Axis :";
|
||||
Print(C.Axis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n XAxis :";
|
||||
Print(C.XAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n YAxis :";
|
||||
Print(C.YAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n Radius :";
|
||||
OS << C.Radius();
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom_Ellipse)& E,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << ELLIPSE << " ";
|
||||
else
|
||||
OS << "Ellipse";
|
||||
|
||||
gp_Elips C = E->Elips();
|
||||
if (!compact) OS << "\n Center :";
|
||||
Print(C.Location(),OS,compact);
|
||||
if (!compact) OS << "\n Axis :";
|
||||
Print(C.Axis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n XAxis :";
|
||||
Print(C.XAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n YAxis :";
|
||||
Print(C.YAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n Radii :";
|
||||
OS << C.MajorRadius();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << C.MinorRadius();
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom_Parabola)& P,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << PARABOLA << " ";
|
||||
else
|
||||
OS << "Parabola";
|
||||
|
||||
gp_Parab C = P->Parab();
|
||||
if (!compact) OS << "\n Center :";
|
||||
Print(C.Location(),OS,compact);
|
||||
if (!compact) OS << "\n Axis :";
|
||||
Print(C.Axis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n XAxis :";
|
||||
Print(C.XAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n YAxis :";
|
||||
Print(C.YAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n Focal :";
|
||||
OS << C.Focal();
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom_Hyperbola)& H,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << HYPERBOLA << " ";
|
||||
else
|
||||
OS << "Hyperbola";
|
||||
|
||||
gp_Hypr C = H->Hypr();
|
||||
if (!compact) OS << "\n Center :";
|
||||
Print(C.Location(),OS,compact);
|
||||
if (!compact) OS << "\n Axis :";
|
||||
Print(C.Axis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n XAxis :";
|
||||
Print(C.XAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n YAxis :";
|
||||
Print(C.YAxis().Direction(),OS,compact);
|
||||
if (!compact) OS << "\n Radii :";
|
||||
OS << C.MajorRadius();
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << C.MinorRadius();
|
||||
if (!compact) OS << "\n";
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom_BezierCurve)& B,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << BEZIER << " ";
|
||||
else
|
||||
OS << "BezierCurve";
|
||||
|
||||
Standard_Boolean rational = B->IsRational();
|
||||
if (compact)
|
||||
OS << (rational ? 1 : 0) << " ";
|
||||
else {
|
||||
if (rational)
|
||||
OS << " rational";
|
||||
}
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i,degree = B->Degree();
|
||||
if (!compact) OS << "\n Degree :";
|
||||
OS << degree << " ";
|
||||
|
||||
for (i = 1; i <= degree+1; i++) {
|
||||
if (!compact) OS << "\n "<<setw(2)<<i<<" : ";
|
||||
Print(B->Pole(i),OS,compact);
|
||||
if (rational)
|
||||
OS << " " << B->Weight(i);
|
||||
if (compact)
|
||||
OS << " ";
|
||||
}
|
||||
OS << "\n";
|
||||
if (!compact) OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom_BSplineCurve)& B,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << BSPLINE << " ";
|
||||
else
|
||||
OS << "BSplineCurve";
|
||||
|
||||
|
||||
Standard_Boolean rational = B->IsRational();
|
||||
if (compact)
|
||||
OS << (rational ? 1 : 0) << " ";
|
||||
else {
|
||||
if (rational)
|
||||
OS << " rational";
|
||||
}
|
||||
|
||||
Standard_Boolean periodic = B->IsPeriodic();
|
||||
if (compact)
|
||||
OS << (periodic ? 1 : 0)<< " ";
|
||||
else {
|
||||
if (periodic)
|
||||
OS << " periodic";
|
||||
}
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i,degree,nbpoles,nbknots;
|
||||
degree = B->Degree();
|
||||
nbpoles = B->NbPoles();
|
||||
nbknots = B->NbKnots();
|
||||
if (!compact) OS << "\n Degree ";
|
||||
else OS << " ";
|
||||
OS << degree;
|
||||
if (!compact) OS << ",";
|
||||
OS << " ";
|
||||
OS << nbpoles;
|
||||
if (!compact) OS << " Poles,";
|
||||
OS << " ";
|
||||
OS << nbknots << " ";
|
||||
if (!compact) OS << " Knots\n";
|
||||
|
||||
if (!compact) OS << "Poles :\n";
|
||||
for (i = 1; i <= nbpoles; i++) {
|
||||
if (!compact) OS << "\n "<<setw(2)<<i<<" : ";
|
||||
else OS << " ";
|
||||
Print(B->Pole(i),OS,compact);
|
||||
if (rational)
|
||||
OS << " " << B->Weight(i);
|
||||
}
|
||||
OS << "\n";
|
||||
|
||||
if (!compact) OS << "Knots :\n";
|
||||
for (i = 1; i <= nbknots; i++) {
|
||||
if (!compact) OS << "\n "<<setw(2)<<i<<" : ";
|
||||
OS << " " << B->Knot(i) << " " << B->Multiplicity(i);
|
||||
}
|
||||
|
||||
OS << "\n";
|
||||
if (!compact) OS << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom_TrimmedCurve)& C,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << TRIMMED << " ";
|
||||
else
|
||||
OS << "Trimmed curve\n";
|
||||
if (!compact) OS << "Parameters : ";
|
||||
OS << C->FirstParameter() << " " << C->LastParameter() << "\n";
|
||||
if (!compact) OS << "Basis curve :\n";
|
||||
GeomTools_CurveSet::PrintCurve(C->BasisCurve(),OS,compact);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void Print(const Handle(Geom_OffsetCurve)& C,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
if (compact)
|
||||
OS << OFFSET << " ";
|
||||
else
|
||||
OS << "OffsetCurve";
|
||||
if (!compact) OS << "Offset : ";
|
||||
OS << C->Offset() << "\n";
|
||||
if (!compact) OS << "Direction : ";
|
||||
Print(C->Direction(),OS,compact);
|
||||
OS << "\n";
|
||||
if (!compact) OS << "Basis curve :\n";
|
||||
GeomTools_CurveSet::PrintCurve(C->BasisCurve(),OS,compact);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_CurveSet::PrintCurve(const Handle(Geom_Curve)& C,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact)
|
||||
{
|
||||
Handle(Standard_Type) TheType = C->DynamicType();
|
||||
|
||||
if ( TheType ==STANDARD_TYPE(Geom_Line)) {
|
||||
Print(Handle(Geom_Line)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_Circle)) {
|
||||
Print(Handle(Geom_Circle)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_Ellipse)) {
|
||||
Print(Handle(Geom_Ellipse)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_Parabola)) {
|
||||
Print(Handle(Geom_Parabola)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_Hyperbola)) {
|
||||
Print(Handle(Geom_Hyperbola)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_BezierCurve)) {
|
||||
Print(Handle(Geom_BezierCurve)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_BSplineCurve)) {
|
||||
Print(Handle(Geom_BSplineCurve)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_TrimmedCurve)) {
|
||||
Print(Handle(Geom_TrimmedCurve)::DownCast(C),OS,compact);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_OffsetCurve)) {
|
||||
Print(Handle(Geom_OffsetCurve)::DownCast(C),OS,compact);
|
||||
}
|
||||
else {
|
||||
GeomTools::GetUndefinedTypeHandler()->PrintCurve(C,OS,compact);
|
||||
//if (!compact)
|
||||
// OS << "****** UNKNOWN CURVE TYPE ******\n";
|
||||
//else
|
||||
// cout << "****** UNKNOWN CURVE TYPE ******" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_CurveSet::Dump(Standard_OStream& OS)const
|
||||
{
|
||||
Standard_Integer i, nbsurf = myMap.Extent();
|
||||
OS << "\n -------\n";
|
||||
OS << "Dump of "<< nbsurf << " Curves ";
|
||||
OS << "\n -------\n\n";
|
||||
|
||||
for (i = 1; i <= nbsurf; i++) {
|
||||
OS << setw(4) << i << " : ";
|
||||
PrintCurve(Handle(Geom_Curve)::DownCast(myMap(i)),OS,Standard_False);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_CurveSet::Write(Standard_OStream& OS)const
|
||||
{
|
||||
int prec = OS.precision(17);
|
||||
|
||||
Standard_Integer i, nbcurve = myMap.Extent();
|
||||
OS << "Curves "<< nbcurve << "\n";
|
||||
//OCC19559
|
||||
Handle(Message_ProgressIndicator) progress = GetProgress();
|
||||
Message_ProgressSentry PS(progress, "3D Curves", 0, nbcurve, 1);
|
||||
|
||||
for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
|
||||
if ( !progress.IsNull() )
|
||||
progress->Show();
|
||||
|
||||
PrintCurve(Handle(Geom_Curve)::DownCast(myMap(i)),OS,Standard_True);
|
||||
}
|
||||
|
||||
OS.precision(prec);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadPnt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS, gp_Pnt& P)
|
||||
{
|
||||
Standard_Real X=0.,Y=0.,Z=0.;
|
||||
IS >> X >> Y >> Z;
|
||||
P.SetCoord(X,Y,Z);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadDir
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS, gp_Dir& D)
|
||||
{
|
||||
Standard_Real X=0.,Y=0.,Z=0.;
|
||||
IS >> X >> Y >> Z;
|
||||
D.SetCoord(X,Y,Z);
|
||||
return IS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_Line)& L)
|
||||
{
|
||||
gp_Pnt P(0.,0.,0.);
|
||||
gp_Dir AX(1.,0.,0.);
|
||||
IS >> P >> AX;
|
||||
L = new Geom_Line(P,AX);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_Circle)& C)
|
||||
{
|
||||
gp_Pnt P(0.,0.,0.);
|
||||
gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
|
||||
Standard_Real R=0.;
|
||||
IS >> P >> A >> AX >> AY >> R;
|
||||
C = new Geom_Circle(gp_Ax2(P,A,AX),R);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_Ellipse)& E)
|
||||
{
|
||||
gp_Pnt P(0.,0.,0.);
|
||||
gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
|
||||
Standard_Real R1=0.,R2=0.;
|
||||
IS >> P >> A >> AX >> AY >> R1 >> R2;
|
||||
E = new Geom_Ellipse(gp_Ax2(P,A,AX),R1,R2);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_Parabola)& C)
|
||||
{
|
||||
gp_Pnt P(0.,0.,0.);
|
||||
gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
|
||||
Standard_Real R1=0.;
|
||||
IS >> P >> A >> AX >> AY >> R1;
|
||||
C = new Geom_Parabola(gp_Ax2(P,A,AX),R1);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_Hyperbola)& H)
|
||||
{
|
||||
gp_Pnt P(0.,0.,0.);
|
||||
gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
|
||||
Standard_Real R1=0.,R2=0.;
|
||||
IS >> P >> A >> AX >> AY >> R1 >> R2;
|
||||
H = new Geom_Hyperbola(gp_Ax2(P,A,AX),R1,R2);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_BezierCurve)& B)
|
||||
{
|
||||
Standard_Boolean rational=Standard_False;
|
||||
IS >> rational;
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i=0,degree=0;
|
||||
IS >> degree;
|
||||
|
||||
TColgp_Array1OfPnt poles(1,degree+1);
|
||||
TColStd_Array1OfReal weights(1,degree+1);
|
||||
|
||||
for (i = 1; i <= degree+1; i++) {
|
||||
IS >> poles(i);
|
||||
if (rational)
|
||||
IS >> weights(i);
|
||||
}
|
||||
|
||||
if (rational)
|
||||
B = new Geom_BezierCurve(poles,weights);
|
||||
else
|
||||
B = new Geom_BezierCurve(poles);
|
||||
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_BSplineCurve)& B)
|
||||
{
|
||||
|
||||
Standard_Boolean rational=Standard_False,periodic=Standard_False;
|
||||
IS >> rational >> periodic;
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i=0,degree=0,nbpoles=0,nbknots=0;
|
||||
IS >> degree >> nbpoles >> nbknots;
|
||||
|
||||
TColgp_Array1OfPnt poles(1,nbpoles);
|
||||
TColStd_Array1OfReal weights(1,nbpoles);
|
||||
|
||||
for (i = 1; i <= nbpoles; i++) {
|
||||
IS >> poles(i);
|
||||
if (rational)
|
||||
IS >> weights(i);
|
||||
}
|
||||
|
||||
TColStd_Array1OfReal knots(1,nbknots);
|
||||
TColStd_Array1OfInteger mults(1,nbknots);
|
||||
|
||||
for (i = 1; i <= nbknots; i++) {
|
||||
IS >> knots(i) >> mults(i);
|
||||
}
|
||||
|
||||
if (rational)
|
||||
B = new Geom_BSplineCurve(poles,weights,knots,mults,degree,periodic);
|
||||
else
|
||||
B = new Geom_BSplineCurve(poles,knots,mults,degree,periodic);
|
||||
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_TrimmedCurve)& C)
|
||||
{
|
||||
Standard_Real p1=0.,p2=0.;
|
||||
IS >> p1 >> p2;
|
||||
Handle(Geom_Curve) BC;
|
||||
GeomTools_CurveSet::ReadCurve(IS,BC);
|
||||
C = new Geom_TrimmedCurve(BC,p1,p2);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_OffsetCurve)& C)
|
||||
{
|
||||
Standard_Real p=0.;
|
||||
IS >> p;
|
||||
gp_Dir D(1.,0.,0.);
|
||||
IS >> D;
|
||||
Handle(Geom_Curve) BC;
|
||||
GeomTools_CurveSet::ReadCurve(IS,BC);
|
||||
C = new Geom_OffsetCurve(BC,p,D);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& GeomTools_CurveSet::ReadCurve(Standard_IStream& IS,
|
||||
Handle(Geom_Curve)& C)
|
||||
{
|
||||
Standard_Integer ctype;
|
||||
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
IS >> ctype;
|
||||
switch (ctype) {
|
||||
|
||||
case LINE :
|
||||
{
|
||||
Handle(Geom_Line) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case CIRCLE :
|
||||
{
|
||||
Handle(Geom_Circle) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case ELLIPSE :
|
||||
{
|
||||
Handle(Geom_Ellipse) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case PARABOLA :
|
||||
{
|
||||
Handle(Geom_Parabola) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case HYPERBOLA :
|
||||
{
|
||||
Handle(Geom_Hyperbola) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case BEZIER :
|
||||
{
|
||||
Handle(Geom_BezierCurve) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case BSPLINE :
|
||||
{
|
||||
Handle(Geom_BSplineCurve) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case TRIMMED :
|
||||
{
|
||||
Handle(Geom_TrimmedCurve) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
case OFFSET :
|
||||
{
|
||||
Handle(Geom_OffsetCurve) CC;
|
||||
IS >> CC;
|
||||
C = CC;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
Handle(Geom_Curve) CC;
|
||||
GeomTools::GetUndefinedTypeHandler()->ReadCurve(ctype,IS,CC);
|
||||
C = CC;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
#ifdef DEB
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
cout <<"EXCEPTION in GeomTools_CurveSet::ReadCurve(..)!!!" << endl;
|
||||
cout << anExc << endl;
|
||||
#endif
|
||||
C = NULL;
|
||||
}
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_CurveSet::Read(Standard_IStream& IS)
|
||||
{
|
||||
char buffer[255];
|
||||
IS >> buffer;
|
||||
if (strcmp(buffer,"Curves")) {
|
||||
cout << "Not a Curve table"<<endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom_Curve) C;
|
||||
Standard_Integer i, nbcurve;
|
||||
IS >> nbcurve;
|
||||
//OCC19559
|
||||
Handle(Message_ProgressIndicator) progress = GetProgress();
|
||||
Message_ProgressSentry PS(progress, "3D Curves", 0, nbcurve, 1);
|
||||
for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
|
||||
if ( !progress.IsNull() )
|
||||
progress->Show();
|
||||
|
||||
GeomTools_CurveSet::ReadCurve(IS,C);
|
||||
myMap.Add(C);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetProgress
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Message_ProgressIndicator) GeomTools_CurveSet::GetProgress() const
|
||||
{
|
||||
return myProgress;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetProgress
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_CurveSet::SetProgress(const Handle(Message_ProgressIndicator)& PR)
|
||||
{
|
||||
myProgress = PR;
|
||||
}
|
||||
|
||||
|
90
src/GeomTools/GeomTools_SurfaceSet.cdl
Executable file
90
src/GeomTools/GeomTools_SurfaceSet.cdl
Executable file
@@ -0,0 +1,90 @@
|
||||
-- File: GeomTools_SurfaceSet.cdl
|
||||
-- Created: Mon Jul 19 15:21:50 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@nonox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class SurfaceSet from GeomTools
|
||||
|
||||
---Purpose: Stores a set of Surfaces from Geom.
|
||||
|
||||
uses
|
||||
Surface from Geom,
|
||||
IndexedMapOfTransient from TColStd,
|
||||
ProgressIndicator from Message
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
Create returns SurfaceSet from GeomTools;
|
||||
---Purpose: Returns an empty set of Surfaces.
|
||||
|
||||
Clear(me : in out)
|
||||
---Purpose: Clears the content of the set.
|
||||
is static;
|
||||
|
||||
Add(me : in out; S : Surface from Geom) returns Integer
|
||||
---Purpose: Incorporate a new Surface in the set and returns
|
||||
-- its index.
|
||||
is static;
|
||||
|
||||
Surface(me; I : Integer) returns Surface from Geom
|
||||
---Purpose: Returns the Surface of index <I>.
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
is static;
|
||||
|
||||
Index(me; S : Surface from Geom) returns Integer
|
||||
---Purpose: Returns the index of <L>.
|
||||
is static;
|
||||
|
||||
Dump(me; OS : in out OStream)
|
||||
---Purpose: Dumps the content of me on the stream <OS>.
|
||||
is static;
|
||||
|
||||
Write(me; OS : in out OStream)
|
||||
---Purpose: Writes the content of me on the stream <OS> in a
|
||||
-- format that can be read back by Read.
|
||||
is static;
|
||||
|
||||
Read(me : in out; IS : in out IStream)
|
||||
---Purpose: Reads the content of me from the stream <IS>. me
|
||||
-- is first cleared.
|
||||
--
|
||||
is static;
|
||||
|
||||
--
|
||||
-- class methods to write an read surfaces
|
||||
--
|
||||
|
||||
PrintSurface(myclass; S : Surface from Geom;
|
||||
OS : in out OStream;
|
||||
compact : Boolean = Standard_False);
|
||||
---Purpose: Dumps the surface on the stream, if compact is True
|
||||
-- use the compact format that can be read back.
|
||||
|
||||
ReadSurface(myclass; IS : in out IStream;
|
||||
S : in out Surface from Geom)
|
||||
returns IStream;
|
||||
---Purpose: Reads the surface from the stream. The surface is
|
||||
-- assumed to have been writtent with the Print
|
||||
-- method (compact = True).
|
||||
--
|
||||
---C++: return &
|
||||
|
||||
SetProgress(me : in out; PR : ProgressIndicator from Message);
|
||||
|
||||
GetProgress(me) returns ProgressIndicator from Message;
|
||||
|
||||
fields
|
||||
|
||||
myMap : IndexedMapOfTransient from TColStd;
|
||||
myProgress : ProgressIndicator from Message;
|
||||
|
||||
end SurfaceSet;
|
||||
|
||||
|
1083
src/GeomTools/GeomTools_SurfaceSet.cxx
Executable file
1083
src/GeomTools/GeomTools_SurfaceSet.cxx
Executable file
File diff suppressed because it is too large
Load Diff
60
src/GeomTools/GeomTools_UndefinedTypeHandler.cdl
Executable file
60
src/GeomTools/GeomTools_UndefinedTypeHandler.cdl
Executable file
@@ -0,0 +1,60 @@
|
||||
-- File: GeomTools_UndefinedTypeHandler.cdl
|
||||
-- Created: Fri Oct 29 11:16:35 1999
|
||||
-- Author: Pavel DURANDIN
|
||||
-- <pdn@friendox>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
|
||||
class UndefinedTypeHandler from GeomTools inherits TShared from MMgt
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
|
||||
Curve from Geom,
|
||||
Surface from Geom,
|
||||
Curve from Geom2d,
|
||||
OStream,
|
||||
IStream
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable UndefinedTypeHandler from GeomTools;
|
||||
|
||||
-- Curve
|
||||
|
||||
PrintCurve(me; C : Curve from Geom;
|
||||
OS : in out OStream;
|
||||
compact : Boolean = Standard_False) is virtual;
|
||||
|
||||
ReadCurve(me; ctype: Integer;
|
||||
IS : in out IStream;
|
||||
C : in out Curve from Geom)
|
||||
returns IStream is virtual;
|
||||
---C++: return &
|
||||
|
||||
--PCurve
|
||||
|
||||
PrintCurve2d(me; C : Curve from Geom2d;
|
||||
OS : in out OStream;
|
||||
compact : Boolean = Standard_False) is virtual;
|
||||
|
||||
ReadCurve2d(me; ctype: Integer;
|
||||
IS : in out IStream;
|
||||
C : in out Curve from Geom2d)
|
||||
returns IStream is virtual;
|
||||
---C++: return &
|
||||
|
||||
--Surface
|
||||
|
||||
PrintSurface(me; S : Surface from Geom;
|
||||
OS : in out OStream;
|
||||
compact : Boolean = Standard_False) is virtual;
|
||||
|
||||
ReadSurface(me; ctype: Integer;
|
||||
IS : in out IStream;
|
||||
S : in out Surface from Geom)
|
||||
returns IStream is virtual;
|
||||
---C++: return &
|
||||
|
||||
end UndefinedTypeHandler;
|
87
src/GeomTools/GeomTools_UndefinedTypeHandler.cxx
Executable file
87
src/GeomTools/GeomTools_UndefinedTypeHandler.cxx
Executable file
@@ -0,0 +1,87 @@
|
||||
// File: GeomTools_UndefinedTypeHandler.cxx
|
||||
// Created: Fri Oct 29 11:25:54 1999
|
||||
// Author: Pavel DURANDIN
|
||||
// <pdn@friendox>
|
||||
|
||||
|
||||
#include <GeomTools_UndefinedTypeHandler.ixx>
|
||||
|
||||
GeomTools_UndefinedTypeHandler::GeomTools_UndefinedTypeHandler()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PrintCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_UndefinedTypeHandler::PrintCurve(const Handle(Geom_Curve)& /*C*/,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact) const
|
||||
{
|
||||
if (!compact)
|
||||
OS << "****** UNKNOWN CURVE TYPE ******\n";
|
||||
else
|
||||
cout << "****** UNKNOWN CURVE TYPE ******" << endl;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& GeomTools_UndefinedTypeHandler::ReadCurve(const Standard_Integer /*ctype*/,
|
||||
Standard_IStream& IS,
|
||||
Handle(Geom_Curve)& /*C*/) const
|
||||
{
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_UndefinedTypeHandler::PrintCurve2d(const Handle(Geom2d_Curve)& /*C*/,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact) const
|
||||
{
|
||||
if (!compact)
|
||||
OS << "****** UNKNOWN CURVE2d TYPE ******\n";
|
||||
else
|
||||
cout << "****** UNKNOWN CURVE2d TYPE ******" << endl;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& GeomTools_UndefinedTypeHandler::ReadCurve2d(const Standard_Integer /*ctype*/,
|
||||
Standard_IStream& IS,
|
||||
Handle(Geom2d_Curve)& /*C*/) const
|
||||
{
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PrintSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomTools_UndefinedTypeHandler::PrintSurface(const Handle(Geom_Surface)& /*S*/,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean compact) const
|
||||
{
|
||||
if (!compact)
|
||||
OS << "****** UNKNOWN SURFACE TYPE ******\n";
|
||||
else
|
||||
cout << "****** UNKNOWN SURFACE TYPE ******" << endl;
|
||||
}
|
||||
|
||||
Standard_IStream& GeomTools_UndefinedTypeHandler::ReadSurface(const Standard_Integer /*ctype*/,
|
||||
Standard_IStream& IS,
|
||||
Handle(Geom_Surface)& /*S*/) const
|
||||
{
|
||||
return IS;
|
||||
}
|
Reference in New Issue
Block a user