mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
61
src/BinTools/BinTools.cdl
Executable file
61
src/BinTools/BinTools.cdl
Executable file
@@ -0,0 +1,61 @@
|
||||
-- File: BinTools.cdl
|
||||
-- Created: Tue May 11 18:02:29 2004
|
||||
-- Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
-- Copyright: Open CasCade S.A. 2004
|
||||
|
||||
|
||||
package BinTools
|
||||
|
||||
---Purpose: Tool to keep shapes in binary format
|
||||
|
||||
uses
|
||||
Geom2d,
|
||||
Geom,
|
||||
TColStd,
|
||||
TopoDS,
|
||||
TopAbs,
|
||||
TopLoc,
|
||||
BRep,
|
||||
BRepTools,
|
||||
TopTools
|
||||
is
|
||||
|
||||
class ShapeSet;
|
||||
|
||||
class Curve2dSet;
|
||||
|
||||
class CurveSet;
|
||||
|
||||
class SurfaceSet;
|
||||
|
||||
class LocationSet;
|
||||
|
||||
pointer LocationSetPtr to LocationSet from BinTools;
|
||||
|
||||
|
||||
PutReal (OS : out OStream from Standard; theValue : Real from Standard) returns OStream;
|
||||
---C++: return &
|
||||
|
||||
PutInteger (OS : out OStream from Standard; theValue : Integer from Standard) returns OStream;
|
||||
---C++: return &
|
||||
|
||||
PutBool (OS : out OStream from Standard; theValue : Boolean from Standard) returns OStream;
|
||||
---C++: return &
|
||||
|
||||
PutExtChar (OS : out OStream from Standard; theValue : ExtCharacter from Standard) returns OStream;
|
||||
---C++: return &
|
||||
|
||||
GetReal (IS : out IStream from Standard; theValue : out Real from Standard) returns IStream;
|
||||
---C++: return &
|
||||
|
||||
GetInteger (IS : out IStream from Standard; theValue : out Integer from Standard) returns IStream;
|
||||
---C++: return &
|
||||
|
||||
GetBool (IS : out IStream from Standard; theValue : out Boolean from Standard) returns IStream;
|
||||
---C++: return &
|
||||
|
||||
GetExtChar (IS : out IStream from Standard; theValue : out ExtCharacter from Standard) returns IStream;
|
||||
---C++: return &
|
||||
|
||||
end BinTools;
|
||||
|
121
src/BinTools/BinTools.cxx
Executable file
121
src/BinTools/BinTools.cxx
Executable file
@@ -0,0 +1,121 @@
|
||||
// File: BinTools.cxx
|
||||
// Created: Tue May 18 17:00:25 2004
|
||||
// Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
// Copyright: Open CasCade S.A. 2004
|
||||
|
||||
#include <BinTools.ixx>
|
||||
#include <FSD_FileHeader.hxx>
|
||||
#include <Storage_StreamTypeMismatchError.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : PutBool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_OStream& BinTools::PutBool(Standard_OStream& OS, const Standard_Boolean aValue)
|
||||
{
|
||||
OS.put((Standard_Byte)aValue);
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : PutInteger
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_OStream& BinTools::PutInteger(Standard_OStream& OS, const Standard_Integer aValue)
|
||||
{
|
||||
Standard_Integer anIntValue = aValue;
|
||||
#if DO_INVERSE
|
||||
anIntValue = InverseInt (aValue);
|
||||
#endif
|
||||
OS.write((char*)&anIntValue, sizeof(Standard_Integer));
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : PutReal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_OStream& BinTools::PutReal(Standard_OStream& OS, const Standard_Real aValue)
|
||||
{
|
||||
Standard_Real aRValue = aValue;
|
||||
#if DO_INVERSE
|
||||
aRValue = InverseReal (aValue);
|
||||
#endif
|
||||
OS.write((char*)&aRValue, sizeof(Standard_Real));
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PutExtChar
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_OStream& BinTools::PutExtChar(Standard_OStream& OS, const Standard_ExtCharacter aValue)
|
||||
{
|
||||
Standard_ExtCharacter aSValue = aValue;
|
||||
#if DO_INVERSE
|
||||
aSValue = InverseExtChar (aValue);
|
||||
#endif
|
||||
OS.write((char*)&aSValue, sizeof(Standard_ExtCharacter));
|
||||
return OS;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : GetReal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& BinTools::GetReal(Standard_IStream& IS, Standard_Real& aValue)
|
||||
{
|
||||
if(!IS.read ((char*)&aValue, sizeof(Standard_Real)))
|
||||
Storage_StreamTypeMismatchError::Raise();
|
||||
#if DO_INVERSE
|
||||
aValue = InverseReal (aValue);
|
||||
#endif
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetInteger
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& BinTools::GetInteger(Standard_IStream& IS, Standard_Integer& aValue)
|
||||
{
|
||||
if(!IS.read ((char*)&aValue, sizeof(Standard_Integer)))
|
||||
Storage_StreamTypeMismatchError::Raise();;
|
||||
#if DO_INVERSE
|
||||
aValue = InverseInt (aValue);
|
||||
#endif
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetExtChar
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& BinTools::GetExtChar(Standard_IStream& IS, Standard_ExtCharacter& theValue)
|
||||
{
|
||||
if(!IS.read ((char*)&theValue, sizeof(Standard_ExtCharacter)))
|
||||
Storage_StreamTypeMismatchError::Raise();;
|
||||
#if DO_INVERSE
|
||||
theValue = InverseExtChar (theValue);
|
||||
#endif
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetBool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& BinTools::GetBool(Standard_IStream& IS, Standard_Boolean& aValue)
|
||||
{
|
||||
aValue = (Standard_Boolean)IS.get();
|
||||
return IS;
|
||||
}
|
79
src/BinTools/BinTools_Curve2dSet.cdl
Executable file
79
src/BinTools/BinTools_Curve2dSet.cdl
Executable file
@@ -0,0 +1,79 @@
|
||||
-- File: BinTools_Curve2dSet.cdl
|
||||
-- Created: Tue May 18 17:20:14 2004
|
||||
-- Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
-- Copyright: Open CasCade S.A. 2004
|
||||
|
||||
|
||||
class Curve2dSet from BinTools
|
||||
|
||||
---Purpose: Stores a set of Curves from Geom2d in binary format
|
||||
|
||||
uses
|
||||
Curve from Geom2d,
|
||||
IndexedMapOfTransient from TColStd
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
Create returns Curve2dSet from BinTools;
|
||||
---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
|
||||
--
|
||||
|
||||
WriteCurve2d(myclass; C : Curve from Geom2d;
|
||||
OS : in out OStream);
|
||||
---Purpose: Dumps the curve on the binary stream, 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 written with the Write
|
||||
-- method.
|
||||
--
|
||||
---C++: return &
|
||||
|
||||
fields
|
||||
|
||||
myMap : IndexedMapOfTransient from TColStd;
|
||||
|
||||
end Curve2dSet;
|
||||
|
718
src/BinTools/BinTools_Curve2dSet.cxx
Executable file
718
src/BinTools/BinTools_Curve2dSet.cxx
Executable file
@@ -0,0 +1,718 @@
|
||||
// File: BinTools_Curve2dSet.cxx
|
||||
// Created: Tue May 18 17:22:26 2004
|
||||
// Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
// Copyright: Open CasCade S.A. 2004
|
||||
|
||||
#include <BinTools_Curve2dSet.ixx>
|
||||
#include <Standard_Stream.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 <BinTools.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 : BinTools_Curve2dSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BinTools_Curve2dSet::BinTools_Curve2dSet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_Curve2dSet::Clear()
|
||||
{
|
||||
myMap.Clear();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BinTools_Curve2dSet::Add(const Handle(Geom2d_Curve)& S)
|
||||
{
|
||||
return myMap.Add(S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Curve) BinTools_Curve2dSet::Curve2d
|
||||
(const Standard_Integer I)const
|
||||
{
|
||||
return Handle(Geom2d_Curve)::DownCast(myMap(I));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Index
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BinTools_Curve2dSet::Index
|
||||
(const Handle(Geom2d_Curve)& S)const
|
||||
{
|
||||
return myMap.FindIndex(S);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << (gp_Pnt2d)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const gp_Pnt2d P)
|
||||
|
||||
{
|
||||
BinTools::PutReal(OS, P.X());
|
||||
return BinTools::PutReal(OS, P.Y());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << (gp_Dir2d D)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const gp_Dir2d D)
|
||||
{
|
||||
BinTools::PutReal(OS, D.X());
|
||||
return BinTools::PutReal(OS, D.Y());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << ((Geom2d_Line)& L)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_Line)& L)
|
||||
{
|
||||
|
||||
OS << (Standard_Byte)LINE;
|
||||
gp_Lin2d C2d = L->Lin2d();
|
||||
OS << C2d.Location();//Pnt2d
|
||||
OS << C2d.Direction();//Dir2d
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << ((Geom2d_Circle)& C)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_Circle)& C)
|
||||
{
|
||||
OS << (Standard_Byte)CIRCLE;
|
||||
gp_Circ2d C2d = C->Circ2d();
|
||||
OS << C2d.Location();
|
||||
OS << C2d.XAxis().Direction();
|
||||
OS << C2d.YAxis().Direction();
|
||||
BinTools::PutReal(OS, C2d.Radius());
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom2d_Ellipse)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_Ellipse)& E)
|
||||
{
|
||||
OS << (Standard_Byte)ELLIPSE;
|
||||
gp_Elips2d C2d = E->Elips2d();
|
||||
OS << C2d.Location();
|
||||
OS << C2d.XAxis().Direction();
|
||||
OS << C2d.YAxis().Direction();
|
||||
BinTools::PutReal(OS, C2d.MajorRadius());
|
||||
BinTools::PutReal(OS, C2d.MinorRadius());
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << (Geom2d_Parabola)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_Parabola)& P)
|
||||
{
|
||||
OS << (Standard_Byte)PARABOLA;
|
||||
gp_Parab2d C2d = P->Parab2d();
|
||||
OS << C2d.Location();//Loc
|
||||
OS << C2d.Axis().XAxis().Direction();//XDir
|
||||
OS << C2d.Axis().YAxis().Direction();//YDir
|
||||
BinTools::PutReal(OS, C2d.Focal());//Focal
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom2d_Hyperbola)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_Hyperbola)& H)
|
||||
{
|
||||
OS << (Standard_Byte)HYPERBOLA;
|
||||
gp_Hypr2d C2d = H->Hypr2d();
|
||||
OS << C2d.Location(); //Loc
|
||||
OS << C2d.XAxis().Direction();//XDir
|
||||
OS << C2d.YAxis().Direction();//YDir
|
||||
BinTools::PutReal(OS, C2d.MajorRadius());//MajR
|
||||
BinTools::PutReal(OS, C2d.MinorRadius());
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom2d_BezierCurve)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_BezierCurve)& B)
|
||||
{
|
||||
OS << (Standard_Byte)BEZIER;
|
||||
Standard_Boolean aRational = B->IsRational() ? 1:0;
|
||||
BinTools::PutBool(OS, aRational); //rational
|
||||
// poles and weights
|
||||
Standard_Integer i,aDegree = B->Degree();
|
||||
BinTools::PutExtChar(OS, (Standard_ExtCharacter)aDegree); //Degree
|
||||
for (i = 1; i <= aDegree+1; i++) {
|
||||
OS << B->Pole(i); //Pnt2d
|
||||
if (aRational)
|
||||
BinTools::PutReal(OS, B->Weight(i));//Real
|
||||
}
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom2d_BSplineCurve)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_BSplineCurve)& B)
|
||||
{
|
||||
OS << (Standard_Byte)BSPLINE;
|
||||
Standard_Boolean aRational = B->IsRational() ? 1:0;
|
||||
BinTools::PutBool(OS, aRational); //rational
|
||||
Standard_Boolean aPeriodic = B->IsPeriodic() ? 1:0;
|
||||
BinTools::PutBool(OS, aPeriodic); //periodic
|
||||
// poles and weights
|
||||
Standard_Integer i,aDegree,aNbPoles,aNbKnots;
|
||||
aDegree = B->Degree();
|
||||
aNbPoles = B->NbPoles();
|
||||
aNbKnots = B->NbKnots();
|
||||
BinTools::PutExtChar(OS, (Standard_ExtCharacter) aDegree);
|
||||
BinTools::PutInteger(OS, aNbPoles);
|
||||
BinTools::PutInteger(OS, aNbKnots);
|
||||
for (i = 1; i <= aNbPoles; i++) {
|
||||
OS << B->Pole(i); // Pnt2d
|
||||
if (aRational)
|
||||
BinTools::PutReal(OS, B->Weight(i));
|
||||
}
|
||||
|
||||
for (i = 1; i <= aNbKnots; i++) {
|
||||
BinTools::PutReal(OS, B->Knot(i));
|
||||
BinTools::PutInteger(OS, B->Multiplicity(i));
|
||||
}
|
||||
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom2d_TrimmedCurve)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_TrimmedCurve)& C)
|
||||
{
|
||||
OS << (Standard_Byte)TRIMMED;
|
||||
BinTools::PutReal(OS, C->FirstParameter());
|
||||
BinTools::PutReal(OS, C->LastParameter());
|
||||
BinTools_Curve2dSet::WriteCurve2d(C->BasisCurve(),OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom2d_OffsetCurve)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_OffsetCurve)& C)
|
||||
{
|
||||
OS << (Standard_Byte)OFFSET;
|
||||
BinTools::PutReal(OS,C->Offset());//Offset
|
||||
BinTools_Curve2dSet::WriteCurve2d(C->BasisCurve(),OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WriteCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_Curve2dSet::WriteCurve2d(const Handle(Geom2d_Curve)& C,
|
||||
Standard_OStream& OS)
|
||||
{
|
||||
Standard_SStream aMsg;
|
||||
Handle(Standard_Type) TheType = C->DynamicType();
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
if ( TheType == STANDARD_TYPE(Geom2d_Circle)) {
|
||||
OS << Handle(Geom2d_Circle)::DownCast(C);
|
||||
}
|
||||
else if ( TheType ==STANDARD_TYPE(Geom2d_Line)) {
|
||||
OS << Handle(Geom2d_Line)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_Ellipse)) {
|
||||
OS << Handle(Geom2d_Ellipse)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_Parabola)) {
|
||||
OS << Handle(Geom2d_Parabola)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_Hyperbola)) {
|
||||
OS << Handle(Geom2d_Hyperbola)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_BezierCurve)) {
|
||||
OS << Handle(Geom2d_BezierCurve)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_BSplineCurve)) {
|
||||
OS << Handle(Geom2d_BSplineCurve)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
|
||||
OS << Handle(Geom2d_TrimmedCurve)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom2d_OffsetCurve)) {
|
||||
OS << Handle(Geom2d_OffsetCurve)::DownCast(C);
|
||||
}
|
||||
else {
|
||||
aMsg << "UNKNOWN CURVE2d TYPE" << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
aMsg << "EXCEPTION in BinTools_Curve2dSet::WriteCurve2d(..)" << endl;
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
aMsg << anExc << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_Curve2dSet::Write(Standard_OStream& OS)const
|
||||
{
|
||||
Standard_Integer i, aNbCurves = myMap.Extent();
|
||||
OS << "Curve2ds "<< aNbCurves << "\n";
|
||||
for (i = 1; i <= aNbCurves; i++) {
|
||||
WriteCurve2d(Handle(Geom2d_Curve)::DownCast(myMap(i)),OS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadPnt2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS, gp_Pnt2d& P)
|
||||
{
|
||||
Standard_Real X=0.,Y=0.;
|
||||
BinTools::GetReal(IS, X);
|
||||
BinTools::GetReal(IS, 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.;
|
||||
BinTools::GetReal(IS, X);
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetReal(IS, R1);
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetReal(IS, R1);
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetBool(IS, rational);
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i=0,degree=0;
|
||||
// degree;
|
||||
Standard_ExtCharacter aVal='\0';
|
||||
BinTools::GetExtChar(IS, aVal);
|
||||
degree = (Standard_Integer)aVal;
|
||||
|
||||
TColgp_Array1OfPnt2d poles(1,degree+1);
|
||||
TColStd_Array1OfReal weights(1,degree+1);
|
||||
|
||||
for (i = 1; i <= degree+1; i++) {
|
||||
IS >> poles(i);//Pnt2d
|
||||
if (rational)
|
||||
BinTools::GetReal(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;
|
||||
BinTools::GetBool(IS, rational);
|
||||
BinTools::GetBool(IS, periodic);
|
||||
// poles and weights
|
||||
Standard_Integer i=0,degree=0,nbpoles=0,nbknots=0;
|
||||
Standard_ExtCharacter aVal='\0';
|
||||
|
||||
BinTools::GetExtChar(IS, aVal);
|
||||
degree = (Standard_Integer)aVal;
|
||||
|
||||
BinTools::GetInteger(IS, nbpoles);
|
||||
|
||||
BinTools::GetInteger(IS, nbknots);
|
||||
|
||||
TColgp_Array1OfPnt2d poles(1,nbpoles);
|
||||
TColStd_Array1OfReal weights(1,nbpoles);
|
||||
|
||||
for (i = 1; i <= nbpoles; i++) {
|
||||
IS >> poles(i);//Pnt2d
|
||||
if (rational)
|
||||
BinTools::GetReal(IS, weights(i));
|
||||
}
|
||||
|
||||
TColStd_Array1OfReal knots(1,nbknots);
|
||||
TColStd_Array1OfInteger mults(1,nbknots);
|
||||
|
||||
for (i = 1; i <= nbknots; i++) {
|
||||
BinTools::GetReal(IS, knots(i));
|
||||
BinTools::GetInteger(IS, 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.;
|
||||
BinTools::GetReal(IS, p1);//FirstParameter
|
||||
BinTools::GetReal(IS, p2);//LastParameter
|
||||
Handle(Geom2d_Curve) BC;
|
||||
BinTools_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.;
|
||||
BinTools::GetReal(IS, p);//Offset
|
||||
Handle(Geom2d_Curve) BC;
|
||||
BinTools_Curve2dSet::ReadCurve2d(IS,BC);
|
||||
C = new Geom2d_OffsetCurve(BC,p);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& BinTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS,
|
||||
Handle(Geom2d_Curve)& C)
|
||||
{
|
||||
Standard_SStream aMsg;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
const Standard_Byte ctype = (Standard_Byte) IS.get();
|
||||
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:
|
||||
{
|
||||
C = NULL;
|
||||
aMsg << "UNKNOWN CURVE2d TYPE" << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
C = NULL;
|
||||
aMsg <<"EXCEPTION in BinTools_Curve2dSet::ReadCurve2d(...)" << endl;
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
aMsg << anExc << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_Curve2dSet::Read(Standard_IStream& IS)
|
||||
{
|
||||
char buffer[255];
|
||||
#ifdef DEB
|
||||
// const Standard_Integer aPos = IS.tellg();
|
||||
// cout << "\tPosition of Curves2d section = " << aPos << endl;
|
||||
#endif
|
||||
IS >> buffer;
|
||||
if (IS.fail() || strcmp(buffer,"Curve2ds")) {
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "BinTools_Curve2dSet::Read: Not a Curve2d table"<<endl;
|
||||
#ifdef DEB
|
||||
cout <<"Curve2dSet buffer: " << buffer << endl;
|
||||
#endif
|
||||
Standard_Failure::Raise(aMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom2d_Curve) C;
|
||||
Standard_Integer i, aNbCurves;
|
||||
IS >> aNbCurves;
|
||||
IS.get();//remove <lf>
|
||||
for (i = 1; i <= aNbCurves; i++) {
|
||||
BinTools_Curve2dSet::ReadCurve2d(IS,C);
|
||||
myMap.Add(C);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
75
src/BinTools/BinTools_CurveSet.cdl
Executable file
75
src/BinTools/BinTools_CurveSet.cdl
Executable file
@@ -0,0 +1,75 @@
|
||||
-- File: BinTools_CurveSet.cdl
|
||||
-- Created: Thu May 20 11:41:05 2004
|
||||
-- Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
-- Copyright: Open CasCade S.A. 2004
|
||||
|
||||
|
||||
class CurveSet from BinTools
|
||||
|
||||
---Purpose: Stores a set of Curves from Geom in binary format.
|
||||
|
||||
uses
|
||||
Curve from Geom,
|
||||
IndexedMapOfTransient from TColStd
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
Create returns CurveSet from BinTools;
|
||||
---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;
|
||||
|
||||
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
|
||||
--
|
||||
|
||||
WriteCurve(myclass; C : Curve from Geom;
|
||||
OS : in out OStream);
|
||||
---Purpose: Dumps the curve on the stream in binary 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 written with the Write
|
||||
-- method
|
||||
--
|
||||
---C++: return &
|
||||
|
||||
fields
|
||||
|
||||
myMap : IndexedMapOfTransient from TColStd;
|
||||
|
||||
end CurveSet;
|
732
src/BinTools/BinTools_CurveSet.cxx
Executable file
732
src/BinTools/BinTools_CurveSet.cxx
Executable file
@@ -0,0 +1,732 @@
|
||||
// File: BinTools_CurveSet.cxx
|
||||
// Created: Thu May 20 11:48:00 2004
|
||||
// Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
// Copyright: Open CasCade S.A. 2004
|
||||
|
||||
|
||||
#include <BinTools_CurveSet.ixx>
|
||||
#include <BinTools.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>
|
||||
|
||||
#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 : BinTools_CurveSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BinTools_CurveSet::BinTools_CurveSet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_CurveSet::Clear()
|
||||
{
|
||||
myMap.Clear();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BinTools_CurveSet::Add(const Handle(Geom_Curve)& C)
|
||||
{
|
||||
return (C.IsNull()) ? 0 : myMap.Add(C);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Curve) BinTools_CurveSet::Curve
|
||||
(const Standard_Integer I)const
|
||||
{
|
||||
if (I == 0) {
|
||||
Handle(Geom_Curve) dummy;
|
||||
return dummy;
|
||||
}
|
||||
else
|
||||
return Handle(Geom_Curve)::DownCast(myMap(I));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Index
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BinTools_CurveSet::Index
|
||||
(const Handle(Geom_Curve)& S)const
|
||||
{
|
||||
return S.IsNull() ? 0 : myMap.FindIndex(S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << (gp_Pnt)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const gp_Pnt P)
|
||||
{
|
||||
BinTools::PutReal(OS, P.X());
|
||||
BinTools::PutReal(OS, P.Y());
|
||||
BinTools::PutReal(OS, P.Z());
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << (gp_Dir)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const gp_Dir D)
|
||||
{
|
||||
BinTools::PutReal(OS, D.X());
|
||||
BinTools::PutReal(OS, D.Y());
|
||||
BinTools::PutReal(OS, D.Z());
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << (Geom_Line)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_Line)& L)
|
||||
{
|
||||
OS << (Standard_Byte)LINE;
|
||||
gp_Lin C = L->Lin();
|
||||
OS << C.Location();//Pnt
|
||||
OS << C.Direction();//Dir
|
||||
return OS;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_Circle)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_Circle)& CC)
|
||||
{
|
||||
OS << (Standard_Byte)CIRCLE;
|
||||
gp_Circ C = CC->Circ();
|
||||
OS << C.Location();
|
||||
OS << C.Axis().Direction();
|
||||
OS << C.XAxis().Direction();
|
||||
OS << C.YAxis().Direction();
|
||||
BinTools::PutReal(OS, C.Radius());
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_Ellipse)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_Ellipse)& E)
|
||||
{
|
||||
OS << (Standard_Byte)ELLIPSE;
|
||||
gp_Elips C = E->Elips();
|
||||
OS << C.Location();
|
||||
OS << C.Axis().Direction();
|
||||
OS << C.XAxis().Direction();
|
||||
OS << C.YAxis().Direction();
|
||||
BinTools::PutReal(OS, C.MajorRadius());
|
||||
BinTools::PutReal(OS, C.MinorRadius());
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_Parabola)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_Parabola)& P)
|
||||
{
|
||||
OS << (Standard_Byte)PARABOLA;
|
||||
gp_Parab C = P->Parab();
|
||||
OS << C.Location();
|
||||
OS << C.Axis().Direction();
|
||||
OS << C.XAxis().Direction();
|
||||
OS << C.YAxis().Direction();
|
||||
BinTools::PutReal(OS, C.Focal());
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_Hyperbola)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_Hyperbola)& H)
|
||||
{
|
||||
OS << (Standard_Byte)HYPERBOLA;
|
||||
gp_Hypr C = H->Hypr();
|
||||
OS << C.Location();
|
||||
OS << C.Axis().Direction();
|
||||
OS << C.XAxis().Direction();
|
||||
OS << C.YAxis().Direction();
|
||||
BinTools::PutReal(OS, C.MajorRadius());
|
||||
BinTools::PutReal(OS, C.MinorRadius());
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_BezierCurve)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_BezierCurve)& B)
|
||||
{
|
||||
OS << (Standard_Byte)BEZIER;
|
||||
Standard_Boolean aRational = B->IsRational() ? 1:0;
|
||||
BinTools::PutBool(OS, aRational); //rational
|
||||
// poles and weights
|
||||
Standard_Integer i,aDegree = B->Degree();
|
||||
BinTools::PutExtChar(OS, (Standard_ExtCharacter)aDegree); //<< Degree
|
||||
for (i = 1; i <= aDegree+1; i++) {
|
||||
OS << B->Pole(i); //Pnt
|
||||
if (aRational)
|
||||
BinTools::PutReal(OS, B->Weight(i));//Real
|
||||
}
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_BSplineCurve)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_BSplineCurve)& B)
|
||||
{
|
||||
OS << (Standard_Byte)BSPLINE;
|
||||
Standard_Boolean aRational = B->IsRational() ? 1:0;
|
||||
BinTools::PutBool(OS, aRational); //rational
|
||||
Standard_Boolean aPeriodic = B->IsPeriodic() ? 1:0;
|
||||
BinTools::PutBool(OS, aPeriodic); //periodic
|
||||
// poles and weights
|
||||
Standard_Integer i,aDegree,aNbPoles,aNbKnots;
|
||||
aDegree = B->Degree();
|
||||
aNbPoles = B->NbPoles();
|
||||
aNbKnots = B->NbKnots();
|
||||
BinTools::PutExtChar(OS, (Standard_ExtCharacter) aDegree);
|
||||
BinTools::PutInteger(OS, aNbPoles);
|
||||
BinTools::PutInteger(OS, aNbKnots);
|
||||
for (i = 1; i <= aNbPoles; i++) {
|
||||
OS << B->Pole(i); // Pnt
|
||||
if (aRational)
|
||||
BinTools::PutReal(OS, B->Weight(i));
|
||||
}
|
||||
|
||||
for (i = 1; i <= aNbKnots; i++) {
|
||||
BinTools::PutReal(OS, B->Knot(i));
|
||||
BinTools::PutInteger(OS, B->Multiplicity(i));
|
||||
}
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_TrimmedCurve)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_TrimmedCurve)& C)
|
||||
{
|
||||
OS << (Standard_Byte)TRIMMED;
|
||||
BinTools::PutReal(OS, C->FirstParameter());
|
||||
BinTools::PutReal(OS, C->LastParameter());
|
||||
BinTools_CurveSet::WriteCurve(C->BasisCurve(),OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_OffsetCurve)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_OffsetCurve)& C)
|
||||
{
|
||||
OS << (Standard_Byte)OFFSET;
|
||||
BinTools::PutReal(OS,C->Offset());//Offset
|
||||
OS << C->Direction();
|
||||
BinTools_CurveSet::WriteCurve(C->BasisCurve(),OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_CurveSet::WriteCurve(const Handle(Geom_Curve)& C,
|
||||
Standard_OStream& OS)
|
||||
{
|
||||
Standard_SStream aMsg;
|
||||
Handle(Standard_Type) TheType = C->DynamicType();
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
if ( TheType ==STANDARD_TYPE(Geom_Line)) {
|
||||
OS << Handle(Geom_Line)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_Circle)) {
|
||||
OS << Handle(Geom_Circle)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_Ellipse)) {
|
||||
OS << Handle(Geom_Ellipse)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_Parabola)) {
|
||||
OS << Handle(Geom_Parabola)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_Hyperbola)) {
|
||||
OS << Handle(Geom_Hyperbola)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_BezierCurve)) {
|
||||
OS << Handle(Geom_BezierCurve)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_BSplineCurve)) {
|
||||
OS << Handle(Geom_BSplineCurve)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_TrimmedCurve)) {
|
||||
OS << Handle(Geom_TrimmedCurve)::DownCast(C);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_OffsetCurve)) {
|
||||
OS << Handle(Geom_OffsetCurve)::DownCast(C);
|
||||
}
|
||||
else {
|
||||
aMsg << "UNKNOWN CURVE TYPE" <<endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
aMsg << "EXCEPTION in BinTools_CurveSet::WriteCurve(..)" << endl;
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
aMsg << anExc << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_CurveSet::Write(Standard_OStream& OS)const
|
||||
{
|
||||
Standard_Integer i, nbsurf = myMap.Extent();
|
||||
OS << "Curves "<< nbsurf << "\n";
|
||||
for (i = 1; i <= nbsurf; i++) {
|
||||
WriteCurve(Handle(Geom_Curve)::DownCast(myMap(i)),OS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadPnt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS, gp_Pnt& P)
|
||||
{
|
||||
Standard_Real X=0.,Y=0.,Z=0.;
|
||||
BinTools::GetReal(IS, X);
|
||||
BinTools::GetReal(IS, Y);
|
||||
BinTools::GetReal(IS, 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.;
|
||||
BinTools::GetReal(IS, X);
|
||||
BinTools::GetReal(IS, Y);
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetReal(IS, R1);
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetReal(IS, R1);
|
||||
BinTools::GetReal(IS, 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;
|
||||
BinTools::GetBool(IS, rational);
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i=0,degree=0;
|
||||
// degree;
|
||||
Standard_ExtCharacter aVal='\0';
|
||||
BinTools::GetExtChar(IS, aVal);
|
||||
degree = (Standard_Integer)aVal;
|
||||
|
||||
TColgp_Array1OfPnt poles(1,degree+1);
|
||||
TColStd_Array1OfReal weights(1,degree+1);
|
||||
|
||||
for (i = 1; i <= degree+1; i++) {
|
||||
IS >> poles(i);//Pnt
|
||||
if (rational)
|
||||
// weights(i);
|
||||
BinTools::GetReal(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;
|
||||
BinTools::GetBool(IS, rational);
|
||||
BinTools::GetBool(IS, periodic);
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i=0,degree=0,nbpoles=0,nbknots=0;
|
||||
Standard_ExtCharacter aVal='\0';
|
||||
BinTools::GetExtChar(IS, aVal);
|
||||
degree = (Standard_Integer)aVal;
|
||||
|
||||
BinTools::GetInteger(IS, nbpoles);
|
||||
|
||||
BinTools::GetInteger(IS, nbknots);
|
||||
|
||||
TColgp_Array1OfPnt poles(1,nbpoles);
|
||||
TColStd_Array1OfReal weights(1,nbpoles);
|
||||
|
||||
for (i = 1; i <= nbpoles; i++) {
|
||||
IS >> poles(i);//Pnt
|
||||
if (rational)
|
||||
BinTools::GetReal(IS, weights(i));
|
||||
}
|
||||
|
||||
TColStd_Array1OfReal knots(1,nbknots);
|
||||
TColStd_Array1OfInteger mults(1,nbknots);
|
||||
|
||||
for (i = 1; i <= nbknots; i++) {
|
||||
BinTools::GetReal(IS, knots(i));
|
||||
BinTools::GetInteger(IS, 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.;
|
||||
BinTools::GetReal(IS, p1);//FirstParameter
|
||||
BinTools::GetReal(IS, p2);//LastParameter
|
||||
Handle(Geom_Curve) BC;
|
||||
BinTools_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.;
|
||||
BinTools::GetReal(IS, p);//Offset
|
||||
gp_Dir D(1.,0.,0.);
|
||||
IS >> D;
|
||||
Handle(Geom_Curve) BC;
|
||||
BinTools_CurveSet::ReadCurve(IS,BC);
|
||||
C = new Geom_OffsetCurve(BC,p,D);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& BinTools_CurveSet::ReadCurve(Standard_IStream& IS,
|
||||
Handle(Geom_Curve)& C)
|
||||
{
|
||||
Standard_SStream aMsg;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
const Standard_Byte ctype = (Standard_Byte) IS.get();
|
||||
|
||||
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:
|
||||
{
|
||||
C = NULL;
|
||||
aMsg << "UNKNOWN CURVE TYPE" << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
C = NULL;
|
||||
aMsg <<"EXCEPTION in BinTools_CurveSet::ReadCurve(..)" << endl;
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_CurveSet::Read(Standard_IStream& IS)
|
||||
{
|
||||
char buffer[255];
|
||||
IS >> buffer;
|
||||
if (IS.fail() || strcmp(buffer,"Curves")) {
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "BinTools_CurveSet::Read: Not a Curve table"<<endl;
|
||||
#ifdef DEB
|
||||
cout <<"CurveSet buffer: " << buffer << endl;
|
||||
#endif
|
||||
Standard_Failure::Raise(aMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom_Curve) C;
|
||||
Standard_Integer i, nbcurve;
|
||||
IS >> nbcurve;
|
||||
|
||||
IS.get();//remove <lf>
|
||||
for (i = 1; i <= nbcurve; i++) {
|
||||
BinTools_CurveSet::ReadCurve(IS,C);
|
||||
myMap.Add(C);
|
||||
}
|
||||
}
|
||||
|
||||
|
68
src/BinTools/BinTools_LocationSet.cdl
Executable file
68
src/BinTools/BinTools_LocationSet.cdl
Executable file
@@ -0,0 +1,68 @@
|
||||
-- File: BinTools_LocationSet.cdl
|
||||
-- Created: Tue Jun 15 12:01:40 2004
|
||||
-- Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
-- Copyright: Open CasCade S.A. 2004
|
||||
|
||||
class LocationSet from BinTools
|
||||
|
||||
---Purpose: The class LocationSet stores a set of location in
|
||||
-- a relocatable state.
|
||||
--
|
||||
-- It can be created from Locations.
|
||||
--
|
||||
-- It can create Locations.
|
||||
|
||||
|
||||
uses
|
||||
Location from TopLoc,
|
||||
IndexedMapOfLocation from TopLoc
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
Create returns LocationSet from BinTools;
|
||||
---Purpose: Returns an empty set of locations.
|
||||
|
||||
Clear(me : in out)
|
||||
---Purpose: Clears the content of the set.
|
||||
is static;
|
||||
|
||||
Add(me : in out; L : Location from TopLoc) returns Integer
|
||||
---Purpose: Incorporate a new Location in the set and returns
|
||||
-- its index.
|
||||
is static;
|
||||
|
||||
Location(me; I : Integer) returns Location from TopLoc
|
||||
---Purpose: Returns the location of index <I>.
|
||||
--
|
||||
---C++: return const &
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
is static;
|
||||
|
||||
Index(me; L : Location from TopLoc) returns Integer
|
||||
---Purpose: Returns the index of <L>.
|
||||
is static;
|
||||
|
||||
NbLocations(me) returns Integer
|
||||
---Purpose: Returns number of locations.
|
||||
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;
|
||||
|
||||
fields
|
||||
|
||||
myMap : IndexedMapOfLocation from TopLoc;
|
||||
|
||||
end LocationSet;
|
||||
|
256
src/BinTools/BinTools_LocationSet.cxx
Executable file
256
src/BinTools/BinTools_LocationSet.cxx
Executable file
@@ -0,0 +1,256 @@
|
||||
// File: BinTools_LocationSet.cxx
|
||||
// Created: Tue Jun 15 12:04:06 2004
|
||||
// Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
// Copyright: Open CasCade S.A. 2004
|
||||
|
||||
#include <BinTools_LocationSet.ixx>
|
||||
#include <BinTools.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : operator >> (gp_Trsf& T)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_IStream& operator >>(Standard_IStream& IS, gp_Trsf& T)
|
||||
{
|
||||
Standard_Real V1[3],V2[3],V3[3];
|
||||
Standard_Real V[3];
|
||||
|
||||
BinTools::GetReal(IS, V1[0]);
|
||||
BinTools::GetReal(IS, V1[1]);
|
||||
BinTools::GetReal(IS, V1[2]);
|
||||
BinTools::GetReal(IS, V[0]);
|
||||
|
||||
BinTools::GetReal(IS, V2[0]);
|
||||
BinTools::GetReal(IS, V2[1]);
|
||||
BinTools::GetReal(IS, V2[2]);
|
||||
BinTools::GetReal(IS, V[1]);
|
||||
|
||||
BinTools::GetReal(IS, V3[0]);
|
||||
BinTools::GetReal(IS, V3[1]);
|
||||
BinTools::GetReal(IS, V3[2]);
|
||||
BinTools::GetReal(IS, V[2]);
|
||||
|
||||
T.SetValues(V1[0],V1[1],V1[2],V[0],
|
||||
V2[0],V2[1],V2[2],V[1],
|
||||
V3[0],V3[1],V3[2],V[2],
|
||||
Precision::Angular(),
|
||||
Precision::Confusion());
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << (gp_Trsf& T)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS,const gp_Trsf& T)
|
||||
{
|
||||
gp_XYZ V = T.TranslationPart();
|
||||
gp_Mat M = T.VectorialPart();
|
||||
|
||||
BinTools::PutReal(OS, M(1,1));
|
||||
BinTools::PutReal(OS, M(1,2));
|
||||
BinTools::PutReal(OS, M(1,3));
|
||||
BinTools::PutReal(OS,V.Coord(1));
|
||||
|
||||
BinTools::PutReal(OS, M(2,1));
|
||||
BinTools::PutReal(OS, M(2,2));
|
||||
BinTools::PutReal(OS, M(2,3));
|
||||
BinTools::PutReal(OS,V.Coord(2));
|
||||
|
||||
BinTools::PutReal(OS, M(3,1));
|
||||
BinTools::PutReal(OS, M(3,2));
|
||||
BinTools::PutReal(OS, M(3,3));
|
||||
BinTools::PutReal(OS,V.Coord(3));
|
||||
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BinTools_LocationSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BinTools_LocationSet::BinTools_LocationSet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_LocationSet::Clear()
|
||||
{
|
||||
myMap.Clear();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BinTools_LocationSet::Add(const TopLoc_Location& L)
|
||||
{
|
||||
if (L.IsIdentity()) return 0;
|
||||
Standard_Integer n = myMap.FindIndex(L);
|
||||
if (n > 0) return n;
|
||||
TopLoc_Location N = L;
|
||||
do {
|
||||
myMap.Add(N.FirstDatum());
|
||||
N = N.NextLocation();
|
||||
} while (!N.IsIdentity());
|
||||
return myMap.Add(L);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Location
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopLoc_Location& BinTools_LocationSet::Location
|
||||
(const Standard_Integer I)const
|
||||
{
|
||||
static TopLoc_Location identity;
|
||||
if (I == 0) return identity;
|
||||
else return myMap(I);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Index
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BinTools_LocationSet::Index(const TopLoc_Location& L) const
|
||||
{
|
||||
if (L.IsIdentity()) return 0;
|
||||
return myMap.FindIndex(L);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbLocations
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BinTools_LocationSet::NbLocations() const
|
||||
{
|
||||
return myMap.Extent();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write locations
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_LocationSet::Write(Standard_OStream& OS) const
|
||||
{
|
||||
|
||||
Standard_Integer i, nbLoc = myMap.Extent();
|
||||
OS << "Locations "<< nbLoc <<endl;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
for (i = 1; i <= nbLoc; i++) {
|
||||
TopLoc_Location L = myMap(i);
|
||||
|
||||
TopLoc_Location L2 = L.NextLocation();
|
||||
Standard_Boolean simple = L2.IsIdentity();
|
||||
Standard_Integer p = L.FirstPower();
|
||||
TopLoc_Location L1 = L.FirstDatum();
|
||||
Standard_Boolean elementary = (simple && p == 1);
|
||||
if (elementary) {
|
||||
|
||||
OS.put((Standard_Byte)1); // 1
|
||||
OS << L.Transformation();
|
||||
}
|
||||
else {
|
||||
OS.put((Standard_Byte)2); // 2
|
||||
BinTools::PutInteger(OS, myMap.FindIndex(L1));
|
||||
BinTools::PutInteger(OS, p);
|
||||
while (!L2.IsIdentity()) {
|
||||
L1 = L2.FirstDatum();
|
||||
p = L2.FirstPower();
|
||||
L2 = L2.NextLocation();
|
||||
BinTools::PutInteger(OS, myMap.FindIndex(L1));
|
||||
BinTools::PutInteger(OS, p);
|
||||
}
|
||||
|
||||
BinTools::PutInteger(OS, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "EXCEPTION in BinTools_LocatioSet::Write(..)" << endl;
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
aMsg << anExc << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinTools_LocationSet::Read(Standard_IStream& IS)
|
||||
{
|
||||
|
||||
myMap.Clear();
|
||||
char buffer[255];
|
||||
Standard_Integer l1,p;
|
||||
|
||||
IS >> buffer;
|
||||
if (IS.fail() || (strcmp(buffer,"Locations"))) {
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "BinTools_LocationSet::Read: Not a location table"<<endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Integer i, nbLoc;
|
||||
IS >> nbLoc;
|
||||
IS.get();// remove lf
|
||||
TopLoc_Location L;
|
||||
gp_Trsf T;
|
||||
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
for (i = 1; i <= nbLoc; i++) {
|
||||
|
||||
const Standard_Byte aTypLoc = IS.get();
|
||||
if (aTypLoc == 1) {
|
||||
IS >> T;
|
||||
L = T;
|
||||
}
|
||||
|
||||
else if (aTypLoc == 2) {
|
||||
L = TopLoc_Location();
|
||||
BinTools::GetInteger(IS, l1); //Index
|
||||
while (l1 != 0) {
|
||||
BinTools::GetInteger(IS, p);
|
||||
TopLoc_Location L1 = myMap(l1);
|
||||
L = L1.Powered(p) *L;
|
||||
BinTools::GetInteger(IS, l1);
|
||||
}
|
||||
} else {
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "Unexpected location's type = " << aTypLoc << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
if (!L.IsIdentity()) myMap.Add(L);
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "EXCEPTION in BinTools_LocationSet::Read(..)" << endl;
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
aMsg << anExc << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
196
src/BinTools/BinTools_ShapeSet.cdl
Executable file
196
src/BinTools/BinTools_ShapeSet.cdl
Executable file
@@ -0,0 +1,196 @@
|
||||
-- File: BinTools_ShapeSet.cdl
|
||||
-- Created: Tue May 11 18:04:54 2004
|
||||
-- Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
-- Copyright: Open CasCade S.A. 2004
|
||||
|
||||
|
||||
class ShapeSet from BinTools
|
||||
|
||||
---Purpose: Writes topology in OStream in binary format
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
IndexedMapOfShape from TopTools,
|
||||
ShapeEnum from TopAbs,
|
||||
Builder from BRep,
|
||||
ShapeEnum from TopAbs,
|
||||
LocationSet from BinTools,
|
||||
SurfaceSet from BinTools,
|
||||
CurveSet from BinTools,
|
||||
Curve2dSet from BinTools,
|
||||
IndexedMapOfTransient from TColStd
|
||||
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create(isWithTriangles: Boolean from Standard = Standard_False)
|
||||
returns ShapeSet from BinTools;
|
||||
---Purpose: Builds an empty ShapeSet.
|
||||
-- Parameter <isWithTriangles> is added for XML Persistence
|
||||
|
||||
Delete(me:out) is virtual;
|
||||
---C++: alias "Standard_EXPORT virtual ~BinTools_ShapeSet(){Delete() ; }"
|
||||
|
||||
SetFormatNb(me : out; theFormatNb : Integer) is static;
|
||||
|
||||
FormatNb(me) returns Integer is static;
|
||||
---Purpose: two formats available for the moment:
|
||||
-- First: does not write CurveOnSurface UV Points into the file
|
||||
-- on reading calls Check() method.
|
||||
-- Second: stores CurveOnSurface UV Points.
|
||||
-- On reading format is recognized from Version string.
|
||||
|
||||
Clear(me : in out)
|
||||
---Purpose: Clears the content of the set.
|
||||
is virtual;
|
||||
|
||||
Add(me : in out; S : Shape from TopoDS) returns Integer
|
||||
---Purpose: Stores <S> and its sub-shape. Returns the index of <S>.
|
||||
-- The method AddGeometry is called on each sub-shape.
|
||||
is static;
|
||||
|
||||
Shape(me; I : Integer) returns Shape from TopoDS
|
||||
---Purpose: Returns the sub-shape of index <I>.
|
||||
--
|
||||
---C++: return const &
|
||||
is static;
|
||||
|
||||
Index(me; S : Shape from TopoDS) returns Integer
|
||||
---Purpose: Returns the index of <S>.
|
||||
is static;
|
||||
|
||||
Locations(me) returns LocationSet from BinTools
|
||||
---C++: return const &
|
||||
is static;
|
||||
|
||||
ChangeLocations(me : in out) returns LocationSet from BinTools
|
||||
---C++: return &
|
||||
is static;
|
||||
|
||||
NbShapes(me) returns Integer;
|
||||
---Purpose:Returns number of shapes read from file.
|
||||
|
||||
Write(me; OS : in out OStream)
|
||||
---Purpose: Writes the content of me on the stream <OS> in binary
|
||||
-- format that can be read back by Read.
|
||||
--
|
||||
-- Writes the locations.
|
||||
--
|
||||
-- Writes the geometry calling WriteGeometry.
|
||||
--
|
||||
-- Dumps the shapes from last to first.
|
||||
-- For each shape :
|
||||
-- Write the type.
|
||||
-- calls WriteGeometry(S).
|
||||
-- Write the flags, the subshapes.
|
||||
is virtual;
|
||||
|
||||
Read(me : in out; IS : in out IStream)
|
||||
---Purpose: Reads the content of me from the binary stream <IS>. me
|
||||
-- is first cleared.
|
||||
--
|
||||
-- Reads the locations.
|
||||
--
|
||||
-- Reads the geometry calling ReadGeometry.
|
||||
--
|
||||
-- Reads the shapes.
|
||||
-- For each shape
|
||||
-- Reads the type.
|
||||
-- calls ReadGeometry(T,S).
|
||||
-- Reads the flag, the subshapes.
|
||||
is virtual;
|
||||
|
||||
Write(me; S : Shape from TopoDS; OS : in out OStream)
|
||||
---Purpose: Writes on <OS> the shape <S>. Writes the
|
||||
-- orientation, the index of the TShape and the index
|
||||
-- of the Location.
|
||||
is virtual;
|
||||
|
||||
WriteGeometry(me; OS : in out OStream)
|
||||
---Purpose: Writes the geometry of me on the stream <OS> in a
|
||||
-- binary format that can be read back by Read.
|
||||
is virtual;
|
||||
|
||||
ReadGeometry(me : in out; IS : in out IStream)
|
||||
---Purpose: Reads the geometry of me from the stream <IS>.
|
||||
is virtual;
|
||||
|
||||
Read(me; S : in out Shape from TopoDS; IS : in out IStream;
|
||||
NbShapes : Integer)
|
||||
---Purpose: Reads from <IS> a shape and returns it in S.
|
||||
-- <NbShapes> is the number of tshapes in the set.
|
||||
is virtual;
|
||||
|
||||
WriteGeometry(me; S : Shape from TopoDS; OS : in out OStream)
|
||||
---Purpose: Writes the geometry of <S> on the stream <OS> in a
|
||||
-- binary format that can be read back by Read.
|
||||
is virtual;
|
||||
|
||||
ReadGeometry(me : in out; T : ShapeEnum from TopAbs;
|
||||
IS : in out IStream;
|
||||
S : out Shape from TopoDS)
|
||||
---Purpose: Reads the geometry of a shape of type <T> from the
|
||||
-- stream <IS> and returns it in <S>.
|
||||
is virtual;
|
||||
|
||||
AddGeometry(me : in out; S : Shape from TopoDS)
|
||||
---Purpose: Stores the goemetry of <S>.
|
||||
is virtual;
|
||||
|
||||
-- WriteLocations(me; OS: in out OStream from Standard) is static;
|
||||
|
||||
-- ReadLocations(me: in out; OS: in out IStream from Standard) is static;
|
||||
|
||||
AddShapes(me : in out; S1 : in out Shape from TopoDS;
|
||||
S2 : Shape from TopoDS)
|
||||
---Purpose: Inserts the shape <S2> in the shape <S1>.
|
||||
is virtual;
|
||||
|
||||
ReadPolygon3D(me: in out; IS: in out IStream)
|
||||
---Purpose: Reads the 3d polygons of me
|
||||
-- from the stream <IS>.
|
||||
is static;
|
||||
|
||||
WritePolygon3D(me; OS: in out OStream)
|
||||
---Purpose: Writes the 3d polygons
|
||||
-- on the stream <OS> in a format that can
|
||||
-- be read back by Read.
|
||||
is static;
|
||||
|
||||
ReadTriangulation(me: in out; IS: in out IStream)
|
||||
---Purpose: Reads the triangulation of me
|
||||
-- from the stream <IS>.
|
||||
is static;
|
||||
|
||||
WriteTriangulation(me; OS: in out OStream)
|
||||
---Purpose: Writes the triangulation
|
||||
-- on the stream <OS> in a format that can
|
||||
-- be read back by Read.
|
||||
is static;
|
||||
|
||||
ReadPolygonOnTriangulation(me: in out; IS: in out IStream)
|
||||
---Purpose: Reads the polygons on triangulation of me
|
||||
-- from the stream <IS>.
|
||||
is static;
|
||||
|
||||
WritePolygonOnTriangulation(me; OS: in out OStream)
|
||||
---Purpose: Writes the polygons on triangulation
|
||||
-- on the stream <OS> in a format that can
|
||||
-- be read back by Read.
|
||||
is static;
|
||||
|
||||
fields
|
||||
myShapes : IndexedMapOfShape from TopTools;
|
||||
myLocations : LocationSet from BinTools;
|
||||
myFormatNb : Integer from Standard; -- jfa 26.09.2001
|
||||
myBuilder : Builder from BRep;
|
||||
mySurfaces : SurfaceSet from BinTools;
|
||||
myCurves : CurveSet from BinTools;
|
||||
myCurves2d : Curve2dSet from BinTools;
|
||||
myPolygons2D: IndexedMapOfTransient from TColStd;
|
||||
myPolygons3D: IndexedMapOfTransient from TColStd;
|
||||
myTriangulations: IndexedMapOfTransient from TColStd;
|
||||
myNodes : IndexedMapOfTransient from TColStd;
|
||||
myWithTriangles: Boolean from Standard;
|
||||
end ShapeSet;
|
1516
src/BinTools/BinTools_ShapeSet.cxx
Executable file
1516
src/BinTools/BinTools_ShapeSet.cxx
Executable file
File diff suppressed because it is too large
Load Diff
75
src/BinTools/BinTools_SurfaceSet.cdl
Executable file
75
src/BinTools/BinTools_SurfaceSet.cdl
Executable file
@@ -0,0 +1,75 @@
|
||||
-- File: BinTools_SurfaceSet.cdl
|
||||
-- Created: Thu May 20 14:33:11 2004
|
||||
-- Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
-- Copyright: Open CasCade S.A. 2004
|
||||
|
||||
|
||||
class SurfaceSet from BinTools
|
||||
|
||||
---Purpose: Stores a set of Surfaces from Geom in binary format.
|
||||
|
||||
uses
|
||||
Surface from Geom,
|
||||
IndexedMapOfTransient from TColStd
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
Create returns SurfaceSet from BinTools;
|
||||
---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;
|
||||
|
||||
Write(me; OS : in out OStream)
|
||||
---Purpose: Writes the content of me on the stream <OS> in
|
||||
-- binary 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
|
||||
--
|
||||
|
||||
WriteSurface(myclass; S : Surface from Geom;
|
||||
OS : in out OStream);
|
||||
---Purpose: Dumps the surface on the stream in binary
|
||||
-- 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 written with the Write
|
||||
-- method.
|
||||
--
|
||||
---C++: return &
|
||||
|
||||
fields
|
||||
|
||||
myMap : IndexedMapOfTransient from TColStd;
|
||||
|
||||
end SurfaceSet;
|
910
src/BinTools/BinTools_SurfaceSet.cxx
Executable file
910
src/BinTools/BinTools_SurfaceSet.cxx
Executable file
@@ -0,0 +1,910 @@
|
||||
// File: BinTools_SurfaceSet.cxx
|
||||
// Created: Thu May 20 14:39:42 2004
|
||||
// Author: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
// Copyright: Open CasCade S.A. 2004
|
||||
|
||||
|
||||
#include <BinTools_SurfaceSet.ixx>
|
||||
#include <BinTools.hxx>
|
||||
|
||||
#include <BinTools_CurveSet.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_ConicalSurface.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <Geom_ToroidalSurface.hxx>
|
||||
#include <Geom_SurfaceOfLinearExtrusion.hxx>
|
||||
#include <Geom_SurfaceOfRevolution.hxx>
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_OffsetSurface.hxx>
|
||||
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Cylinder.hxx>
|
||||
#include <gp_Cone.hxx>
|
||||
#include <gp_Sphere.hxx>
|
||||
#include <gp_Torus.hxx>
|
||||
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
|
||||
#define PLANE 1
|
||||
#define CYLINDER 2
|
||||
#define CONE 3
|
||||
#define SPHERE 4
|
||||
#define TORUS 5
|
||||
#define LINEAREXTRUSION 6
|
||||
#define REVOLUTION 7
|
||||
#define BEZIER 8
|
||||
#define BSPLINE 9
|
||||
#define RECTANGULAR 10
|
||||
#define OFFSET 11
|
||||
|
||||
//=======================================================================
|
||||
//function : BinTools_SurfaceSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BinTools_SurfaceSet::BinTools_SurfaceSet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_SurfaceSet::Clear()
|
||||
{
|
||||
myMap.Clear();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BinTools_SurfaceSet::Add(const Handle(Geom_Surface)& S)
|
||||
{
|
||||
return myMap.Add(S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Surface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Surface) BinTools_SurfaceSet::Surface
|
||||
(const Standard_Integer I)const
|
||||
{
|
||||
return Handle(Geom_Surface)::DownCast(myMap(I));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Index
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BinTools_SurfaceSet::Index
|
||||
(const Handle(Geom_Surface)& S)const
|
||||
{
|
||||
return myMap.FindIndex(S);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << (gp_Pnt)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const gp_Pnt P)
|
||||
{
|
||||
BinTools::PutReal(OS, P.X());
|
||||
BinTools::PutReal(OS, P.Y());
|
||||
BinTools::PutReal(OS, P.Z());
|
||||
return OS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator << (gp_Dir)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const gp_Dir D)
|
||||
{
|
||||
BinTools::PutReal(OS, D.X());
|
||||
BinTools::PutReal(OS, D.Y());
|
||||
BinTools::PutReal(OS, D.Z());
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_Plane)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_Plane)& S)
|
||||
{
|
||||
OS << (Standard_Byte)PLANE;
|
||||
gp_Pln P = S->Pln();
|
||||
OS << P.Location();//Pnt
|
||||
OS << P.Axis().Direction();
|
||||
OS << P.XAxis().Direction();
|
||||
OS << P.YAxis().Direction();
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_CylindricalSurface)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_CylindricalSurface)& S)
|
||||
{
|
||||
OS << (Standard_Byte)CYLINDER;
|
||||
gp_Cylinder P = S->Cylinder();
|
||||
OS << P.Location();//Pnt
|
||||
OS << P.Axis().Direction();
|
||||
OS << P.XAxis().Direction();
|
||||
OS << P.YAxis().Direction();
|
||||
BinTools::PutReal(OS, P.Radius());
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_ConicalSurface)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_ConicalSurface)& S)
|
||||
{
|
||||
OS << (Standard_Byte)CONE;
|
||||
gp_Cone P = S->Cone();
|
||||
OS << P.Location();//Pnt
|
||||
OS << P.Axis().Direction();
|
||||
OS << P.XAxis().Direction();
|
||||
OS << P.YAxis().Direction();
|
||||
BinTools::PutReal(OS, P.RefRadius());
|
||||
BinTools::PutReal(OS, P.SemiAngle());
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_SphericalSurface)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_SphericalSurface)& S)
|
||||
{
|
||||
OS << (Standard_Byte)SPHERE;
|
||||
gp_Sphere P = S->Sphere();
|
||||
OS << P.Location();//Pnt
|
||||
OS << P.Position().Axis().Direction();
|
||||
OS << P.XAxis().Direction();
|
||||
OS << P.YAxis().Direction();
|
||||
BinTools::PutReal(OS, P.Radius());
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_ToroidalSurface)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_ToroidalSurface)& S)
|
||||
{
|
||||
OS << (Standard_Byte)TORUS;
|
||||
gp_Torus P = S->Torus();
|
||||
OS << P.Location();//Pnt
|
||||
OS << P.Axis().Direction();
|
||||
OS << P.XAxis().Direction();
|
||||
OS << P.YAxis().Direction();
|
||||
BinTools::PutReal(OS, P.MajorRadius());
|
||||
BinTools::PutReal(OS, P.MinorRadius());
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_SurfaceOfLinearExtrusion)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_SurfaceOfLinearExtrusion)& S)
|
||||
{
|
||||
OS << (Standard_Byte)LINEAREXTRUSION;
|
||||
OS << S->Direction();
|
||||
BinTools_CurveSet::WriteCurve(S->BasisCurve(),OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_SurfaceOfRevolution)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_SurfaceOfRevolution)& S)
|
||||
{
|
||||
OS << (Standard_Byte)REVOLUTION;
|
||||
OS << S->Location();
|
||||
OS << S->Direction();
|
||||
BinTools_CurveSet::WriteCurve(S->BasisCurve(),OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_BezierSurface)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_BezierSurface)& S)
|
||||
{
|
||||
OS << (Standard_Byte)BEZIER;
|
||||
Standard_Boolean urational = S->IsURational() ? 1:0;
|
||||
Standard_Boolean vrational = S->IsVRational() ? 1:0;
|
||||
BinTools::PutBool(OS, urational); //rational
|
||||
BinTools::PutBool(OS, vrational);
|
||||
// cout << "Bezier Surface:"<< endl;
|
||||
// cout << "\turational = "<<urational<<" vrational = " <<vrational<<endl;
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i,j,udegree,vdegree;
|
||||
udegree = S->UDegree();
|
||||
vdegree = S->VDegree();
|
||||
#ifdef DEB
|
||||
// cout << "\tudegree = " << udegree << ", vdegree = "<< vdegree<<endl;
|
||||
#endif
|
||||
BinTools::PutExtChar(OS, (Standard_ExtCharacter)udegree);
|
||||
BinTools::PutExtChar(OS, (Standard_ExtCharacter)vdegree);
|
||||
for (i = 1; i <= udegree+1; i++) {
|
||||
for (j = 1; j <= vdegree+1; j++) {
|
||||
OS << S->Pole(i,j); //Pnt
|
||||
#ifdef DEB
|
||||
// cout << "Bezier Surface: Pole Pnt: X = " << S->Pole(i,j).X()<< " Y = " << S->Pole(i,j).Y()<<" Z = " << S->Pole(i,j).Z()<<endl;
|
||||
#endif
|
||||
if (urational || vrational) {
|
||||
BinTools::PutReal(OS, S->Weight(i,j));//Real
|
||||
#ifdef DEB
|
||||
// cout << "Bezier Surface: Put Real" << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef DEB
|
||||
// const Standard_Integer aPos = OS.tellp();
|
||||
// cout << "\tEnd of Bezier surface pos = " << aPos << endl;
|
||||
#endif
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_BSplineSurface)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_BSplineSurface)& S)
|
||||
{
|
||||
OS << (Standard_Byte)BSPLINE;
|
||||
Standard_Boolean urational = S->IsURational() ? 1:0;
|
||||
Standard_Boolean vrational = S->IsVRational() ? 1:0;
|
||||
Standard_Boolean uperiodic = S->IsUPeriodic() ? 1:0;
|
||||
Standard_Boolean vperiodic = S->IsVPeriodic() ? 1:0;
|
||||
BinTools::PutBool(OS, urational);
|
||||
BinTools::PutBool(OS, vrational);
|
||||
BinTools::PutBool(OS, uperiodic);
|
||||
BinTools::PutBool(OS, vperiodic);
|
||||
|
||||
// poles and weights
|
||||
Standard_Integer i,j,udegree,vdegree,nbupoles,nbvpoles,nbuknots,nbvknots;
|
||||
udegree = S->UDegree();
|
||||
vdegree = S->VDegree();
|
||||
nbupoles = S->NbUPoles();
|
||||
nbvpoles = S->NbVPoles();
|
||||
nbuknots = S->NbUKnots();
|
||||
nbvknots = S->NbVKnots();
|
||||
BinTools::PutExtChar(OS, (Standard_ExtCharacter) udegree);
|
||||
BinTools::PutExtChar(OS, (Standard_ExtCharacter) vdegree);
|
||||
BinTools::PutInteger(OS, nbupoles);
|
||||
BinTools::PutInteger(OS, nbvpoles);
|
||||
BinTools::PutInteger(OS, nbuknots);
|
||||
BinTools::PutInteger(OS, nbvknots);
|
||||
for (i = 1; i <= nbupoles; i++) {
|
||||
for (j = 1; j <= nbvpoles; j++) {
|
||||
OS << S->Pole(i,j); //Pnt
|
||||
if (urational || vrational)
|
||||
BinTools::PutReal(OS, S->Weight(i,j));//Real
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 1; i <= nbuknots; i++) {
|
||||
BinTools::PutReal(OS,S->UKnot(i));
|
||||
BinTools::PutInteger(OS, S->UMultiplicity(i));
|
||||
}
|
||||
|
||||
for (i = 1; i <= nbvknots; i++) {
|
||||
BinTools::PutReal(OS,S->VKnot(i));
|
||||
BinTools::PutInteger(OS, S->VMultiplicity(i));
|
||||
}
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_RectangularTrimmedSurface)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_RectangularTrimmedSurface)& S)
|
||||
{
|
||||
OS << (Standard_Byte)RECTANGULAR;
|
||||
Standard_Real U1,U2,V1,V2;
|
||||
S->Bounds(U1,U2,V1,V2);
|
||||
BinTools::PutReal(OS, U1);
|
||||
BinTools::PutReal(OS, U2);
|
||||
BinTools::PutReal(OS, V1);
|
||||
BinTools::PutReal(OS, V2);
|
||||
BinTools_SurfaceSet::WriteSurface(S->BasisSurface(),OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator <<(Geom_OffsetSurface)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_OffsetSurface)& S)
|
||||
{
|
||||
OS << (Standard_Byte)OFFSET;
|
||||
BinTools::PutReal(OS, S->Offset());
|
||||
BinTools_SurfaceSet::WriteSurface(S->BasisSurface(),OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : WriteSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_SurfaceSet::WriteSurface(const Handle(Geom_Surface)& S,
|
||||
Standard_OStream& OS)
|
||||
{
|
||||
Standard_SStream aMsg;
|
||||
Handle(Standard_Type) TheType = S->DynamicType();
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
if ( TheType == STANDARD_TYPE(Geom_Plane)) {
|
||||
OS << Handle(Geom_Plane)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_CylindricalSurface)) {
|
||||
OS << Handle(Geom_CylindricalSurface)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_ConicalSurface)) {
|
||||
OS << Handle(Geom_ConicalSurface)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_SphericalSurface)) {
|
||||
OS << Handle(Geom_SphericalSurface)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_ToroidalSurface)) {
|
||||
OS << Handle(Geom_ToroidalSurface)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) {
|
||||
OS << Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_SurfaceOfRevolution)) {
|
||||
OS << Handle(Geom_SurfaceOfRevolution)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_BezierSurface)) {
|
||||
OS << Handle(Geom_BezierSurface)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_BSplineSurface)) {
|
||||
OS << Handle(Geom_BSplineSurface)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
|
||||
OS << Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_OffsetSurface)) {
|
||||
OS << Handle(Geom_OffsetSurface)::DownCast(S);
|
||||
}
|
||||
else {
|
||||
aMsg <<"UNKNOWN SURFACE TYPE" <<endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
aMsg << "EXCEPTION in BinTools_SurfaceSet::WriteSurface(..)" << endl;
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
aMsg << anExc << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_SurfaceSet::Write(Standard_OStream& OS)const
|
||||
{
|
||||
|
||||
Standard_Integer i, nbsurf = myMap.Extent();
|
||||
OS << "Surfaces "<< nbsurf << "\n";
|
||||
for (i = 1; i <= nbsurf; i++) {
|
||||
WriteSurface(Handle(Geom_Surface)::DownCast(myMap(i)),OS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadPnt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS, gp_Pnt& P)
|
||||
{
|
||||
Standard_Real X=0.,Y=0.,Z=0.;
|
||||
BinTools::GetReal(IS, X);
|
||||
BinTools::GetReal(IS, Y);
|
||||
BinTools::GetReal(IS, 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.;
|
||||
BinTools::GetReal(IS, X);
|
||||
BinTools::GetReal(IS, Y);
|
||||
BinTools::GetReal(IS, Z);
|
||||
D.SetCoord(X,Y,Z);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadAx3
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS, gp_Ax3& A3)
|
||||
{
|
||||
gp_Pnt P(0.,0.,0.);
|
||||
gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
|
||||
IS >> P >> A >> AX >> AY;
|
||||
gp_Ax3 ax3(P,A,AX);
|
||||
if (AY.DotCross(A,AX) < 0)
|
||||
ax3.YReverse();
|
||||
A3 = ax3;
|
||||
return IS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_Plane)& S)
|
||||
{
|
||||
gp_Ax3 A;
|
||||
IS >> A;
|
||||
S = new Geom_Plane(A);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_CylindricalSurface)& S)
|
||||
{
|
||||
gp_Ax3 A;
|
||||
Standard_Real R=0.;
|
||||
IS >> A;
|
||||
BinTools::GetReal(IS, R);
|
||||
S = new Geom_CylindricalSurface(A,R);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_ConicalSurface)& S)
|
||||
{
|
||||
gp_Ax3 A;
|
||||
Standard_Real R=0.,Ang=0.;
|
||||
IS >> A;
|
||||
BinTools::GetReal(IS, R);
|
||||
BinTools::GetReal(IS, Ang);
|
||||
S = new Geom_ConicalSurface(A,Ang,R);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_SphericalSurface)& S)
|
||||
{
|
||||
gp_Ax3 A;
|
||||
Standard_Real R=0.;
|
||||
IS >> A;
|
||||
BinTools::GetReal(IS, R);
|
||||
S = new Geom_SphericalSurface(A,R);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_ToroidalSurface)& S)
|
||||
{
|
||||
gp_Ax3 A;
|
||||
Standard_Real R1=0.,R2=0.;
|
||||
IS >> A;
|
||||
BinTools::GetReal(IS, R1);
|
||||
BinTools::GetReal(IS, R2);
|
||||
S = new Geom_ToroidalSurface(A,R1,R2);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_SurfaceOfLinearExtrusion)& S)
|
||||
{
|
||||
gp_Dir D(1.,0.,0.);
|
||||
Handle(Geom_Curve) C;
|
||||
IS >> D;
|
||||
BinTools_CurveSet::ReadCurve(IS,C);
|
||||
S = new Geom_SurfaceOfLinearExtrusion(C,D);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_SurfaceOfRevolution)& S)
|
||||
{
|
||||
gp_Pnt P(0.,0.,0.);
|
||||
gp_Dir D(1.,0.,0.);
|
||||
Handle(Geom_Curve) C;
|
||||
IS >> P >> D;
|
||||
BinTools_CurveSet::ReadCurve(IS, C);
|
||||
S = new Geom_SurfaceOfRevolution(C,gp_Ax1(P,D));
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_BezierSurface)& S)
|
||||
{
|
||||
// cout << "BezierSurface:" <<endl;
|
||||
Standard_Boolean urational=Standard_False, vrational=Standard_False;
|
||||
BinTools::GetBool(IS, urational);
|
||||
BinTools::GetBool(IS, vrational);
|
||||
|
||||
// cout << "\turational = " << urational << " vrational = " << vrational<<endl;
|
||||
Standard_Integer udegree=0, vdegree=0;
|
||||
Standard_ExtCharacter aVal='\0';
|
||||
BinTools::GetExtChar(IS, aVal);
|
||||
|
||||
udegree = (Standard_Integer)aVal;
|
||||
BinTools::GetExtChar(IS, aVal);
|
||||
vdegree = (Standard_Integer)aVal;
|
||||
// cout << "\ttudegree = " << udegree << ", vdegree = " << vdegree << endl;
|
||||
|
||||
TColgp_Array2OfPnt poles(1,udegree+1,1,vdegree+1);
|
||||
TColStd_Array2OfReal weights(1,udegree+1,1,vdegree+1);
|
||||
|
||||
Standard_Integer i,j;
|
||||
for (i = 1; i <= udegree+1; i++) {
|
||||
for (j = 1; j <= vdegree+1; j++) {
|
||||
IS >> poles(i,j);//Pnt
|
||||
// cout <<"Pole X = " <<poles(i,j).X()<< " Y = " <<poles(i,j).Y()<< " Z = " << poles(i,j).Z()<<endl;
|
||||
if (urational || vrational)
|
||||
BinTools::GetReal(IS, weights(i,j));
|
||||
}
|
||||
}
|
||||
|
||||
if (urational || vrational)
|
||||
S = new Geom_BezierSurface(poles,weights);
|
||||
else
|
||||
S = new Geom_BezierSurface(poles);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_BSplineSurface)& S)
|
||||
{
|
||||
Standard_Boolean urational=Standard_False, vrational=Standard_False,
|
||||
uperiodic=Standard_False, vperiodic=Standard_False;
|
||||
BinTools::GetBool(IS, urational);
|
||||
BinTools::GetBool(IS, vrational);
|
||||
BinTools::GetBool(IS, uperiodic);
|
||||
BinTools::GetBool(IS, vperiodic);
|
||||
|
||||
Standard_Integer udegree=0, vdegree=0,nbupoles=0,nbvpoles=0,nbuknots=0,nbvknots=0;
|
||||
Standard_ExtCharacter aVal='\0';
|
||||
BinTools::GetExtChar(IS, aVal);
|
||||
udegree = (Standard_Integer)aVal;
|
||||
BinTools::GetExtChar(IS, aVal);
|
||||
vdegree = (Standard_Integer)aVal;
|
||||
BinTools::GetInteger(IS, nbupoles);
|
||||
BinTools::GetInteger(IS, nbvpoles);
|
||||
BinTools::GetInteger(IS, nbuknots);
|
||||
BinTools::GetInteger(IS, nbvknots);
|
||||
|
||||
TColgp_Array2OfPnt poles(1,nbupoles,1,nbvpoles);
|
||||
TColStd_Array2OfReal weights(1,nbupoles,1,nbvpoles);
|
||||
|
||||
Standard_Integer i,j;
|
||||
for (i = 1; i <= nbupoles; i++) {
|
||||
for (j = 1; j <= nbvpoles; j++) {
|
||||
IS >> poles(i,j);//Pnt
|
||||
if (urational || vrational)
|
||||
BinTools::GetReal(IS, weights(i,j));
|
||||
}
|
||||
}
|
||||
|
||||
TColStd_Array1OfReal uknots(1,nbuknots);
|
||||
TColStd_Array1OfInteger umults(1,nbuknots);
|
||||
for (i = 1; i <= nbuknots; i++) {
|
||||
BinTools::GetReal(IS, uknots(i));
|
||||
BinTools::GetInteger(IS, umults(i));
|
||||
}
|
||||
|
||||
TColStd_Array1OfReal vknots(1,nbvknots);
|
||||
TColStd_Array1OfInteger vmults(1,nbvknots);
|
||||
for (i = 1; i <= nbvknots; i++) {
|
||||
BinTools::GetReal(IS, vknots(i));
|
||||
BinTools::GetInteger(IS, vmults(i));
|
||||
}
|
||||
|
||||
if (urational || vrational)
|
||||
S = new Geom_BSplineSurface(poles,weights,uknots,vknots,umults,vmults,
|
||||
udegree,vdegree,uperiodic,vperiodic);
|
||||
else
|
||||
S = new Geom_BSplineSurface(poles,uknots,vknots,umults,vmults,
|
||||
udegree,vdegree,uperiodic,vperiodic);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_RectangularTrimmedSurface)& S)
|
||||
{
|
||||
Standard_Real U1=0.,U2=0.,V1=0.,V2=0.;
|
||||
BinTools::GetReal(IS, U1);
|
||||
BinTools::GetReal(IS, U2);
|
||||
BinTools::GetReal(IS, V1);
|
||||
BinTools::GetReal(IS, V2);
|
||||
Handle(Geom_Surface) BS;
|
||||
BinTools_SurfaceSet::ReadSurface(IS, BS);
|
||||
S = new Geom_RectangularTrimmedSurface(BS,U1,U2,V1,V2);
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator>>
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_OffsetSurface)& S)
|
||||
{
|
||||
Standard_Real O=0.;
|
||||
BinTools::GetReal(IS, O);
|
||||
Handle(Geom_Surface) BS;
|
||||
BinTools_SurfaceSet::ReadSurface(IS, BS);
|
||||
S = new Geom_OffsetSurface(BS,O);
|
||||
return IS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& BinTools_SurfaceSet::ReadSurface(Standard_IStream& IS,
|
||||
Handle(Geom_Surface)& S)
|
||||
{
|
||||
Standard_SStream aMsg;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
const Standard_Byte stype = (Standard_Byte) IS.get();
|
||||
#ifdef DEB
|
||||
// cout << "ReadSurface: Surface type = " << (Standard_Integer)stype <<endl;
|
||||
#endif
|
||||
switch (stype) {
|
||||
|
||||
case PLANE :
|
||||
{
|
||||
Handle(Geom_Plane) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case CYLINDER :
|
||||
{
|
||||
Handle(Geom_CylindricalSurface) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case CONE :
|
||||
{
|
||||
Handle(Geom_ConicalSurface) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case SPHERE :
|
||||
{
|
||||
Handle(Geom_SphericalSurface) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case TORUS :
|
||||
{
|
||||
Handle(Geom_ToroidalSurface) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case LINEAREXTRUSION :
|
||||
{
|
||||
Handle(Geom_SurfaceOfLinearExtrusion) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case REVOLUTION :
|
||||
{
|
||||
Handle(Geom_SurfaceOfRevolution) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case BEZIER :
|
||||
{
|
||||
Handle(Geom_BezierSurface) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case BSPLINE :
|
||||
{
|
||||
Handle(Geom_BSplineSurface) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case RECTANGULAR :
|
||||
{
|
||||
Handle(Geom_RectangularTrimmedSurface) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
case OFFSET :
|
||||
{
|
||||
Handle(Geom_OffsetSurface) SS;
|
||||
IS >> SS;
|
||||
S = SS;
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
{
|
||||
S = NULL;
|
||||
aMsg << "UNKNOWN SURFACE TYPE" << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
S = NULL;
|
||||
aMsg << "EXCEPTION in BinTools_SurfaceSet::ReadSurface(..)" << endl;
|
||||
Handle(Standard_Failure) anExc = Standard_Failure::Caught();
|
||||
aMsg << anExc << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_SurfaceSet::Read(Standard_IStream& IS)
|
||||
{
|
||||
char buffer[255];
|
||||
IS >> buffer;
|
||||
if (IS.fail() || strcmp(buffer,"Surfaces")) {
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "BinTools_SurfaceSet::Read: Not a surface table"<<endl;
|
||||
#ifdef DEB
|
||||
cout <<"SurfaceSet buffer: " << buffer << endl;
|
||||
#endif
|
||||
Standard_Failure::Raise(aMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) S;
|
||||
Standard_Integer i, nbsurf;
|
||||
IS >> nbsurf;
|
||||
IS.get ();//remove <lf>
|
||||
for (i = 1; i <= nbsurf; i++) {
|
||||
BinTools_SurfaceSet::ReadSurface(IS,S);
|
||||
myMap.Add(S);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user