1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

Integration of OCCT 6.5.0 from SVN

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

4
src/GGraphic2d/FILES Executable file
View File

@@ -0,0 +1,4 @@
FILES
Graphic2d_Curve.hxx
Graphic2d_CurveDefinitionError.hxx
Graphic2d_SetOfCurves.hxx

54
src/GGraphic2d/GGraphic2d.cdl Executable file
View File

@@ -0,0 +1,54 @@
-- File: Graphic2d.cdl
-- Created: Tue Jun 22 16:27:10 1993
-- Author: Jean Louis FRENKEL, Gerard Gras.
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
package GGraphic2d
---Version:
---Purpose: This package permits the creation of 2d graphic curves
-- and set of curves in a in a visualiser.
-- It moved from the Graphic2d package to this package
-- since it required services from the UL GEOMETRY
--
---Keywords: Drawer, View, Graphic Object, Primitive, Line,
-- Circle, Polyline, Ellips, Curve, Image, Text, HidingText,
-- FramedText, Paragraph
---Warning:
---References:
uses
Graphic2d,
Aspect,
Geom2d,
Image,
MMgt,
gp,
OSD,
Quantity,
TCollection,
TColStd,
TShort,
TColGeom2d
is
class Curve ;
---Category: Set of primitive curves
--
class SetOfCurves;
---Category: Set Of Graphic primitives
-----------------------
-- Category: Exceptions
-----------------------
exception CurveDefinitionError inherits OutOfRange;
---Category: Exceptions
end GGraphic2d;

View File

@@ -0,0 +1,71 @@
-- File: GGraphic2d_Curve.cdl
-- Created: Thu Jul 1 10:03:27 1993
-- Author: Jean Louis FRENKEL
-- <jlf@stylox>
-- Modified: TCL G002A, 28-11-00, new method GeomCurve(...)
---Copyright: Matra Datavision 1993
class Curve from GGraphic2d inherits Line from Graphic2d
---Version:
---Purpose: The primitive Curve
---Keywords: Primitive, Curve
---Warning:
---References:
uses
Drawer from Graphic2d,
Curve from Geom2d,
GraphicObject from Graphic2d,
FStream from Aspect,
IFStream from Aspect
is
--------------------------------------
-- Category: Constructors
--------------------------------------
Create (aGraphicObject: GraphicObject from Graphic2d;
aCurve: Curve from Geom2d)
returns mutable Curve from GGraphic2d;
---Level: Public
---Purpose: Creates a curve.
---Category: Constructors
--------------------------------------
-- Category: Inquire methods
--------------------------------------
GeomCurve( me ) returns Curve from Geom2d;
---Level: Internal
---Purpose: returns the geometric curve
--------------------------------------
-- Category: Draw and Pick
--------------------------------------
Draw (me : mutable; aDrawer: Drawer from Graphic2d)
is static protected;
---Level: Internal
---Purpose: Draws the curve <me>.
Pick (me : mutable; X, Y: ShortReal from Standard;
aPrecision: ShortReal from Standard;
aDrawer: Drawer from Graphic2d)
returns Boolean from Standard is static protected;
---Level: Internal
---Purpose: Returns Standard_True if the curve <me> is picked,
-- Standard_False if not.
----------------------------------------------------------------
Save( me; aFStream: in out FStream from Aspect ) is virtual protected;
Retrieve(myclass; anIFStream: in out IFStream from Aspect;
aGraphicObject: GraphicObject from Graphic2d);
fields
myCurve: Curve from Geom2d;
end Curve from GGraphic2d;

View File

@@ -0,0 +1,469 @@
#define WTO0001 //GG_140596
// Calcul des min-max faux apres transformation.
// G002 TCL : Drawing of descriptor of BSpline and Bezier curves in display mode 1
#include <GGraphic2d_Curve.ixx>
#include <BndLib_Add2dCurve.hxx>
#include <Bnd_Box2d.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <GCPnts_UniformDeflection.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Parab2d.hxx>
#include <gp_Hypr2d.hxx>
#include <gp_Pnt.hxx>
#include <TShort_Array1OfShortReal.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <Standard_ErrorHandler.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_OffsetCurve.hxx>
#define MAXPOINTS 1023
#define VERTEXMARKER 4
#define DEFAULTMARKERSIZE 3.0
static TShort_Array1OfShortReal Xpoint(1,MAXPOINTS);
static TShort_Array1OfShortReal Ypoint(1,MAXPOINTS);
GGraphic2d_Curve::GGraphic2d_Curve
(const Handle(Graphic2d_GraphicObject)& aGraphicObject,
const Handle(Geom2d_Curve)& aCurve)
: Graphic2d_Line(aGraphicObject) , myCurve(aCurve) {
Bnd_Box2d Box;
BndLib_Add2dCurve::Add(Geom2dAdaptor_Curve(aCurve),0.,Box);
Standard_Real aXmin, aYmin, aXmax, aYmax;
Box.Get( aXmin, aYmin, aXmax, aYmax);
myMinX = Standard_ShortReal(aXmin);
myMinY = Standard_ShortReal(aYmin);
myMaxX = Standard_ShortReal(aXmax);
myMaxY = Standard_ShortReal(aYmax);
}
Handle(Geom2d_Curve) GGraphic2d_Curve::GeomCurve() const {
return myCurve;
}
void GGraphic2d_Curve::Draw (const Handle(Graphic2d_Drawer)& aDrawer) {
Standard_Boolean IsIn = Standard_False;
if (! myGOPtr->IsTransformed ())
IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY);
else {
Standard_ShortReal minx, miny, maxx, maxy;
#ifdef WTO0001
MinMax(minx,maxx,miny,maxy);
#else
gp_GTrsf2d aTrsf = myGOPtr->Transform ();
Standard_Real MINX, MINY, MAXX, MAXY;
MINX = Standard_Real (myMinX);
MINY = Standard_Real (myMinY);
MAXX = Standard_Real (myMaxX);
MAXY = Standard_Real (myMaxY);
aTrsf.Transforms (MINX, MINY);
aTrsf.Transforms (MAXX, MAXY);
minx = Standard_ShortReal (MINX);
miny = Standard_ShortReal (MINY);
maxx = Standard_ShortReal (MAXX);
maxy = Standard_ShortReal (MAXY);
#endif
IsIn = aDrawer->IsIn (minx,maxx,miny,maxy);
}
if (IsIn) {
switch ( myDisplayMode ) {
case 0:
default: {
gp_GTrsf2d aTrsf = myGOPtr->Transform ();
Standard_ShortReal Def;
Standard_ShortReal Coeff;
Aspect_TypeOfDeflection Type;
aDrawer->DrawPrecision(Def,Coeff,Type);
Standard_Boolean Controll = Standard_True;
if (Type == Aspect_TOD_RELATIVE)
Def = ( Abs(myMaxX-myMinX) + Abs(myMaxY-myMinY) ) * Coeff;
Geom2dAdaptor_Curve GAC(myCurve);
GCPnts_UniformDeflection UD(GAC,Def,Controll);
if (UD.IsDone() ) {
Standard_Integer i,j = 1,nbp = UD.NbPoints();
gp_Pnt p2;
Standard_Real x,y,z;
while (nbp > 0) {
Standard_Integer n = Min(MAXPOINTS,nbp);
for (i=1; i<=n; i++) {
p2 = UD.Value(j); j++;
p2.Coord(x,y,z);
Xpoint(i) = Standard_ShortReal( x );
Ypoint(i) = Standard_ShortReal( y );
}
if (myGOPtr->IsTransformed ()) {
Standard_Real A, B;
for (i=1; i<=n; i++) {
A = Standard_Real (Xpoint(i));
B = Standard_Real (Ypoint(i));
aTrsf.Transforms (A, B);
Xpoint(i) = Standard_ShortReal (A);
Ypoint(i) = Standard_ShortReal (B);
}
}
DrawLineAttrib(aDrawer);
aDrawer->MapPolylineFromTo(Xpoint,Ypoint,n);
nbp -= MAXPOINTS; --j;
} // end while
} // end UD.IsDone
} // end case 0
break;
case 1: {
if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve) ) ) {
Handle(Geom2d_BezierCurve) theBC = Handle(Geom2d_BezierCurve)::DownCast(myCurve);
TColgp_Array1OfPnt2d thePnts(1, theBC->NbPoles());
theBC->Poles(thePnts);
TShort_Array1OfShortReal XDpoint(thePnts.Lower(), thePnts.Upper());
TShort_Array1OfShortReal YDpoint(thePnts.Lower(), thePnts.Upper());
int i;
for ( i = thePnts.Lower(); i <= thePnts.Upper(); ++i ) {
XDpoint.SetValue( i, Standard_ShortReal( thePnts(i).X() ) );
YDpoint.SetValue( i, Standard_ShortReal( thePnts(i).Y() ) );
}
if ( myGOPtr->IsTransformed() ) {
gp_GTrsf2d aTrsf = myGOPtr->Transform();
Standard_Real A, B;
for ( i = XDpoint.Lower(); i <= XDpoint.Upper(); ++i ) {
A = Standard_Real(XDpoint(i));
B = Standard_Real(YDpoint(i));
aTrsf.Transforms( A, B );
XDpoint(i) = Standard_ShortReal( A );
YDpoint(i) = Standard_ShortReal( B );
}
}
DrawLineAttrib(aDrawer);
aDrawer->MapPolylineFromTo(XDpoint,YDpoint,thePnts.Length());
DrawMarkerAttrib(aDrawer);
for ( i = XDpoint.Lower(); i <= XDpoint.Upper(); ++i )
aDrawer->MapMarkerFromTo(VERTEXMARKER,XDpoint(i),YDpoint(i), DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0);
} else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve) ) ) {
Handle(Geom2d_BSplineCurve) theBC = Handle(Geom2d_BSplineCurve)::DownCast(myCurve);
TColgp_Array1OfPnt2d thePnts(1, theBC->NbPoles());
theBC->Poles(thePnts);
TShort_Array1OfShortReal XDpoint(thePnts.Lower(), thePnts.Upper());
TShort_Array1OfShortReal YDpoint(thePnts.Lower(), thePnts.Upper());
int i;
for ( i = thePnts.Lower(); i <= thePnts.Upper(); ++i ) {
XDpoint.SetValue( i, Standard_ShortReal( thePnts(i).X() ) );
YDpoint.SetValue( i, Standard_ShortReal( thePnts(i).Y() ) );
}
if ( myGOPtr->IsTransformed() ) {
gp_GTrsf2d aTrsf = myGOPtr->Transform();
Standard_Real A, B;
for ( i = XDpoint.Lower(); i <= XDpoint.Upper(); ++i ) {
A = Standard_Real(XDpoint(i));
B = Standard_Real(YDpoint(i));
aTrsf.Transforms( A, B );
XDpoint(i) = Standard_ShortReal( A );
YDpoint(i) = Standard_ShortReal( B );
}
}
DrawLineAttrib(aDrawer);
aDrawer->MapPolylineFromTo(XDpoint,YDpoint,thePnts.Length());
DrawMarkerAttrib(aDrawer);
for ( i = XDpoint.Lower(); i <= XDpoint.Upper(); ++i )
aDrawer->MapMarkerFromTo( VERTEXMARKER, XDpoint(i), YDpoint(i), DEFAULTMARKERSIZE, DEFAULTMARKERSIZE, 0.0 );
}
} //end case 1
} //end switch
} // end IsIn
}
Standard_Boolean GGraphic2d_Curve::Pick (const Standard_ShortReal X,
const Standard_ShortReal Y,
const Standard_ShortReal aPrecision,
const Handle(Graphic2d_Drawer)& /*aDrawer*/)
{
//Standard_ShortReal SRX = X, SRY = Y;
static Standard_ShortReal SRX , SRY ;
SRX = X;
SRY = Y;
if (IsInMinMax (X, Y, aPrecision)) {
if (myGOPtr->IsTransformed ()) {
gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted ();
Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY);
aTrsf.Transforms (RX, RY);
SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY);
}
try {
OCC_CATCH_SIGNALS
Geom2dAPI_ProjectPointOnCurve PC(gp_Pnt2d(SRX, SRY),
myCurve,
myCurve->FirstParameter(),
myCurve->LastParameter());
if(PC.NbPoints() == 0) {
return Standard_False;
}
else {
gp_Pnt2d P = PC.NearestPoint();
return (( Abs ( SRX - P.X() ) + Abs ( SRY - P.Y() ) ) < aPrecision);
}
}
catch(Standard_Failure)
{
return Standard_False;
}
}
return Standard_False; //WNT
}
void GGraphic2d_Curve::Save(Aspect_FStream& aFStream) const
{
*aFStream << "GGraphic2d_Curve" << endl;
if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Line)) )
{
Handle(Geom2d_Line) theLine = Handle(Geom2d_Line)::DownCast( myCurve );
gp_Dir2d tDir = theLine->Direction();
gp_Pnt2d tPnt = theLine->Location();
*aFStream << "Geom2d_Line" << endl;
*aFStream << tPnt.X() << ' ' << tPnt.Y() << endl;
*aFStream << tDir.X() << ' ' << tDir.Y() << endl;
}
else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Circle)) )
{
Handle(Geom2d_Circle) theCirc = Handle(Geom2d_Circle)::DownCast( myCurve );
gp_Circ2d tCirc = theCirc->Circ2d();
gp_Ax22d tAx22d = tCirc.Axis();
gp_Pnt2d tLoc = tAx22d.Location();
gp_Dir2d tDirX = tAx22d.XDirection(),
tDirY = tAx22d.YDirection();
Standard_Real tRad = tCirc.Radius();
*aFStream << "Geom2d_Circle" << endl;
*aFStream << tRad << endl;
*aFStream << tLoc.X() << ' ' << tLoc.Y() << endl;
*aFStream << tDirX.X() << ' ' << tDirX.Y() << endl;
*aFStream << tDirY.X() << ' ' << tDirY.Y() << endl;
}
else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Parabola)) )
{
Handle(Geom2d_Parabola) theParab = Handle(Geom2d_Parabola)::DownCast( myCurve );
gp_Parab2d tParab = theParab->Parab2d();
gp_Ax22d tAx22d = tParab.Axis();
gp_Pnt2d tLoc = tAx22d.Location();
gp_Dir2d tDirX = tAx22d.XDirection(),
tDirY = tAx22d.YDirection();
Standard_Real tFocal = theParab->Focal();
*aFStream << "Geom2d_Parabola" << endl;
*aFStream << tFocal << endl;
*aFStream << tLoc.X() << ' ' << tLoc.Y() << endl;
*aFStream << tDirX.X() << ' ' << tDirX.Y() << endl;
*aFStream << tDirY.X() << ' ' << tDirY.Y() << endl;
}
else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Ellipse)) )
{
Handle(Geom2d_Ellipse) theEllipse = Handle(Geom2d_Ellipse)::DownCast(myCurve);
gp_Elips2d tElips = theEllipse->Elips2d();
Standard_Real tMin = tElips.MinorRadius(),
tMaj = tElips.MajorRadius();
gp_Ax22d tAx22d = tElips.Axis();
gp_Pnt2d tLoc = tAx22d.Location();
gp_Dir2d tDirX = tAx22d.XDirection(),
tDirY = tAx22d.YDirection();
*aFStream << "Geom2d_Ellipse" << endl;
*aFStream << tMin << ' ' << tMaj << endl;
*aFStream << tLoc.X() << ' ' << tLoc.Y() << endl;
*aFStream << tDirX.X() << ' ' << tDirX.Y() << endl;
*aFStream << tDirY.X() << ' ' << tDirY.Y() << endl;
}
else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Hyperbola)) )
{
Handle(Geom2d_Hyperbola) theHypr = Handle(Geom2d_Hyperbola)::DownCast(myCurve);
gp_Hypr2d tHypr = theHypr->Hypr2d();
Standard_Real tMin = tHypr.MinorRadius(),
tMaj = tHypr.MajorRadius();
gp_Ax22d tAx22d = tHypr.Axis();
gp_Pnt2d tLoc = tAx22d.Location();
gp_Dir2d tDirX = tAx22d.XDirection(),
tDirY = tAx22d.YDirection();
*aFStream << "Geom2d_Hyperbola" << endl;
*aFStream << tMin << ' ' << tMaj << endl;
*aFStream << tLoc.X() << ' ' << tLoc.Y() << endl;
*aFStream << tDirX.X() << ' ' << tDirX.Y() << endl;
*aFStream << tDirY.X() << ' ' << tDirY.Y() << endl;
}
else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve)) )
{
Handle(Geom2d_BezierCurve) theBC = Handle(Geom2d_BezierCurve)::DownCast(myCurve);
Standard_Integer nbPoles = theBC->NbPoles();
TColgp_Array1OfPnt2d tpoles( 1, nbPoles );
theBC->Poles( tpoles );
*aFStream << "Geom2d_BezierCurve" << endl;
*aFStream << nbPoles << endl;
for ( int i = 1; i <= nbPoles; i++ )
*aFStream << tpoles(i).X() << ' ' << tpoles(i).Y() << endl;
}
else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve)) )
{
// Handle(Geom2d_BSplineCurve) theBSC = Handle(Geom2d_BSplineCurve)::DownCast(myCurve);
}
else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)) )
{
// Handle(Geom2d_OffsetCurve) theOC = Handle(Geom2d_OffsetCurve)::DownCast(myCurve);
}
else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)) )
{
// Handle(Geom2d_TrimmedCurve) theTC = Handle(Geom2d_TrimmedCurve)::DownCast(myCurve);
}
Graphic2d_Line::Save(aFStream);
}
void GGraphic2d_Curve::Retrieve(Aspect_IFStream& anIFStream,
const Handle(Graphic2d_GraphicObject)& aGraphicObject)
{
char buf[100];
anIFStream->getline(buf, 100);
if (! strcmp(buf, "Geom2d_Line"))
{
Standard_Real X, Y, dX, dY;
*anIFStream >> X >> Y;
*anIFStream >> dX >> dY;
gp_Pnt2d tPnt(X, Y);
gp_Dir2d tDir(dX, dY);
Handle(Geom2d_Line)
theLine = new Geom2d_Line(tPnt, tDir);
Handle(GGraphic2d_Curve)
theGGC = new GGraphic2d_Curve(aGraphicObject, theLine);
((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream);
}
else if (! strcmp(buf, "Geom2d_Circle"))
{
Standard_Real tRad, X, Y, dXX, dXY, dYX, dYY;
*anIFStream >> tRad;
*anIFStream >> X >> Y;
*anIFStream >> dXX >> dXY;
*anIFStream >> dYX >> dYY;
gp_Pnt2d tPnt(X, Y);
gp_Dir2d tDirX(dXX, dXY);
gp_Dir2d tDirY(dYX, dYY);
gp_Ax22d tAx22d(tPnt, tDirX, tDirY);
Handle(Geom2d_Circle)
tCirc = new Geom2d_Circle(tAx22d, tRad);
Handle(GGraphic2d_Curve)
theGGC = new GGraphic2d_Curve(aGraphicObject, tCirc);
((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream);
}
else if (! strcmp(buf, "Geom2d_Parabola"))
{
Standard_Real tFocal, X, Y, dXX, dXY, dYX, dYY;
*anIFStream >> tFocal;
*anIFStream >> X >> Y;
*anIFStream >> dXX >> dXY;
*anIFStream >> dYX >> dYY;
gp_Pnt2d tPnt(X, Y);
gp_Dir2d tDirX(dXX, dXY);
gp_Dir2d tDirY(dYX, dYY);
gp_Ax22d tAx22d(tPnt, tDirX, tDirY);
Handle(Geom2d_Parabola)
gp_Parab2d = new Geom2d_Parabola(tAx22d, tFocal);
Handle(GGraphic2d_Curve)
theGGC = new GGraphic2d_Curve(aGraphicObject, gp_Parab2d);
((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream);
}
else if (! strcmp(buf, "Geom2d_Ellipse"))
{
Standard_Real tMin, tMaj, X, Y, dXX, dXY, dYX, dYY;
*anIFStream >> tMin >> tMaj;
*anIFStream >> X >> Y;
*anIFStream >> dXX >> dXY;
*anIFStream >> dYX >> dYY;
gp_Pnt2d tPnt(X, Y);
gp_Dir2d tDirX(dXX, dXY);
gp_Dir2d tDirY(dYX, dYY);
gp_Ax22d tAx22d(tPnt, tDirX, tDirY);
Handle(Geom2d_Ellipse)
theEllipse = new Geom2d_Ellipse(tAx22d, tMaj, tMin);
Handle(GGraphic2d_Curve)
theGGC = new GGraphic2d_Curve(aGraphicObject, theEllipse);
((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream);
}
else if (! strcmp(buf, "Geom2d_Hyperbola"))
{
Standard_Real tMin, tMaj, X, Y, dXX, dXY, dYX, dYY;
*anIFStream >> tMin >> tMaj;
*anIFStream >> X >> Y;
*anIFStream >> dXX >> dXY;
*anIFStream >> dYX >> dYY;
gp_Pnt2d tPnt(X, Y);
gp_Dir2d tDirX(dXX, dXY);
gp_Dir2d tDirY(dYX, dYY);
gp_Ax22d tAx22d(tPnt, tDirX, tDirY);
Handle(Geom2d_Hyperbola)
theHypr = new Geom2d_Hyperbola(tAx22d, tMaj, tMin);
Handle(GGraphic2d_Curve)
theGGC = new GGraphic2d_Curve(aGraphicObject, theHypr);
((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream);
}
else if (! strcmp(buf, "Geom2d_BezierCurve"))
{
Standard_Integer numPoles;
Standard_Real X, Y;
*anIFStream >> numPoles;
TColgp_Array1OfPnt2d listPoles(1, numPoles);
for (Standard_Integer i=1; i<=numPoles; i++)
{
*anIFStream >> X >> Y;
listPoles.SetValue(i, gp_Pnt2d(X, Y));
}
Handle(Geom2d_BezierCurve)
theBC = new Geom2d_BezierCurve(listPoles);
Handle(GGraphic2d_Curve)
theGGC = new GGraphic2d_Curve(aGraphicObject, theBC);
((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream);
}
else if (! strcmp(buf, "Geom2d_BSplineCurve"))
;
else if (! strcmp(buf, "Geom2d_OffsetCurve"))
;
else if (! strcmp(buf, "Geom2d_TrimmedCurve"))
;
else
{}
}

View File

@@ -0,0 +1,102 @@
-- File: GGraphic2d_SetOfCurves.cdl
-- Created: Thu September 21 16:36:51 1995
-- Author: Gerard GRAS
-- <gg@azimox>
-- Modified: TCL_G002 adds new draw methods DrawElement(...) and DrawVertex(...)
---Copyright: Matra Datavision 1993
class SetOfCurves from GGraphic2d inherits Line from Graphic2d
---Version:
---Purpose: The primitive SetOfCurves
---Keywords: Primitive, Curve
---Warning: This primitive must be use as possible for performance
-- improvment but is drawn with a global line attributes
-- for all the set.
-- NOTE: than the method PickedIndex() permits to known
-- the last picked curve in the set.
---References:
uses
Drawer from Graphic2d,
GraphicObject from Graphic2d,
SequenceOfCurve from TColGeom2d,
Length from Quantity,
Curve from Geom2d,
SequenceOfShortReal from TShort,
FStream from Aspect
raises
CurveDefinitionError from GGraphic2d,
OutOfRange from Standard
is
-------------------------
-- Category: Constructors
-------------------------
Create (aGraphicObject: GraphicObject from Graphic2d)
returns mutable SetOfCurves from GGraphic2d;
---Level: Public
---Purpose: Creates an empty set of curves in the graphic
-- object <aGraphicObject>.
---Category: Constructors
Add(me : mutable; aCurve: Curve from Geom2d);
---Level: Public
---Purpose: Add a curve in the set
---Category: Update method
Length(me) returns Integer from Standard;
---Level: Public
---Purpose: Returns the number of curves in the set.
---Category: Inquiry method
Values(me; aRank: Integer from Standard) returns Curve from Geom2d
---Level: Public
---Purpose: Returns the curve of rank <aRank> from the set.
---Trigger: Raises OutOfRange if <aRank> is <1 or >Length()
raises OutOfRange from Standard;
---Category: Inquiry method
--------------------------
-- Category: Draw and Pick
--------------------------
Draw (me : mutable; aDrawer: Drawer from Graphic2d)
is static protected;
---Level: Internal
---Purpose: Draws the set of curves <me>.
DrawElement( me : mutable; aDrawer: Drawer from Graphic2d;
anIndex: Integer from Standard)
is redefined protected;
---Level: Internal
---Purpose: Draws element <anIndex> of the set <me>.
DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d;
anIndex: Integer from Standard)
is redefined protected;
---Level: Internal
---Purpose: Draws vertex <anIndex> of the set <me>.
Pick (me : mutable; X, Y: ShortReal from Standard;
aPrecision: ShortReal from Standard;
aDrawer: Drawer from Graphic2d)
returns Boolean from Standard
is static protected;
---Level: Internal
---Purpose: Returns Standard_True if one curve of the set <me>
-- is picked, Standard_False if not.
---Warning: The PickIndex() method returns the rank of the picked
-- curve if any.
Save( me; aFStream: in out FStream from Aspect ) is virtual protected;
fields
myCurves: SequenceOfCurve from TColGeom2d;
end SetOfCurves from GGraphic2d;

View File

@@ -0,0 +1,461 @@
#include <GGraphic2d_SetOfCurves.ixx>
#include <BndLib_Add2dCurve.hxx>
#include <Bnd_Box2d.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_OffsetCurve.hxx>
#include <GCPnts_UniformDeflection.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Parab2d.hxx>
#include <gp_Hypr2d.hxx>
#include <gp_Pnt.hxx>
#include <TShort_Array1OfShortReal.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <Standard_ErrorHandler.hxx>
#define G002
#define VERTEXMARKER 2
#define DEFAULTMARKERSIZE 3.0
GGraphic2d_SetOfCurves::GGraphic2d_SetOfCurves (
const Handle(Graphic2d_GraphicObject)& aGraphicObject)
: Graphic2d_Line (aGraphicObject) {
}
void GGraphic2d_SetOfCurves::Add (const Handle(Geom2d_Curve) &aCurve)
{
Bnd_Box2d Box;
BndLib_Add2dCurve::Add(Geom2dAdaptor_Curve(aCurve),0.,Box);
Standard_Real Xmin, Ymin, Xmax, Ymax;
Box.Get( Xmin, Ymin, Xmax, Ymax);
Standard_ShortReal minX = Standard_ShortReal(Xmin);
Standard_ShortReal minY = Standard_ShortReal(Ymin);
Standard_ShortReal maxX = Standard_ShortReal(Xmax);
Standard_ShortReal maxY = Standard_ShortReal(Ymax);
myMinX = Min(myMinX,minX);
myMinY = Min(myMinY,minY);
myMaxX = Max(myMaxX,maxX);
myMaxY = Max(myMaxY,maxY);
myCurves.Append(aCurve);
}
Standard_Integer GGraphic2d_SetOfCurves::Length () const {
return myCurves.Length();
}
Handle(Geom2d_Curve) GGraphic2d_SetOfCurves::Values(const Standard_Integer aRank) const {
if( aRank < 1 || aRank > myCurves.Length() )
Standard_OutOfRange::Raise
("the curve rank is out of bounds in the set");
return myCurves.Value(aRank);
}
void GGraphic2d_SetOfCurves::Draw (const Handle(Graphic2d_Drawer)& aDrawer) {
//Standard_Integer i,length = myCurves.Length(),bufferize = 1;
Standard_Integer length = myCurves.Length(), bufferize = 1;
Standard_Boolean IsIn = Standard_False;
Standard_ShortReal minX,minY,maxX,maxY;
Standard_Real Xmin,Ymin,Xmax,Ymax;
if( length <= 0 ) return ;
gp_GTrsf2d aTrsf = myGOPtr->Transform ();
if (! myGOPtr->IsTransformed ())
IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY);
else {
MinMax(minX,maxX,minY,maxY);
IsIn = aDrawer->IsIn (minX,maxX,minY,maxY);
}
if ( IsIn ) {
Standard_ShortReal Def;
Standard_ShortReal Coeff;
Aspect_TypeOfDeflection Type;
Standard_Boolean Controll = Standard_True;
Handle(Geom2d_Curve) aCurve;
Standard_Integer i,typeindex = TypeIndex();
aDrawer->DrawPrecision(Def,Coeff,Type);
DrawLineAttrib(aDrawer);
for( i=1 ; i<=length ; i++ ) {
aCurve = myCurves.Value(i);
if (Type == Aspect_TOD_RELATIVE) {
Bnd_Box2d Box;
BndLib_Add2dCurve::Add(Geom2dAdaptor_Curve(aCurve),0.,Box);
Box.Get( Xmin,Ymin,Xmax,Ymax );
Def = Standard_ShortReal( (Abs(Xmax-Xmin) + Abs(Ymax-Ymin) ) * Coeff);
}
Geom2dAdaptor_Curve GAC(aCurve);
GCPnts_UniformDeflection UD(GAC,Def,Controll);
if(UD.IsDone()) {
Standard_Integer j,nbp = UD.NbPoints();
gp_Pnt p2;
Standard_Real x,y,z;
Standard_ShortReal x1=0,y1=0,x2,y2;
for (j=1; j<=nbp; j++) {
p2 = UD.Value(j);
p2.Coord(x,y,z);
if (myGOPtr->IsTransformed ()) {
aTrsf.Transforms(x, y);
}
if( typeindex > 0 ) {
if( j > 1 ) {
if( j < nbp ) bufferize = 0;
else bufferize = -1;
} else {
bufferize = nbp;
}
aDrawer->MapPolylineFromTo( Standard_ShortReal(x), Standard_ShortReal(y), bufferize);
} else {
if( j > 1 ) {
if( (i == length) && (j == nbp) ) bufferize = -1;
x2 = Standard_ShortReal(x); y2 = Standard_ShortReal(y);
aDrawer->MapSegmentFromTo(x1,y1,x2,y2,bufferize);
x1 = x2; y1 = y2;
bufferize = 0;
} else {
x1 = Standard_ShortReal(x); y1 = Standard_ShortReal(y);
}
}
}
}
}
}
}
#ifdef G002
void GGraphic2d_SetOfCurves::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer,
const Standard_Integer anIndex ) {
Standard_Integer length = myCurves.Length(), bufferize = 1;
Standard_Boolean IsIn = Standard_False;
Standard_ShortReal minX,minY,maxX,maxY;
Standard_Real Xmin,Ymin,Xmax,Ymax;
if ( length <= 0 ) return ;
gp_GTrsf2d aTrsf = myGOPtr->Transform ();
if ( ! myGOPtr->IsTransformed() )
IsIn = aDrawer->IsIn( myMinX,myMaxX,myMinY,myMaxY );
else {
MinMax(minX,maxX,minY,maxY);
IsIn = aDrawer->IsIn (minX,maxX,minY,maxY);
}
if ( IsIn ) {
if ( anIndex > 0 && anIndex <= length ) {
Standard_ShortReal Def, Coeff;
Aspect_TypeOfDeflection Type;
Standard_Boolean Controll = Standard_True;
Handle(Geom2d_Curve) aCurve;
Standard_Integer typeindex = TypeIndex();
aDrawer->DrawPrecision( Def, Coeff, Type );
DrawLineAttrib( aDrawer );
aCurve = myCurves.Value( anIndex );
if ( Type == Aspect_TOD_RELATIVE ) {
Bnd_Box2d Box;
BndLib_Add2dCurve::Add(Geom2dAdaptor_Curve(aCurve),0.,Box);
Box.Get( Xmin,Ymin,Xmax,Ymax );
Def = Standard_ShortReal( (Abs(Xmax-Xmin) + Abs(Ymax-Ymin) ) * Coeff);
}
Geom2dAdaptor_Curve GAC(aCurve);
GCPnts_UniformDeflection UD(GAC,Def,Controll);
if ( UD.IsDone() ) {
Standard_Integer j,nbp = UD.NbPoints();
gp_Pnt p2;
Standard_Real x,y,z;
Standard_ShortReal x1=0,y1=0,x2,y2;
for ( j = 1; j <= nbp; j++ ) {
p2 = UD.Value( j );
p2.Coord( x, y, z );
if ( myGOPtr->IsTransformed() ) {
aTrsf.Transforms (x, y);
}
if ( typeindex > 0 ) {
if ( j > 1 ) {
bufferize = ( j < nbp ) ? 0 : -1;
} else {
bufferize = nbp;
}
aDrawer->MapPolylineFromTo( Standard_ShortReal(x), Standard_ShortReal(y), bufferize );
} else {
if ( j > 1 ) {
if ( ( anIndex == length ) && (j == nbp) )
bufferize = -1;
x2 = Standard_ShortReal(x); y2 = Standard_ShortReal(y);
aDrawer->MapSegmentFromTo( x1, y1, x2, y2, bufferize );
x1 = x2; y1 = y2;
bufferize = 0;
} else {
x1 = Standard_ShortReal(x); y1 = Standard_ShortReal(y);
}
}
} // end for
}
}
} // end if IsIn
}
void GGraphic2d_SetOfCurves::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer,
const Standard_Integer anIndex ) {
Standard_Integer length = myCurves.Length();
Standard_Boolean IsIn = Standard_False;
Standard_ShortReal minX,minY,maxX,maxY;
if ( length <= 0 ) return ;
if ( ! myGOPtr->IsTransformed() )
IsIn = aDrawer->IsIn( myMinX,myMaxX,myMinY,myMaxY );
else {
MinMax(minX,maxX,minY,maxY);
IsIn = aDrawer->IsIn (minX,maxX,minY,maxY);
}
if ( IsIn ) {
if ( anIndex > 0 && anIndex <= 2*length ) {
DrawMarkerAttrib (aDrawer);
Handle(Geom2d_Curve) aCurve;
Standard_Real theParam;
if ( anIndex <= length ) {
aCurve = myCurves.Value( anIndex );
theParam = aCurve->FirstParameter();
} else {
aCurve = myCurves.Value( anIndex - length);
theParam = aCurve->LastParameter();
}
gp_Pnt2d thePnt = aCurve->Value(theParam);
Standard_ShortReal a = Standard_ShortReal(thePnt.X()),
b = Standard_ShortReal(thePnt.Y());
if ( myGOPtr->IsTransformed() ) {
gp_GTrsf2d aTrsf = myGOPtr->Transform ();
Standard_Real a1, b1;
a1 = Standard_Real(a);
b1 = Standard_Real(b);
aTrsf.Transforms( a1, b1 );
a = Standard_ShortReal( a1 );
b = Standard_ShortReal( b1 );
}
aDrawer->MapMarkerFromTo( VERTEXMARKER, a, b,
DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0);
}
} // end if IsIn
}
#endif
Standard_Boolean GGraphic2d_SetOfCurves::Pick(
const Standard_ShortReal X,
const Standard_ShortReal Y,
const Standard_ShortReal aPrecision,
const Handle(Graphic2d_Drawer)& /*aDrawer*/) {
Standard_Integer i,length = myCurves.Length();
//Standard_ShortReal SRX = X, SRY = Y;
static Standard_ShortReal SRX , SRY ;
SRX = X;
SRY = Y;
//Standard_Boolean isPicked = Standard_False;
if ( (length > 0) && IsInMinMax (X, Y, aPrecision)) {
if (myGOPtr->IsTransformed ()) {
gp_GTrsf2d aTrsf = (myGOPtr->Transform()).Inverted();
Standard_Real RX = Standard_Real( SRX ), RY = Standard_Real( SRY );
aTrsf.Transforms( RX, RY );
SRX = Standard_ShortReal( RX ); SRY = Standard_ShortReal( RY );
}
try {
OCC_CATCH_SIGNALS
Handle(Geom2d_Curve) aCurve;
for ( i = 1 ; i <= length; i++ ) {
aCurve = myCurves.Value(i);
Standard_Real FParam = aCurve->FirstParameter(),
LParam = aCurve->LastParameter();
gp_Pnt2d FP = aCurve->Value(FParam),
LP = aCurve->Value(LParam);
Geom2dAPI_ProjectPointOnCurve PC(gp_Pnt2d(SRX, SRY),
aCurve,
FParam,
LParam );
if ( PC.NbPoints() > 0 ) {
gp_Pnt2d P = PC.NearestPoint();
#ifdef G002
if ( ( Abs( SRX - P.X() ) + Abs( SRY - P.Y() ) ) < aPrecision ) {
SetPickedIndex( i );
return Standard_True;
} else if ( Graphic2d_Primitive::IsOn( SRX, SRY,
Standard_ShortReal(FP.X()), Standard_ShortReal(FP.Y()), aPrecision) ) {
SetPickedIndex( -i );
return Standard_True;
} else if ( Graphic2d_Primitive::IsOn( SRX, SRY,
Standard_ShortReal(LP.X()), Standard_ShortReal(LP.Y()), aPrecision) ) {
SetPickedIndex( -i - length );
return Standard_True;
}
#else
if ( ( Abs( SRX - P.X() ) + Abs( SRY - P.Y() ) ) < aPrecision ) {
myPickedIndex = i;
return Standard_True;
}
#endif
} // end if NbPoints() > 0
} // end for
} catch( Standard_Failure ) {
return Standard_False;
}
}
return Standard_False;
}
void GGraphic2d_SetOfCurves::Save(Aspect_FStream& aFStream) const
{
int i,lngth = Length();
if ( ! lngth ) return;
*aFStream << "GGraphic2d_SetOfCurves" << endl;
*aFStream << lngth << endl;
Handle(Geom2d_Curve) myCurve;
for ( i = 1; i <= lngth; i++ ) {
myCurve = myCurves.Value( i );
if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Line)) ) {
Handle(Geom2d_Line) theLine = Handle(Geom2d_Line)::DownCast( myCurve );
gp_Dir2d tDir = theLine->Direction();
gp_Pnt2d tPnt = theLine->Location();
*aFStream << "Geom2d_Line" << endl;
*aFStream << tDir.X() << ' ' << tDir.Y() << endl;
*aFStream << tPnt.X() << ' ' << tPnt.Y() << endl;
} else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Circle)) ) {
Handle(Geom2d_Circle) theCirc = Handle(Geom2d_Circle)::DownCast( myCurve );
gp_Circ2d tCirc = theCirc->Circ2d();
gp_Ax22d tAx22d = tCirc.Axis();
gp_Pnt2d tLoc = tAx22d.Location();
gp_Dir2d tDirX = tAx22d.XDirection(),
tDirY = tAx22d.YDirection();
Standard_Real tRad = tCirc.Radius();
*aFStream << "Geom2d_Circle" << endl;
*aFStream << tLoc.X() << ' ' << tLoc.Y() << endl;
*aFStream << tDirX.X() << ' ' << tDirX.Y() << endl;
*aFStream << tDirY.X() << ' ' << tDirY.Y() << endl;
*aFStream << tRad << endl;
} else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Parabola)) ) {
Handle(Geom2d_Parabola) theParab = Handle(Geom2d_Parabola)::DownCast( myCurve );
gp_Parab2d tParab = theParab->Parab2d();
gp_Ax22d tAx22d = tParab.Axis();
gp_Pnt2d tLoc = tAx22d.Location();
gp_Dir2d tDirX = tAx22d.XDirection(),
tDirY = tAx22d.YDirection();
Standard_Real tFocal = theParab->Focal();
*aFStream << "Geom2d_Parabola" << endl;
*aFStream << tLoc.X() << ' ' << tLoc.Y() << endl;
*aFStream << tDirX.X() << ' ' << tDirX.Y() << endl;
*aFStream << tDirY.X() << ' ' << tDirY.Y() << endl;
*aFStream << tFocal << endl;
} else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Ellipse)) ) {
Handle(Geom2d_Ellipse) theEllipse = Handle(Geom2d_Ellipse)::DownCast(myCurve);
gp_Elips2d tElips = theEllipse->Elips2d();
Standard_Real tMin = tElips.MinorRadius(),
tMaj = tElips.MajorRadius();
gp_Ax22d tAx22d = tElips.Axis();
gp_Pnt2d tLoc = tAx22d.Location();
gp_Dir2d tDirX = tAx22d.XDirection(),
tDirY = tAx22d.YDirection();
*aFStream << "Geom2d_Ellipse" << endl;
*aFStream << tMin << ' ' << tMaj << endl;
*aFStream << tLoc.X() << ' ' << tLoc.Y() << endl;
*aFStream << tDirX.X() << ' ' << tDirX.Y() << endl;
*aFStream << tDirY.X() << ' ' << tDirY.Y() << endl;
} else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Hyperbola)) ) {
Handle(Geom2d_Hyperbola) theHypr = Handle(Geom2d_Hyperbola)::DownCast(myCurve);
gp_Hypr2d tHypr = theHypr->Hypr2d();
Standard_Real tMin = tHypr.MinorRadius(),
tMaj = tHypr.MajorRadius();
gp_Ax22d tAx22d = tHypr.Axis();
gp_Pnt2d tLoc = tAx22d.Location();
gp_Dir2d tDirX = tAx22d.XDirection(),
tDirY = tAx22d.YDirection();
*aFStream << "Geom2d_Hyperbola" << endl;
*aFStream << tMin << ' ' << tMaj << endl;
*aFStream << tLoc.X() << ' ' << tLoc.Y() << endl;
*aFStream << tDirX.X() << ' ' << tDirX.Y() << endl;
*aFStream << tDirY.X() << ' ' << tDirY.Y() << endl;
} else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve)) ) {
Handle(Geom2d_BezierCurve) theBC = Handle(Geom2d_BezierCurve)::DownCast(myCurve);
Standard_Integer nbPoles = theBC->NbPoles();
TColgp_Array1OfPnt2d tpoles( 1, nbPoles );
theBC->Poles( tpoles );
*aFStream << "Geom2d_BezierCurve" << endl;
for ( i = 1; i <= nbPoles; i++ )
*aFStream << tpoles(i).X() << ' ' << tpoles(i).Y() << endl;
} else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve)) ) {
Handle(Geom2d_BSplineCurve) theBSC = Handle(Geom2d_BSplineCurve)::DownCast(myCurve);
} else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)) ) {
Handle(Geom2d_OffsetCurve) theOC = Handle(Geom2d_OffsetCurve)::DownCast(myCurve);
} else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)) ) {
Handle(Geom2d_TrimmedCurve) theTC = Handle(Geom2d_TrimmedCurve)::DownCast(myCurve);
}
} // end for
Graphic2d_Line::Save(aFStream);
}

View File

@@ -0,0 +1,21 @@
// File generated by CPPExt (Transient)
//
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
//
#include <GGraphic2d_Curve.hxx>
typedef GGraphic2d_Curve Graphic2d_Curve;
typedef Handle_GGraphic2d_Curve Handle_Graphic2d_Curve ;

View File

@@ -0,0 +1,21 @@
// File generated by CPPExt (Transient)
//
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
//
#include <GGraphic2d_CurveDefinitionError.hxx>
typedef GGraphic2d_CurveDefinitionError Graphic2d_CurveDefinitionError;

View File

@@ -0,0 +1,21 @@
// File generated by CPPExt (Transient)
//
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
//
#include <GGraphic2d_SetOfCurves.hxx>
typedef GGraphic2d_SetOfCurves Graphic2d_SetOfCurves;
typedef Handle_GGraphic2d_SetOfCurves Handle_Graphic2d_SetOfCurves ;