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:
175
src/DrawTrSurf/DrawTrSurf.cdl
Executable file
175
src/DrawTrSurf/DrawTrSurf.cdl
Executable file
@@ -0,0 +1,175 @@
|
||||
-- File: DrawTrSurf.cdl
|
||||
-- Created: Mon Jun 24 11:23:25 1991
|
||||
-- Author: Christophe MARION
|
||||
-- <cma@phobox>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
|
||||
package DrawTrSurf
|
||||
|
||||
---Purpose: This package supports the display of parametric
|
||||
-- curves and surfaces.
|
||||
--
|
||||
-- The Drawable deferred classes is inherited from
|
||||
-- the Drawable3D class from the package Draw, it
|
||||
-- adds methods to draw 3D Curves and Curves on 3D
|
||||
-- Surfaces.
|
||||
--
|
||||
-- The classes Curve Curve2d and Surface are drawable
|
||||
-- and can be used to draw a single curve from
|
||||
-- packages Geom or Geom2d or a surface from Geom.
|
||||
--
|
||||
-- The Triangulation and Polygon from the package
|
||||
-- Poly are also supported.
|
||||
|
||||
uses
|
||||
MMgt,
|
||||
TCollection,
|
||||
TColStd,
|
||||
Draw,
|
||||
Adaptor3d,
|
||||
Adaptor2d,
|
||||
GeomAbs,
|
||||
Geom,
|
||||
Geom2d,
|
||||
gp,
|
||||
Poly
|
||||
|
||||
is
|
||||
|
||||
deferred class Drawable;
|
||||
|
||||
class Point;
|
||||
|
||||
class Curve;
|
||||
|
||||
class BSplineCurve;
|
||||
|
||||
class BezierCurve;
|
||||
|
||||
|
||||
class Curve2d;
|
||||
|
||||
class BSplineCurve2d;
|
||||
|
||||
class BezierCurve2d;
|
||||
|
||||
class Triangulation2D;
|
||||
|
||||
class Surface;
|
||||
|
||||
class BSplineSurface;
|
||||
|
||||
class BezierSurface;
|
||||
|
||||
class Triangulation;
|
||||
|
||||
class Polygon3D;
|
||||
|
||||
class Polygon2D;
|
||||
|
||||
|
||||
--
|
||||
-- package methods to handle named points curves and surface.
|
||||
--
|
||||
|
||||
Set(Name : CString; G : Pnt from gp);
|
||||
---Purpose: Sets <G> in the variable <Name>. Overwrite the
|
||||
-- variable if already set.
|
||||
|
||||
Set(Name : CString; G : Pnt2d from gp);
|
||||
---Purpose: Sets <G> in the variable <Name>. Overwrite the
|
||||
-- variable if already set.
|
||||
|
||||
Set(Name : CString; G : Geometry from Geom);
|
||||
---Purpose: Sets <G> in the variable <Name>. Overwrite the
|
||||
-- variable if already set.
|
||||
|
||||
Set(Name : CString; C : Curve from Geom2d);
|
||||
---Purpose: Sets <C> in the variable <Name>. Overwrite the
|
||||
-- variable if already set.
|
||||
|
||||
Set(Name : CString; T : Triangulation from Poly);
|
||||
---Purpose: Sets <T> in the variable <Name>. Overwrite the
|
||||
-- variable if already set.
|
||||
|
||||
Set(Name : CString; P : Polygon3D from Poly);
|
||||
---Purpose: Sets <P> in the variable <Name>. Overwrite the
|
||||
-- variable if already set.
|
||||
|
||||
Set(Name : CString; P : Polygon2D from Poly);
|
||||
---Purpose: Sets <P> in the variable <Name>. Overwrite the
|
||||
-- variable if already set.
|
||||
|
||||
|
||||
-- if the variable name is a void string a graphic selection is made.
|
||||
|
||||
Get(Name : in out CString) returns Geometry from Geom;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetPoint(Name : in out CString; P : in out Pnt from gp)
|
||||
returns Boolean;
|
||||
---Purpose: Gets the variable. Returns False if none and print
|
||||
-- a warning message.
|
||||
|
||||
GetPoint2d(Name : in out CString; P : in out Pnt2d from gp)
|
||||
returns Boolean;
|
||||
---Purpose: Gets the variable. Returns False if none and print
|
||||
-- a warning message.
|
||||
|
||||
GetCurve(Name : in out CString) returns Curve from Geom;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetBezierCurve(Name : in out CString) returns BezierCurve from Geom;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetBSplineCurve(Name : in out CString) returns BSplineCurve from Geom;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetCurve2d(Name : in out CString) returns Curve from Geom2d;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetBezierCurve2d(Name : in out CString) returns BezierCurve from Geom2d;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetBSplineCurve2d(Name : in out CString) returns BSplineCurve from Geom2d;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetSurface(Name : in out CString) returns Surface from Geom;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetBezierSurface(Name : in out CString) returns BezierSurface from Geom;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetBSplineSurface(Name : in out CString) returns BSplineSurface from Geom;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetTriangulation(Name : in out CString) returns Triangulation from Poly;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetPolygon3D(Name : in out CString) returns Polygon3D from Poly;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
GetPolygon2D(Name : in out CString) returns Polygon2D from Poly;
|
||||
---Purpose: Get the variable <S>. Returns a null handle if
|
||||
-- none, and print a warning message.
|
||||
|
||||
|
||||
|
||||
BasicCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: defines display commands.
|
||||
|
||||
end DrawTrSurf;
|
1696
src/DrawTrSurf/DrawTrSurf.cxx
Executable file
1696
src/DrawTrSurf/DrawTrSurf.cxx
Executable file
File diff suppressed because it is too large
Load Diff
138
src/DrawTrSurf/DrawTrSurf_BSplineCurve.cdl
Executable file
138
src/DrawTrSurf/DrawTrSurf_BSplineCurve.cdl
Executable file
@@ -0,0 +1,138 @@
|
||||
-- File: BSplineCurve.cdl<2>
|
||||
-- Created: Fri May 22 09:53:01 1992
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
-- <jcv@sdsun4>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class BSplineCurve
|
||||
|
||||
|
||||
from DrawTrSurf
|
||||
|
||||
|
||||
inherits Curve from DrawTrSurf
|
||||
|
||||
|
||||
uses BSplineCurve from Geom,
|
||||
Color from Draw,
|
||||
MarkerShape from Draw,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw
|
||||
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create (C : BSplineCurve from Geom)
|
||||
--- Purpose :
|
||||
-- creates a drawable BSpline curve from a BSpline curve of
|
||||
-- package Geom.
|
||||
returns mutable BSplineCurve from DrawTrSurf;
|
||||
|
||||
|
||||
|
||||
Create (C : BSplineCurve from Geom;
|
||||
CurvColor, PolesColor, KnotsColor : Color from Draw;
|
||||
KnotsShape : MarkerShape from Draw; KnotsSize : Integer;
|
||||
ShowPoles, ShowKnots : Boolean; Discret : Integer; Deflection : Real;
|
||||
DrawMode : Integer)
|
||||
--- Purpose :
|
||||
-- creates a drawable BSpline curve from a BSpline curve of
|
||||
-- package Geom.
|
||||
returns mutable BSplineCurve from DrawTrSurf;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw)
|
||||
is redefined static;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw;
|
||||
ShowPoles, ShowKnots : Boolean);
|
||||
|
||||
|
||||
DrawOn (me;
|
||||
dis : in out Display from Draw;
|
||||
U1, U2 : Real;
|
||||
Pindex : Integer;
|
||||
ShowPoles : Boolean = Standard_True;
|
||||
ShowKnots : Boolean = Standard_True);
|
||||
|
||||
|
||||
ShowPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
ShowKnots (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
ClearPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
ClearKnots (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
FindPole(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
Index : in out Integer)
|
||||
--- Purpose :
|
||||
-- Returns in <Index> the index of the first pole of the
|
||||
-- curve projected by the Display <D> at a distance lower
|
||||
-- than <Prec> from <X,Y>. If no pole is found index is
|
||||
-- set to 0, else index is always greater than the input
|
||||
-- value of index.
|
||||
is static;
|
||||
|
||||
|
||||
FindKnot(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
Index : in out Integer)
|
||||
is static;
|
||||
|
||||
|
||||
SetPolesColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
SetKnotsColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
SetKnotsShape (me : mutable; Shape : MarkerShape from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
KnotsShape (me) returns MarkerShape from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
KnotsColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
PolesColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
drawPoles : Boolean;
|
||||
drawKnots : Boolean;
|
||||
knotsForm : MarkerShape from Draw;
|
||||
knotsLook : Color from Draw;
|
||||
knotsDim : Integer;
|
||||
polesLook : Color from Draw;
|
||||
|
||||
end BSplineCurve;
|
||||
|
312
src/DrawTrSurf/DrawTrSurf_BSplineCurve.cxx
Executable file
312
src/DrawTrSurf/DrawTrSurf_BSplineCurve.cxx
Executable file
@@ -0,0 +1,312 @@
|
||||
#include <DrawTrSurf_BSplineCurve.ixx>
|
||||
#include <Draw_MarkerShape.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
|
||||
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
|
||||
DrawTrSurf_BSplineCurve::DrawTrSurf_BSplineCurve (
|
||||
const Handle(Geom_BSplineCurve)& C) :
|
||||
DrawTrSurf_Curve (C, Draw_vert, 16, 0.05, 1) {
|
||||
|
||||
drawKnots = Standard_True;
|
||||
knotsForm = Draw_Losange;
|
||||
knotsLook = Draw_violet;
|
||||
knotsDim = 5;
|
||||
drawPoles = Standard_True;
|
||||
polesLook = Draw_rouge;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DrawTrSurf_BSplineCurve::DrawTrSurf_BSplineCurve (
|
||||
const Handle(Geom_BSplineCurve)& C, const Draw_Color& CurvColor,
|
||||
const Draw_Color& PolesColor, const Draw_Color& KnotsColor,
|
||||
const Draw_MarkerShape KnotsShape, const Standard_Integer KnotsSize,
|
||||
const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots,
|
||||
const Standard_Integer Discret, const Standard_Real Deflection,
|
||||
const Standard_Integer DrawMode)
|
||||
: DrawTrSurf_Curve (C , CurvColor, Discret, Deflection, DrawMode) {
|
||||
|
||||
drawKnots = ShowKnots;
|
||||
knotsForm = KnotsShape;
|
||||
knotsLook = KnotsColor;
|
||||
knotsDim = KnotsSize;
|
||||
drawPoles = ShowPoles;
|
||||
polesLook = PolesColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve::DrawOn (Draw_Display& dis) const {
|
||||
|
||||
|
||||
Handle(Geom_BSplineCurve) C = Handle(Geom_BSplineCurve)::DownCast(curv);
|
||||
if (drawPoles) {
|
||||
Standard_Integer NbPoles = C->NbPoles();
|
||||
dis.SetColor(polesLook);
|
||||
TColgp_Array1OfPnt CPoles (1, NbPoles);
|
||||
C->Poles (CPoles);
|
||||
dis.MoveTo(CPoles(1));
|
||||
for (Standard_Integer i = 2; i <= NbPoles; i++) {
|
||||
dis.DrawTo(CPoles(i));
|
||||
}
|
||||
if (C->IsPeriodic())
|
||||
dis.DrawTo(CPoles(1));
|
||||
}
|
||||
|
||||
DrawTrSurf_Curve::DrawOn(dis);
|
||||
|
||||
if (drawKnots) {
|
||||
Standard_Integer NbKnots = C->NbKnots();
|
||||
TColStd_Array1OfReal CKnots (1, NbKnots);
|
||||
C->Knots (CKnots);
|
||||
dis.SetColor(knotsLook);
|
||||
Standard_Integer first = C->FirstUKnotIndex();
|
||||
Standard_Integer last = C->LastUKnotIndex();
|
||||
for (Standard_Integer i = first; i <= last; i++) {
|
||||
dis.DrawMarker (C->Value (CKnots (i)), knotsForm, knotsDim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve::DrawOn (
|
||||
|
||||
Draw_Display& dis,
|
||||
const Standard_Boolean ShowPoles,
|
||||
const Standard_Boolean ShowKnots
|
||||
) const {
|
||||
|
||||
|
||||
Handle(Geom_BSplineCurve) C = Handle(Geom_BSplineCurve)::DownCast(curv);
|
||||
if (drawPoles && ShowPoles) {
|
||||
Standard_Integer NbPoles = C->NbPoles();
|
||||
dis.SetColor(polesLook);
|
||||
TColgp_Array1OfPnt CPoles (1, NbPoles);
|
||||
C->Poles (CPoles);
|
||||
dis.MoveTo(CPoles(1));
|
||||
for (Standard_Integer i = 2; i <= NbPoles; i++) {
|
||||
dis.DrawTo(CPoles(i));
|
||||
}
|
||||
}
|
||||
|
||||
DrawTrSurf_Curve::DrawOn(dis);
|
||||
|
||||
if (drawKnots && ShowKnots) {
|
||||
Standard_Integer NbKnots = C->NbKnots();
|
||||
TColStd_Array1OfReal CKnots (1, NbKnots);
|
||||
C->Knots (CKnots);
|
||||
dis.SetColor(knotsLook);
|
||||
for (Standard_Integer i = 1; i <= NbKnots; i++) {
|
||||
dis.DrawMarker (C->Value (CKnots (i)), knotsForm, knotsDim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve::DrawOn (
|
||||
|
||||
Draw_Display& dis,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Integer Pindex,
|
||||
const Standard_Boolean ShowPoles,
|
||||
const Standard_Boolean ShowKnots
|
||||
) const {
|
||||
|
||||
|
||||
Handle(Geom_BSplineCurve) C = Handle(Geom_BSplineCurve)::DownCast(curv);
|
||||
Standard_Real Eps1 = Abs(Epsilon (U1));
|
||||
Standard_Real Eps2 = Abs(Epsilon (U2));
|
||||
Standard_Integer I1, J1, I2, J2;
|
||||
C->LocateU (U1, Eps1, I1, J1);
|
||||
C->LocateU (U2, Eps2, I2, J2);
|
||||
Standard_Integer ka = C->FirstUKnotIndex ();
|
||||
Standard_Integer kb = C->LastUKnotIndex ();
|
||||
|
||||
|
||||
if (drawPoles && ShowPoles) {
|
||||
Standard_Integer NbPoles = C->NbPoles();
|
||||
dis.SetColor(polesLook);
|
||||
TColgp_Array1OfPnt CPoles (1, NbPoles);
|
||||
C->Poles (CPoles);
|
||||
if (Pindex == 0) {
|
||||
dis.MoveTo(CPoles(1));
|
||||
for (Standard_Integer i = 2; i <= NbPoles; i++) {
|
||||
dis.DrawTo(CPoles(i));
|
||||
}
|
||||
}
|
||||
else if (Pindex == 1) {
|
||||
dis.MoveTo(CPoles(1));
|
||||
dis.DrawTo(CPoles(2));
|
||||
}
|
||||
else if (Pindex == NbPoles) {
|
||||
dis.MoveTo(CPoles(NbPoles-1));
|
||||
dis.DrawTo(CPoles(NbPoles));
|
||||
}
|
||||
else {
|
||||
dis.MoveTo(CPoles(Pindex-1));
|
||||
dis.DrawTo(CPoles(Pindex));
|
||||
dis.DrawTo(CPoles(Pindex+1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
dis.SetColor(look);
|
||||
Standard_Integer Degree = C->Degree();
|
||||
|
||||
if (Degree == 1) {
|
||||
dis.MoveTo(C->Value(U1));
|
||||
dis.DrawTo(C->Value(U2));
|
||||
}
|
||||
else {
|
||||
Standard_Integer NbPoints;
|
||||
Standard_Integer Discret = GetDiscretisation();
|
||||
Standard_Real Ustart = C->Knot (ka);
|
||||
Standard_Real Uend = C->Knot (kb);
|
||||
Standard_Real Du, U, Ua, Ub, Uk1, Uk2;
|
||||
|
||||
if (I1 > ka) { ka = I1; Uk1 = U1; }
|
||||
else {
|
||||
U = U1;
|
||||
NbPoints = (Standard_Integer) Abs (Discret * (U1 - Ustart) / (Ustart - Uend));
|
||||
NbPoints = Max (NbPoints, 30);
|
||||
Du = (Ustart - U1) / NbPoints;
|
||||
dis.MoveTo(C->Value (U));
|
||||
for (Standard_Integer i = 1; i <= NbPoints - 2; i++) {
|
||||
U+= Du;
|
||||
dis.DrawTo(C->Value (U));
|
||||
}
|
||||
dis.DrawTo(C->Value (Ustart));
|
||||
Uk1 = Ustart;
|
||||
}
|
||||
|
||||
if (J2 < kb) { kb = J2; Uk2 = U2; }
|
||||
else {
|
||||
Uk2 = Uend;
|
||||
U = Uend;
|
||||
NbPoints = (Standard_Integer) Abs (Discret * (U2 - Uend) / (Ustart - Uend));
|
||||
NbPoints = Max (NbPoints, 30);
|
||||
Du = (U2 - Uend) / NbPoints;
|
||||
dis.MoveTo(C->Value (U));
|
||||
for (Standard_Integer i = 1; i <= NbPoints - 2; i++) {
|
||||
U+= Du;
|
||||
dis.DrawTo(C->Value (U));
|
||||
}
|
||||
dis.DrawTo(C->Value (U2));
|
||||
}
|
||||
|
||||
|
||||
for (Standard_Integer k = ka; k < kb; k++) {
|
||||
if (k == ka) {
|
||||
Ua = Uk1;
|
||||
Ub = C->Knot (k+1);
|
||||
}
|
||||
else if (k == kb-1) {
|
||||
Ua = C->Knot (k);
|
||||
Ub = Uk2;
|
||||
}
|
||||
else {
|
||||
Ua = C->Knot (k);
|
||||
Ub = C->Knot (k+1);
|
||||
}
|
||||
U = Ua;
|
||||
NbPoints = (Standard_Integer) Abs (Discret * (Ua - Ub) / (Ustart - Uend));
|
||||
NbPoints = Max (NbPoints, 30);
|
||||
Du = (Ub - Ua) / NbPoints;
|
||||
dis.MoveTo(C->Value (U));
|
||||
for (Standard_Integer i = 1; i <= NbPoints - 2; i++) {
|
||||
U+= Du;
|
||||
dis.DrawTo(C->Value (U));
|
||||
}
|
||||
dis.DrawTo(C->Value (Ub));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (drawKnots && ShowKnots) {
|
||||
Standard_Integer NbKnots = C->NbKnots();
|
||||
TColStd_Array1OfReal CKnots (1, NbKnots);
|
||||
C->Knots (CKnots);
|
||||
dis.SetColor(knotsLook);
|
||||
for (Standard_Integer i = J1; i <= I2; i++) {
|
||||
dis.DrawMarker (C->Value (CKnots (i)), knotsForm, knotsDim);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve::ShowPoles () { drawPoles = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve::ShowKnots () { drawKnots = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve::ClearPoles () { drawPoles = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve::ClearKnots () { drawKnots = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve::FindPole (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real XPrec,
|
||||
Standard_Integer& Index) const {
|
||||
|
||||
Handle(Geom_BSplineCurve) bc = Handle(Geom_BSplineCurve)::DownCast(curv);
|
||||
Standard_Real Prec = XPrec / D.Zoom();
|
||||
gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
|
||||
Index++;
|
||||
Standard_Integer NbPoles = bc->NbPoles();
|
||||
while (Index <= NbPoles) {
|
||||
if (D.Project(bc->Pole(Index)).Distance(p1) <= Prec)
|
||||
return;
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve::FindKnot (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec,
|
||||
Standard_Integer& Index) const {
|
||||
|
||||
Handle(Geom_BSplineCurve) bc = Handle(Geom_BSplineCurve)::DownCast(curv);
|
||||
gp_Pnt2d p1(X,Y);
|
||||
Index++;
|
||||
Standard_Integer NbKnots = bc->NbKnots();
|
||||
while (Index <= NbKnots) {
|
||||
if (D.Project(bc->Value(bc->Knot(Index))).Distance(p1) <= Prec)
|
||||
return;
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve::Copy()const
|
||||
{
|
||||
Handle(DrawTrSurf_BSplineCurve) DC = new DrawTrSurf_BSplineCurve
|
||||
(Handle(Geom_BSplineCurve)::DownCast(curv->Copy()),
|
||||
look,polesLook,knotsLook,knotsForm,knotsDim,
|
||||
drawPoles,drawKnots,
|
||||
GetDiscretisation(),GetDeflection(),GetDrawMode());
|
||||
|
||||
return DC;
|
||||
}
|
||||
|
||||
|
38
src/DrawTrSurf/DrawTrSurf_BSplineCurve.lxx
Executable file
38
src/DrawTrSurf/DrawTrSurf_BSplineCurve.lxx
Executable file
@@ -0,0 +1,38 @@
|
||||
|
||||
inline void DrawTrSurf_BSplineCurve::SetPolesColor (
|
||||
const Draw_Color& aColor) {
|
||||
|
||||
polesLook = aColor;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_BSplineCurve::SetKnotsColor (
|
||||
const Draw_Color& aColor) {
|
||||
|
||||
knotsLook = aColor;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_BSplineCurve::SetKnotsShape (
|
||||
const Draw_MarkerShape Shape) {
|
||||
|
||||
knotsForm = Shape;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_MarkerShape DrawTrSurf_BSplineCurve::KnotsShape () const {
|
||||
|
||||
return knotsForm;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_BSplineCurve::KnotsColor () const {
|
||||
|
||||
return knotsLook;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_BSplineCurve::PolesColor () const {
|
||||
|
||||
return polesLook;
|
||||
}
|
108
src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cdl
Executable file
108
src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cdl
Executable file
@@ -0,0 +1,108 @@
|
||||
|
||||
-- File: BSplineCurve2d.cdl
|
||||
-- Created: Fri May 22 10:46:49 1992
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
-- <jcv@sdsun4>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class BSplineCurve2d
|
||||
|
||||
|
||||
from DrawTrSurf
|
||||
|
||||
|
||||
inherits Curve2d from DrawTrSurf
|
||||
|
||||
|
||||
uses BSplineCurve from Geom2d,
|
||||
Color from Draw,
|
||||
MarkerShape from Draw,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw
|
||||
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create (C : BSplineCurve from Geom2d)
|
||||
--- Purpose :
|
||||
-- creates a drawable BSpline curve from a BSpline curve of
|
||||
-- package Geom2d.
|
||||
returns mutable BSplineCurve2d from DrawTrSurf;
|
||||
|
||||
|
||||
Create (C : BSplineCurve from Geom2d;
|
||||
CurvColor, PolesColor, KnotsColor : Color from Draw;
|
||||
KnotsShape : MarkerShape from Draw; KnotsSize : Integer;
|
||||
ShowPoles, ShowKnots : Boolean; Discret : Integer)
|
||||
returns mutable BSplineCurve2d from DrawTrSurf;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw)
|
||||
is redefined static;
|
||||
|
||||
ShowPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
ShowKnots (me : mutable)
|
||||
is static;
|
||||
|
||||
ClearPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
ClearKnots (me : mutable)
|
||||
is static;
|
||||
|
||||
FindPole(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
Index : in out Integer)
|
||||
---Purpose: Returns in <Index> the index of the first pole of the
|
||||
-- curve projected by the Display <D> at a distance lower
|
||||
-- than <Prec> from <X,Y>. If no pole is found index is
|
||||
-- set to 0, else index is always greater than the input
|
||||
-- value of index.
|
||||
is static;
|
||||
|
||||
FindKnot(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
Index : in out Integer)
|
||||
is static;
|
||||
|
||||
SetPolesColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
SetKnotsColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
SetKnotsShape (me : mutable; Shape : MarkerShape from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
KnotsShape (me) returns MarkerShape from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
KnotsColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
PolesColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
drawPoles : Boolean;
|
||||
drawKnots : Boolean;
|
||||
knotsForm : MarkerShape from Draw;
|
||||
knotsLook : Color from Draw;
|
||||
knotsDim : Integer;
|
||||
polesLook : Color from Draw;
|
||||
|
||||
end BSplineCurve2d;
|
142
src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx
Executable file
142
src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx
Executable file
@@ -0,0 +1,142 @@
|
||||
#include <DrawTrSurf_BSplineCurve2d.ixx>
|
||||
#include <Draw_MarkerShape.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
|
||||
DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (
|
||||
const Handle(Geom2d_BSplineCurve)& C)
|
||||
: DrawTrSurf_Curve2d (C, Draw_vert, 100) {
|
||||
|
||||
drawKnots = Standard_True;
|
||||
knotsForm = Draw_Losange;
|
||||
knotsLook = Draw_violet;
|
||||
knotsDim = 5;
|
||||
drawPoles = Standard_True;
|
||||
polesLook = Draw_rouge;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (
|
||||
const Handle(Geom2d_BSplineCurve)& C, const Draw_Color& CurvColor,
|
||||
const Draw_Color& PolesColor, const Draw_Color& KnotsColor,
|
||||
const Draw_MarkerShape KnotsShape, const Standard_Integer KnotsSize,
|
||||
const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots, const Standard_Integer Discret)
|
||||
: DrawTrSurf_Curve2d (C, CurvColor, Discret) {
|
||||
|
||||
drawKnots = ShowKnots;
|
||||
knotsForm = KnotsShape;
|
||||
knotsLook = KnotsColor;
|
||||
knotsDim = KnotsSize;
|
||||
drawPoles = ShowPoles;
|
||||
polesLook = PolesColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::DrawOn (Draw_Display& dis) const
|
||||
{
|
||||
|
||||
Handle(Geom2d_BSplineCurve) C = Handle(Geom2d_BSplineCurve)::DownCast(curv);
|
||||
|
||||
if (drawPoles) {
|
||||
Standard_Integer NbPoles = C->NbPoles();
|
||||
dis.SetColor(polesLook);
|
||||
TColgp_Array1OfPnt2d CPoles (1, NbPoles);
|
||||
C->Poles (CPoles);
|
||||
dis.MoveTo(CPoles(1));
|
||||
for (Standard_Integer i = 2; i <= NbPoles; i++) {
|
||||
dis.DrawTo(CPoles(i));
|
||||
}
|
||||
if (C->IsPeriodic())
|
||||
dis.DrawTo(CPoles(1));
|
||||
}
|
||||
|
||||
DrawTrSurf_Curve2d::DrawOn(dis);
|
||||
|
||||
if (drawKnots) {
|
||||
Standard_Integer NbKnots = C->NbKnots();
|
||||
TColStd_Array1OfReal CKnots (1, NbKnots);
|
||||
C->Knots (CKnots);
|
||||
dis.SetColor(knotsLook);
|
||||
for (Standard_Integer i = 1; i <= NbKnots; i++) {
|
||||
gp_Pnt2d P = C->Value(CKnots(i));
|
||||
dis.DrawMarker (P, knotsForm, knotsDim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::ShowPoles () { drawPoles = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::ShowKnots () { drawKnots = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::ClearPoles () { drawPoles = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::ClearKnots () { drawKnots = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::FindPole (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real XPrec,
|
||||
Standard_Integer& Index) const {
|
||||
|
||||
Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
|
||||
Standard_Real Prec = XPrec / D.Zoom();
|
||||
gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
|
||||
Index++;
|
||||
Standard_Integer NbPoles = bc->NbPoles();
|
||||
gp_Pnt P;
|
||||
gp_Pnt2d P2d;
|
||||
while (Index <= NbPoles) {
|
||||
P2d = bc->Pole(Index);
|
||||
P.SetCoord (P2d.X(), P2d.Y(), 0.0);
|
||||
if (D.Project(P).Distance(p1) <= Prec)
|
||||
return;
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::FindKnot (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec,
|
||||
Standard_Integer& Index) const {
|
||||
|
||||
Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
|
||||
gp_Pnt2d P2d;
|
||||
gp_Pnt P;
|
||||
gp_Pnt2d p1(X,Y);
|
||||
Index++;
|
||||
Standard_Integer NbKnots = bc->NbKnots();
|
||||
while (Index <= NbKnots) {
|
||||
P2d = bc->Value(bc->Knot(Index));
|
||||
P.SetCoord (P2d.X(), P2d.Y(), 0.0);
|
||||
if (D.Project(P).Distance(p1) <= Prec)
|
||||
return;
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve2d::Copy()const
|
||||
{
|
||||
Handle(DrawTrSurf_BSplineCurve2d) DC = new DrawTrSurf_BSplineCurve2d
|
||||
(Handle(Geom2d_BSplineCurve)::DownCast(curv->Copy()),
|
||||
look,polesLook,knotsLook,knotsForm,knotsDim,
|
||||
drawPoles,drawKnots,
|
||||
GetDiscretisation());
|
||||
|
||||
return DC;
|
||||
}
|
||||
|
39
src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.lxx
Executable file
39
src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.lxx
Executable file
@@ -0,0 +1,39 @@
|
||||
|
||||
inline void DrawTrSurf_BSplineCurve2d::SetPolesColor (
|
||||
const Draw_Color& aColor) {
|
||||
|
||||
polesLook = aColor;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_BSplineCurve2d::SetKnotsColor (
|
||||
const Draw_Color& aColor) {
|
||||
|
||||
knotsLook = aColor;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_BSplineCurve2d::SetKnotsShape (
|
||||
const Draw_MarkerShape Shape) {
|
||||
|
||||
knotsForm = Shape;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_MarkerShape DrawTrSurf_BSplineCurve2d::KnotsShape () const {
|
||||
|
||||
return knotsForm;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_BSplineCurve2d::KnotsColor () const {
|
||||
|
||||
return knotsLook;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_BSplineCurve2d::PolesColor () const {
|
||||
|
||||
return polesLook;
|
||||
}
|
||||
|
155
src/DrawTrSurf/DrawTrSurf_BSplineSurface.cdl
Executable file
155
src/DrawTrSurf/DrawTrSurf_BSplineSurface.cdl
Executable file
@@ -0,0 +1,155 @@
|
||||
-- File: BSplineSurface.cdl
|
||||
-- Created: Fri May 22 10:29:42 1992
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class BSplineSurface from DrawTrSurf
|
||||
|
||||
inherits Surface from DrawTrSurf
|
||||
|
||||
--- Purpose :
|
||||
-- This class defines a drawable BSplineSurface.
|
||||
-- With this class you can draw the control points and the knots
|
||||
-- of the surface.
|
||||
-- You can use the general class Surface from DrawTrSurf too,
|
||||
-- if you just want to sea boundaries and isoparametric curves.
|
||||
|
||||
uses BSplineSurface from Geom,
|
||||
Color from Draw,
|
||||
MarkerShape from Draw,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw
|
||||
|
||||
is
|
||||
|
||||
|
||||
|
||||
Create (S : BSplineSurface from Geom)
|
||||
returns mutable BSplineSurface from DrawTrSurf;
|
||||
--- Purpose : default drawing mode.
|
||||
-- The isoparametric curves corresponding to the knots values are
|
||||
-- drawn.
|
||||
-- The control points and the knots points are drawn.
|
||||
-- The boundaries are yellow, the isoparametric curves are blues.
|
||||
-- For the discretisation 50 points are computed in each parametric
|
||||
-- direction.
|
||||
|
||||
|
||||
Create (S : BSplineSurface from Geom;
|
||||
BoundsColor, IsosColor, PolesColor, KnotsColor : Color from Draw;
|
||||
KnotsShape : MarkerShape from Draw; KnotsSize : Integer;
|
||||
ShowPoles, ShowKnots : Boolean; Discret : Integer; Deflection : Real;
|
||||
DrawMode : Integer)
|
||||
returns mutable BSplineSurface from DrawTrSurf;
|
||||
--- Purpose :
|
||||
-- The isoparametric curves corresponding to the knots values are
|
||||
-- drawn.
|
||||
|
||||
|
||||
|
||||
Create (S : BSplineSurface from Geom;
|
||||
NbUIsos, NbVIsos : Integer;
|
||||
BoundsColor, IsosColor, PolesColor, KnotsColor : Color from Draw;
|
||||
KnotsShape : MarkerShape from Draw; KnotsSize : Integer;
|
||||
ShowPoles, ShowKnots : Boolean; Discret : Integer; Deflection : Real;
|
||||
DrawMode : Integer)
|
||||
returns mutable BSplineSurface from DrawTrSurf;
|
||||
--- Purpose : Parametric equidistant iso curves are drawn.
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw)
|
||||
is redefined static;
|
||||
|
||||
|
||||
ShowPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
ShowKnots (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
ShowIsos (me : mutable; Nu, Nv : Integer)
|
||||
--- Purpose : change the number of isoparametric curves to be drawn.
|
||||
is redefined;
|
||||
|
||||
|
||||
ShowKnotsIsos (me : mutable)
|
||||
--- Purpose : change the number of isoparametric curves to be drawn.
|
||||
is static;
|
||||
|
||||
|
||||
ClearIsos (me : mutable)
|
||||
--- Purpose : rub out all the isoparametric curves.
|
||||
is redefined;
|
||||
|
||||
|
||||
ClearPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
ClearKnots (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
FindPole(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
UIndex, VIndex : in out Integer)
|
||||
is static;
|
||||
|
||||
|
||||
FindUKnot(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
UIndex : in out Integer)
|
||||
is static;
|
||||
|
||||
|
||||
FindVKnot(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
VIndex : in out Integer)
|
||||
is static;
|
||||
|
||||
|
||||
SetPolesColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
SetKnotsColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
SetKnotsShape (me : mutable; Shape : MarkerShape from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
KnotsShape (me) returns MarkerShape from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
KnotsColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
PolesColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
drawPoles : Boolean;
|
||||
drawKnots : Boolean;
|
||||
knotsIsos : Boolean;
|
||||
knotsForm : MarkerShape from Draw;
|
||||
knotsLook : Color from Draw;
|
||||
knotsDim : Integer;
|
||||
polesLook : Color from Draw;
|
||||
|
||||
end BSplineSurface;
|
287
src/DrawTrSurf/DrawTrSurf_BSplineSurface.cxx
Executable file
287
src/DrawTrSurf/DrawTrSurf_BSplineSurface.cxx
Executable file
@@ -0,0 +1,287 @@
|
||||
#include <DrawTrSurf_BSplineSurface.ixx>
|
||||
#include <DrawTrSurf_BSplineCurve.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Draw_MarkerShape.hxx>
|
||||
#include <GeomAdaptor_HSurface.hxx>
|
||||
#include <GeomAdaptor_Surface.hxx>
|
||||
#include <Adaptor3d_IsoCurve.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
|
||||
|
||||
DrawTrSurf_BSplineSurface::DrawTrSurf_BSplineSurface (
|
||||
const Handle(Geom_BSplineSurface)& S)
|
||||
: DrawTrSurf_Surface (S, S->NbUKnots()-2, S->NbVKnots()-2,
|
||||
Draw_jaune, Draw_bleu, 30, 0.05, 0){
|
||||
|
||||
drawPoles = Standard_True;
|
||||
drawKnots = Standard_True;
|
||||
knotsIsos = Standard_True;
|
||||
knotsForm = Draw_Losange;
|
||||
knotsLook = Draw_violet;
|
||||
knotsDim = 5;
|
||||
polesLook = Draw_rouge;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DrawTrSurf_BSplineSurface::DrawTrSurf_BSplineSurface (
|
||||
const Handle(Geom_BSplineSurface)& S, const Draw_Color& BoundsColor,
|
||||
const Draw_Color& IsosColor, const Draw_Color& PolesColor,
|
||||
const Draw_Color& KnotsColor, const Draw_MarkerShape KnotsShape,
|
||||
const Standard_Integer KnotsSize, const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots,
|
||||
const Standard_Integer Discret, const Standard_Real Deflection, const Standard_Integer DrawMode)
|
||||
: DrawTrSurf_Surface (S, S->NbUKnots()-2, S->NbVKnots()-2, BoundsColor,
|
||||
IsosColor, Discret, Deflection, DrawMode){
|
||||
|
||||
knotsIsos = Standard_True;
|
||||
drawPoles = ShowPoles;
|
||||
drawKnots = ShowKnots;
|
||||
knotsForm = KnotsShape;
|
||||
knotsLook = KnotsColor;
|
||||
knotsDim = KnotsSize;
|
||||
polesLook = PolesColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DrawTrSurf_BSplineSurface::DrawTrSurf_BSplineSurface (
|
||||
const Handle(Geom_BSplineSurface)& S, const Standard_Integer NbUIsos,
|
||||
const Standard_Integer NbVIsos, const Draw_Color& BoundsColor,
|
||||
const Draw_Color& IsosColor, const Draw_Color& PolesColor,
|
||||
const Draw_Color& KnotsColor, const Draw_MarkerShape KnotsShape,
|
||||
const Standard_Integer KnotsSize, const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots,
|
||||
const Standard_Integer Discret, const Standard_Real Deflection, const Standard_Integer DrawMode)
|
||||
: DrawTrSurf_Surface (S, Abs(NbUIsos), Abs(NbVIsos), BoundsColor,
|
||||
IsosColor, Discret, Deflection, DrawMode){
|
||||
|
||||
knotsIsos = Standard_False;
|
||||
drawPoles = ShowPoles;
|
||||
drawKnots = ShowKnots;
|
||||
knotsForm = KnotsShape;
|
||||
knotsLook = KnotsColor;
|
||||
knotsDim = KnotsSize;
|
||||
polesLook = PolesColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::DrawOn (Draw_Display& dis) const {
|
||||
|
||||
Handle(Geom_BSplineSurface) S = Handle(Geom_BSplineSurface)::DownCast(surf);
|
||||
Standard_Integer i, j;
|
||||
|
||||
Standard_Real Ua,Ub,Va,Vb;
|
||||
S->Bounds(Ua,Ub,Va,Vb);
|
||||
|
||||
if (drawPoles) {
|
||||
Standard_Integer NbUPoles = S->NbUPoles();
|
||||
Standard_Integer NbVPoles = S->NbVPoles();
|
||||
dis.SetColor(polesLook);
|
||||
TColgp_Array2OfPnt SPoles (1, NbUPoles, 1, NbVPoles);
|
||||
S->Poles (SPoles);
|
||||
for (j = 1; j <= NbVPoles; j++) {
|
||||
dis.MoveTo(SPoles(1, j));
|
||||
for (i = 2; i <= NbUPoles; i++) {
|
||||
dis.DrawTo(SPoles(i, j));
|
||||
}
|
||||
if (S->IsUPeriodic())
|
||||
dis.DrawTo(SPoles(1,j));
|
||||
}
|
||||
for (i = 1; i <= NbUPoles; i++) {
|
||||
dis.MoveTo(SPoles(i, 1));
|
||||
for (j = 2; j <= NbVPoles; j++) {
|
||||
dis.DrawTo(SPoles(i, j));
|
||||
}
|
||||
if (S->IsVPeriodic())
|
||||
dis.DrawTo(SPoles(i,1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (knotsIsos) {
|
||||
Standard_Integer first, last;
|
||||
Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
|
||||
HS->ChangeSurface().Load(surf);
|
||||
|
||||
Adaptor3d_IsoCurve C(HS);
|
||||
|
||||
dis.SetColor(isosLook);
|
||||
first = S->FirstUKnotIndex() + 1;
|
||||
last = S->LastUKnotIndex() - 1;
|
||||
for (i = first; i <= last; i++) {
|
||||
DrawIsoCurveOn(C,GeomAbs_IsoU,S->UKnot(i),Va,Vb,dis);
|
||||
}
|
||||
first = S->FirstVKnotIndex() + 1;
|
||||
last = S->LastVKnotIndex() - 1;
|
||||
for (j = first; j <= last; j++) {
|
||||
DrawIsoCurveOn(C,GeomAbs_IsoV,S->VKnot(j),Ua,Ub,dis);
|
||||
}
|
||||
}
|
||||
|
||||
DrawTrSurf_Surface::DrawOn(dis,!knotsIsos);
|
||||
|
||||
if (drawKnots) {
|
||||
Standard_Integer first, last;
|
||||
Standard_Integer NbUKnots = S->NbUKnots();
|
||||
TColStd_Array1OfReal SUKnots (1, NbUKnots);
|
||||
S->UKnots (SUKnots);
|
||||
dis.SetColor(knotsLook);
|
||||
first = S->FirstUKnotIndex();
|
||||
last = S->LastUKnotIndex();
|
||||
for (i = first; i <= last; i++) {
|
||||
dis.DrawMarker (S->Value (SUKnots(i), Va), knotsForm, knotsDim);
|
||||
}
|
||||
Standard_Integer NbVKnots = S->NbVKnots();
|
||||
TColStd_Array1OfReal SVKnots (1, NbVKnots);
|
||||
S->VKnots (SVKnots);
|
||||
dis.SetColor(knotsLook);
|
||||
first = S->FirstVKnotIndex();
|
||||
last = S->LastVKnotIndex();
|
||||
for (j = first; j <= last; j++) {
|
||||
dis.DrawMarker (S->Value (Ua, SVKnots(j)), knotsForm, knotsDim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::ShowPoles () { drawPoles = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::ShowKnots () { drawKnots = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::ClearPoles () { drawPoles = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::ShowKnotsIsos () {
|
||||
knotsIsos = Standard_True;
|
||||
Handle(Geom_BSplineSurface) S = Handle(Geom_BSplineSurface)::DownCast(surf);
|
||||
nbUIsos = S->NbUKnots()-2;
|
||||
nbVIsos = S->NbVKnots()-2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::ClearIsos () {
|
||||
|
||||
knotsIsos = Standard_False;
|
||||
nbUIsos = 0;
|
||||
nbVIsos = 0;
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::ShowIsos (
|
||||
const Standard_Integer Nu, const Standard_Integer Nv) {
|
||||
|
||||
knotsIsos = Standard_False;
|
||||
nbUIsos = Abs(Nu);
|
||||
nbVIsos = Abs(Nv);
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::ClearKnots () { drawKnots = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::FindPole (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real XPrec,
|
||||
Standard_Integer& UIndex, Standard_Integer& VIndex) const {
|
||||
|
||||
Handle(Geom_BSplineSurface) bs = Handle(Geom_BSplineSurface)::DownCast(surf);
|
||||
gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
|
||||
Standard_Real Prec = XPrec / D.Zoom();
|
||||
UIndex++;
|
||||
VIndex++;
|
||||
Standard_Integer NbUPoles = bs->NbUPoles();
|
||||
Standard_Integer NbVPoles = bs->NbVPoles();
|
||||
while (VIndex <= NbVPoles) {
|
||||
while (UIndex <= NbUPoles) {
|
||||
if (D.Project(bs->Pole(UIndex, VIndex)).Distance(p1) <= Prec)
|
||||
return;
|
||||
UIndex++;
|
||||
}
|
||||
UIndex = 1;
|
||||
VIndex++;
|
||||
}
|
||||
UIndex = VIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::FindUKnot (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec,
|
||||
Standard_Integer& UIndex) const {
|
||||
|
||||
Handle(Geom_BSplineSurface) bs = Handle(Geom_BSplineSurface)::DownCast(surf);
|
||||
gp_Pnt2d p1(X,Y);
|
||||
UIndex++;
|
||||
Standard_Integer NbUKnots = bs->NbUKnots();
|
||||
Standard_Real U1, U2, V1, V2;
|
||||
surf->Bounds (U1, U2, V1, V2);
|
||||
while (UIndex <= NbUKnots) {
|
||||
if (D.Project(bs->Value(bs->UKnot(UIndex), V1)).Distance(p1) <= Prec)
|
||||
return;
|
||||
UIndex++;
|
||||
}
|
||||
UIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineSurface::FindVKnot (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec,
|
||||
Standard_Integer& VIndex) const {
|
||||
|
||||
|
||||
Handle(Geom_BSplineSurface) bs = Handle(Geom_BSplineSurface)::DownCast(surf);
|
||||
gp_Pnt2d p1(X,Y);
|
||||
VIndex++;
|
||||
Standard_Integer NbVKnots = bs->NbVKnots();
|
||||
Standard_Real U1, U2, V1, V2;
|
||||
surf->Bounds (U1, U2, V1, V2);
|
||||
while (VIndex <= NbVKnots) {
|
||||
if (D.Project(bs->Value(U1, bs->VKnot(VIndex))).Distance(p1) <= Prec)
|
||||
return;
|
||||
VIndex++;
|
||||
}
|
||||
VIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_BSplineSurface::Copy()const
|
||||
{
|
||||
Handle(DrawTrSurf_BSplineSurface) DS;
|
||||
if (!knotsIsos)
|
||||
DS = new DrawTrSurf_BSplineSurface
|
||||
(Handle(Geom_BSplineSurface)::DownCast(surf->Copy()),
|
||||
nbUIsos,nbVIsos,
|
||||
boundsLook,isosLook,polesLook,knotsLook,
|
||||
knotsForm,knotsDim,drawPoles,drawKnots,
|
||||
GetDiscretisation(),GetDeflection(),GetDrawMode());
|
||||
else
|
||||
DS = new DrawTrSurf_BSplineSurface
|
||||
(Handle(Geom_BSplineSurface)::DownCast(surf->Copy()),
|
||||
boundsLook,isosLook,polesLook,knotsLook,
|
||||
knotsForm,knotsDim,drawPoles,drawKnots,
|
||||
GetDiscretisation(),GetDeflection(),GetDrawMode());
|
||||
|
||||
return DS;
|
||||
|
||||
}
|
||||
|
||||
|
39
src/DrawTrSurf/DrawTrSurf_BSplineSurface.lxx
Executable file
39
src/DrawTrSurf/DrawTrSurf_BSplineSurface.lxx
Executable file
@@ -0,0 +1,39 @@
|
||||
|
||||
|
||||
inline void DrawTrSurf_BSplineSurface::SetKnotsColor (
|
||||
const Draw_Color& aColor) {
|
||||
|
||||
knotsLook = aColor;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_BSplineSurface::SetKnotsShape (
|
||||
const Draw_MarkerShape Shape) {
|
||||
|
||||
knotsForm = Shape;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_BSplineSurface::SetPolesColor (
|
||||
const Draw_Color& aColor) {
|
||||
|
||||
polesLook = aColor;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_MarkerShape DrawTrSurf_BSplineSurface::KnotsShape () const {
|
||||
|
||||
return knotsForm;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_BSplineSurface::KnotsColor () const {
|
||||
|
||||
return knotsLook;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_BSplineSurface::PolesColor () const {
|
||||
|
||||
return polesLook;
|
||||
}
|
82
src/DrawTrSurf/DrawTrSurf_BezierCurve.cdl
Executable file
82
src/DrawTrSurf/DrawTrSurf_BezierCurve.cdl
Executable file
@@ -0,0 +1,82 @@
|
||||
-- File: BezierCurve.cdl<2>
|
||||
-- Created: Fri May 22 10:25:55 1992
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
-- <jcv@sdsun4>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class BezierCurve
|
||||
|
||||
|
||||
from DrawTrSurf
|
||||
|
||||
|
||||
inherits Curve from DrawTrSurf
|
||||
|
||||
|
||||
uses BezierCurve from Geom,
|
||||
Color from Draw,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw
|
||||
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create (C : BezierCurve from Geom)
|
||||
--- Purpose :
|
||||
-- creates a drawable Bezier curve from a Bezier curve of
|
||||
-- package Geom.
|
||||
returns mutable BezierCurve from DrawTrSurf;
|
||||
|
||||
|
||||
Create (C : BezierCurve from Geom;
|
||||
CurvColor, PolesColor : Color from Draw;
|
||||
ShowPoles : Boolean; Discret : Integer;Deflection : Real;
|
||||
DrawMode : Integer)
|
||||
returns mutable BezierCurve from DrawTrSurf;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw)
|
||||
is redefined static;
|
||||
|
||||
|
||||
ShowPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
ClearPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
FindPole(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
Index : in out Integer)
|
||||
--- Purpose :
|
||||
-- Returns in <Index> the index of the first pole of the
|
||||
-- curve projected by the Display <D> at a distance lower
|
||||
-- than <Prec> from <X,Y>. If no pole is found index is
|
||||
-- set to 0, else index is always greater than the input
|
||||
-- value of index.
|
||||
is static;
|
||||
|
||||
|
||||
SetPolesColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
PolesColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
drawPoles : Boolean;
|
||||
polesLook : Color from Draw;
|
||||
|
||||
end BezierCurve;
|
93
src/DrawTrSurf/DrawTrSurf_BezierCurve.cxx
Executable file
93
src/DrawTrSurf/DrawTrSurf_BezierCurve.cxx
Executable file
@@ -0,0 +1,93 @@
|
||||
#include <DrawTrSurf_BezierCurve.ixx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
DrawTrSurf_BezierCurve::DrawTrSurf_BezierCurve (
|
||||
const Handle(Geom_BezierCurve)& C)
|
||||
: DrawTrSurf_Curve (C, Draw_vert, 16, 0.05, 1) {
|
||||
|
||||
drawPoles = Standard_True;
|
||||
polesLook = Draw_rouge;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DrawTrSurf_BezierCurve::DrawTrSurf_BezierCurve (
|
||||
const Handle(Geom_BezierCurve)& C, const Draw_Color& CurvColor,
|
||||
const Draw_Color& PolesColor, const Standard_Boolean ShowPoles,
|
||||
const Standard_Integer Discret,const Standard_Real Deflection,
|
||||
const Standard_Integer DrawMode ) :
|
||||
DrawTrSurf_Curve (C, CurvColor, Discret, Deflection, DrawMode) {
|
||||
|
||||
drawPoles = ShowPoles;
|
||||
polesLook = PolesColor;
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BezierCurve::DrawOn (Draw_Display& dis) const {
|
||||
|
||||
|
||||
Handle(Geom_BezierCurve) C = Handle(Geom_BezierCurve)::DownCast(curv);
|
||||
|
||||
if (drawPoles) {
|
||||
Standard_Integer NbPoles = C->NbPoles();
|
||||
dis.SetColor(polesLook);
|
||||
TColgp_Array1OfPnt CPoles (1, NbPoles);
|
||||
C->Poles (CPoles);
|
||||
dis.MoveTo(CPoles(1));
|
||||
for (Standard_Integer i = 2; i <= NbPoles; i++) {
|
||||
dis.DrawTo(CPoles(i));
|
||||
}
|
||||
}
|
||||
|
||||
DrawTrSurf_Curve::DrawOn(dis);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BezierCurve::ShowPoles () { drawPoles = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BezierCurve::ClearPoles () { drawPoles = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BezierCurve::FindPole (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D,
|
||||
const Standard_Real XPrec, Standard_Integer& Index) const {
|
||||
|
||||
Handle(Geom_BezierCurve) bz = Handle(Geom_BezierCurve)::DownCast(curv);
|
||||
gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
|
||||
Standard_Real Prec = XPrec / D.Zoom();
|
||||
Index++;
|
||||
Standard_Integer NbPoles = bz->NbPoles();
|
||||
while (Index <= NbPoles) {
|
||||
if (D.Project(bz->Pole(Index)).Distance(p1) <= Prec)
|
||||
return;
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve::Copy()const
|
||||
{
|
||||
Handle(DrawTrSurf_BezierCurve) DC = new DrawTrSurf_BezierCurve
|
||||
(Handle(Geom_BezierCurve)::DownCast(curv->Copy()),
|
||||
look,polesLook,
|
||||
drawPoles,
|
||||
GetDiscretisation(),GetDeflection(),GetDrawMode());
|
||||
|
||||
return DC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
19
src/DrawTrSurf/DrawTrSurf_BezierCurve.lxx
Executable file
19
src/DrawTrSurf/DrawTrSurf_BezierCurve.lxx
Executable file
@@ -0,0 +1,19 @@
|
||||
|
||||
inline void DrawTrSurf_BezierCurve::SetPolesColor (
|
||||
const Draw_Color& aColor) {
|
||||
|
||||
polesLook = aColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_BezierCurve::PolesColor () const {
|
||||
|
||||
return polesLook;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
81
src/DrawTrSurf/DrawTrSurf_BezierCurve2d.cdl
Executable file
81
src/DrawTrSurf/DrawTrSurf_BezierCurve2d.cdl
Executable file
@@ -0,0 +1,81 @@
|
||||
-- File: BezierCurve2d.cdl
|
||||
-- Created: Fri May 22 10:45:54 1992
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
-- <jcv@sdsun4>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
|
||||
class BezierCurve2d
|
||||
|
||||
|
||||
from DrawTrSurf
|
||||
|
||||
|
||||
inherits Curve2d from DrawTrSurf
|
||||
|
||||
|
||||
uses BezierCurve from Geom2d,
|
||||
Color from Draw,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw
|
||||
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create (C : BezierCurve from Geom2d)
|
||||
--- Purpose :
|
||||
-- creates a drawable Bezier curve from a Bezier curve of
|
||||
-- package Geom2d.
|
||||
returns mutable BezierCurve2d from DrawTrSurf;
|
||||
|
||||
|
||||
Create (C : BezierCurve from Geom2d;
|
||||
CurvColor, PolesColor : Color from Draw;
|
||||
ShowPoles : Boolean; Discret : Integer)
|
||||
returns mutable BezierCurve2d from DrawTrSurf;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw)
|
||||
is redefined static;
|
||||
|
||||
|
||||
ShowPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
ClearPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
FindPole(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
Index : in out Integer)
|
||||
--- Purpose :
|
||||
-- Returns in <Index> the index of the first pole of the
|
||||
-- curve projected by the Display <D> at a distance lower
|
||||
-- than <Prec> from <X,Y>. If no pole is found index is
|
||||
-- set to 0, else index is always greater than the input
|
||||
-- value of index.
|
||||
is static;
|
||||
|
||||
|
||||
SetPolesColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
PolesColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
drawPoles : Boolean;
|
||||
polesLook : Color from Draw;
|
||||
|
||||
end BezierCurve2d;
|
100
src/DrawTrSurf/DrawTrSurf_BezierCurve2d.cxx
Executable file
100
src/DrawTrSurf/DrawTrSurf_BezierCurve2d.cxx
Executable file
@@ -0,0 +1,100 @@
|
||||
#include <DrawTrSurf_BezierCurve2d.ixx>
|
||||
|
||||
#include <Geom2d_BezierCurve.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
|
||||
DrawTrSurf_BezierCurve2d::DrawTrSurf_BezierCurve2d (
|
||||
const Handle(Geom2d_BezierCurve)& C) :
|
||||
DrawTrSurf_Curve2d (C, Draw_vert, 50) {
|
||||
|
||||
drawPoles = Standard_True;
|
||||
polesLook = Draw_rouge;
|
||||
}
|
||||
|
||||
|
||||
DrawTrSurf_BezierCurve2d::DrawTrSurf_BezierCurve2d (
|
||||
const Handle(Geom2d_BezierCurve)& C, const Draw_Color& CurvColor,
|
||||
const Draw_Color& PolesColor, const Standard_Boolean ShowPoles,
|
||||
const Standard_Integer Discret) : DrawTrSurf_Curve2d (C, CurvColor, Discret) {
|
||||
|
||||
drawPoles = ShowPoles;
|
||||
polesLook = PolesColor;
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BezierCurve2d::DrawOn (Draw_Display& dis) const
|
||||
{
|
||||
|
||||
Handle(Geom2d_BezierCurve) C = Handle(Geom2d_BezierCurve)::DownCast(curv);
|
||||
|
||||
if (drawPoles) {
|
||||
dis.SetColor(polesLook);
|
||||
TColgp_Array1OfPnt2d CPoles (1, C->NbPoles());
|
||||
C->Poles (CPoles);
|
||||
dis.MoveTo(CPoles(1));
|
||||
for (Standard_Integer i = 2; i <= C->NbPoles(); i++) {
|
||||
dis.DrawTo(CPoles(i));
|
||||
}
|
||||
}
|
||||
|
||||
DrawTrSurf_Curve2d::DrawOn(dis);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BezierCurve2d::ShowPoles ()
|
||||
{
|
||||
drawPoles = Standard_True;
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BezierCurve2d::ClearPoles ()
|
||||
{
|
||||
drawPoles = Standard_False;
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BezierCurve2d::FindPole (
|
||||
const Standard_Real X,
|
||||
const Standard_Real Y,
|
||||
const Draw_Display& D,
|
||||
const Standard_Real XPrec,
|
||||
Standard_Integer& Index) const
|
||||
{
|
||||
|
||||
Handle(Geom2d_BezierCurve) bz = Handle(Geom2d_BezierCurve)::DownCast(curv);
|
||||
gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
|
||||
Standard_Real Prec = XPrec / D.Zoom();
|
||||
Index++;
|
||||
Standard_Integer NbPoles = bz->NbPoles();
|
||||
gp_Pnt P;
|
||||
gp_Pnt2d P2d;
|
||||
while (Index <= NbPoles) {
|
||||
P2d = bz->Pole(Index);
|
||||
P.SetCoord (P2d.X(), P2d.Y(), 0.0);
|
||||
if (D.Project(P).Distance(p1) <= Prec)
|
||||
return;
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve2d::Copy()const
|
||||
{
|
||||
Handle(DrawTrSurf_BezierCurve2d) DC = new DrawTrSurf_BezierCurve2d
|
||||
(Handle(Geom2d_BezierCurve)::DownCast(curv->Copy()),
|
||||
look,polesLook,
|
||||
drawPoles,
|
||||
GetDiscretisation());
|
||||
|
||||
return DC;
|
||||
}
|
19
src/DrawTrSurf/DrawTrSurf_BezierCurve2d.lxx
Executable file
19
src/DrawTrSurf/DrawTrSurf_BezierCurve2d.lxx
Executable file
@@ -0,0 +1,19 @@
|
||||
|
||||
inline void DrawTrSurf_BezierCurve2d::SetPolesColor (
|
||||
const Draw_Color& aColor) {
|
||||
|
||||
polesLook = aColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_BezierCurve2d::PolesColor () const {
|
||||
|
||||
return polesLook;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
75
src/DrawTrSurf/DrawTrSurf_BezierSurface.cdl
Executable file
75
src/DrawTrSurf/DrawTrSurf_BezierSurface.cdl
Executable file
@@ -0,0 +1,75 @@
|
||||
-- File: BezierSurface.cdl
|
||||
-- Created: Fri May 22 10:41:09 1992
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
-- <jcv@sdsun4>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class BezierSurface
|
||||
|
||||
from DrawTrSurf
|
||||
|
||||
inherits Surface from DrawTrSurf
|
||||
|
||||
uses BezierSurface from Geom,
|
||||
Color from Draw,
|
||||
MarkerShape from Draw,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create (S : BezierSurface from Geom)
|
||||
--- Purpose :
|
||||
-- creates a drawable Bezier curve from a Bezier curve of
|
||||
-- package Geom.
|
||||
returns mutable BezierSurface from DrawTrSurf;
|
||||
|
||||
|
||||
|
||||
Create (S : BezierSurface from Geom;
|
||||
NbUIsos, NbVIsos : Integer;
|
||||
BoundsColor, IsosColor, PolesColor : Color from Draw;
|
||||
ShowPoles : Boolean; Discret : Integer;Deflection : Real;
|
||||
DrawMode : Integer)
|
||||
returns mutable BezierSurface from DrawTrSurf;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw)
|
||||
is redefined static;
|
||||
|
||||
|
||||
ShowPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
ClearPoles (me : mutable)
|
||||
is static;
|
||||
|
||||
|
||||
FindPole(me; X,Y : Real; D : Display from Draw; Prec : Real;
|
||||
UIndex, VIndex : in out Integer)
|
||||
is static;
|
||||
|
||||
|
||||
SetPolesColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
PolesColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
drawPoles : Boolean;
|
||||
polesLook : Color from Draw;
|
||||
|
||||
end BezierSurface;
|
115
src/DrawTrSurf/DrawTrSurf_BezierSurface.cxx
Executable file
115
src/DrawTrSurf/DrawTrSurf_BezierSurface.cxx
Executable file
@@ -0,0 +1,115 @@
|
||||
#include <DrawTrSurf_BezierSurface.ixx>
|
||||
#include <DrawTrSurf_BezierCurve.hxx>
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
DrawTrSurf_BezierSurface::DrawTrSurf_BezierSurface (
|
||||
const Handle(Geom_BezierSurface)& S)
|
||||
: DrawTrSurf_Surface (S, 1, 1, Draw_jaune, Draw_bleu, 30, 0.05, 0) {
|
||||
|
||||
drawPoles = Standard_True;
|
||||
polesLook = Draw_rouge;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DrawTrSurf_BezierSurface::DrawTrSurf_BezierSurface (
|
||||
const Handle(Geom_BezierSurface)& S,
|
||||
const Standard_Integer NbUIsos, const Standard_Integer NbVIsos,
|
||||
const Draw_Color& BoundsColor, const Draw_Color& IsosColor,
|
||||
const Draw_Color& PolesColor, const Standard_Boolean ShowPoles,
|
||||
const Standard_Integer Discret,const Standard_Real Deflection,
|
||||
const Standard_Integer DrawMode)
|
||||
: DrawTrSurf_Surface (S, NbUIsos, NbVIsos, BoundsColor, IsosColor,
|
||||
Discret, Deflection, DrawMode){
|
||||
|
||||
drawPoles = ShowPoles;
|
||||
polesLook = PolesColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BezierSurface::DrawOn (Draw_Display& dis) const {
|
||||
|
||||
Standard_Integer i,j;
|
||||
Handle(Geom_BezierSurface) S = Handle(Geom_BezierSurface)::DownCast(surf);
|
||||
|
||||
if (drawPoles) {
|
||||
Standard_Integer NbUPoles = S->NbUPoles();
|
||||
Standard_Integer NbVPoles = S->NbVPoles();
|
||||
dis.SetColor(polesLook);
|
||||
TColgp_Array2OfPnt SPoles (1, NbUPoles, 1, NbVPoles);
|
||||
S->Poles (SPoles);
|
||||
for (j = 1; j <= NbVPoles; j++) {
|
||||
dis.MoveTo(SPoles(1, j));
|
||||
for (i = 2; i <= NbUPoles; i++) {
|
||||
dis.DrawTo(SPoles(i, j));
|
||||
}
|
||||
}
|
||||
for (i = 1; i <= NbUPoles; i++) {
|
||||
dis.MoveTo(SPoles(i, 1));
|
||||
for (j = 2; j <= NbVPoles; j++) {
|
||||
dis.DrawTo(SPoles(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DrawTrSurf_Surface::DrawOn(dis);
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BezierSurface::ShowPoles () { drawPoles = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BezierSurface::ClearPoles () { drawPoles = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BezierSurface::FindPole (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D,
|
||||
const Standard_Real XPrec, Standard_Integer& UIndex, Standard_Integer& VIndex) const {
|
||||
|
||||
Handle(Geom_BezierSurface) bs = Handle(Geom_BezierSurface)::DownCast(surf);
|
||||
gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
|
||||
Standard_Real Prec = XPrec / D.Zoom();
|
||||
UIndex++;
|
||||
VIndex++;
|
||||
Standard_Integer NbUPoles = bs->NbUPoles();
|
||||
Standard_Integer NbVPoles = bs->NbVPoles();
|
||||
while (VIndex <= NbVPoles) {
|
||||
while (UIndex <= NbUPoles) {
|
||||
if (D.Project(bs->Pole(UIndex, VIndex)).Distance(p1) <= Prec)
|
||||
return;
|
||||
UIndex++;
|
||||
}
|
||||
UIndex = 1;
|
||||
VIndex++;
|
||||
}
|
||||
UIndex = VIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_BezierSurface::Copy()const
|
||||
{
|
||||
Handle(DrawTrSurf_BezierSurface) DS = new DrawTrSurf_BezierSurface
|
||||
(Handle(Geom_BezierSurface)::DownCast(surf->Copy()),
|
||||
nbUIsos,nbVIsos,
|
||||
boundsLook,isosLook,polesLook,drawPoles,
|
||||
GetDiscretisation(),GetDeflection(),GetDrawMode());
|
||||
|
||||
return DS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
13
src/DrawTrSurf/DrawTrSurf_BezierSurface.lxx
Executable file
13
src/DrawTrSurf/DrawTrSurf_BezierSurface.lxx
Executable file
@@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_BezierSurface::PolesColor () const {
|
||||
|
||||
return polesLook;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_BezierSurface::SetPolesColor (
|
||||
const Draw_Color& aColor) {
|
||||
|
||||
polesLook = aColor;
|
||||
}
|
110
src/DrawTrSurf/DrawTrSurf_Curve.cdl
Executable file
110
src/DrawTrSurf/DrawTrSurf_Curve.cdl
Executable file
@@ -0,0 +1,110 @@
|
||||
-- File: Curve.cdl
|
||||
-- Created: Thu May 21 19:16:50 1992
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
-- <jcv@sdsun4>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Curve from DrawTrSurf
|
||||
|
||||
inherits Drawable
|
||||
|
||||
--- Purpose :
|
||||
-- This class defines a drawable curve in 3d space.
|
||||
|
||||
uses Curve from Geom,
|
||||
Color from Draw,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw,
|
||||
Interpretor from Draw,
|
||||
OStream
|
||||
|
||||
is
|
||||
|
||||
|
||||
|
||||
|
||||
Create (C : Curve from Geom; DispOrigin : Boolean from Standard = Standard_True)
|
||||
--- Purpose :
|
||||
-- creates a drawable curve from a curve of package Geom.
|
||||
returns mutable Curve from DrawTrSurf;
|
||||
|
||||
|
||||
Create (C : Curve from Geom; aColor : Color from Draw; Discret : Integer;
|
||||
Deflection : Real; DrawMode : Integer;
|
||||
DispOrigin : Boolean from Standard = Standard_True;
|
||||
DispCurvRadius : Boolean = Standard_False;
|
||||
RadiusMax : Real = 1.0e3;
|
||||
RatioOfRadius : Real = 0.1)
|
||||
returns mutable Curve from DrawTrSurf;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw);
|
||||
|
||||
|
||||
GetCurve (me) returns any Curve from Geom
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
SetColor(me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
DisplayOrigin(me) returns Boolean
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
DisplayOrigin(me : mutable; V : Boolean)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
ShowCurvature(me : mutable)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
ClearCurvature(me : mutable)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
SetRadiusMax(me : mutable; Radius : Real)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
SetRadiusRatio(me : mutable; Ratio : Real)
|
||||
---C++: inline
|
||||
is static;
|
||||
Color (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
RadiusMax(me) returns Real
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
RadiusRatio(me) returns Real
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
---Purpose: For variable dump.
|
||||
is redefined;
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
---Purpose: For variable whatis command. Set as a result the
|
||||
-- type of the variable.
|
||||
|
||||
fields
|
||||
|
||||
curv : Curve from Geom is protected ;
|
||||
look : Color from Draw is protected ;
|
||||
disporigin : Boolean from Standard is protected ;
|
||||
dispcurvradius : Boolean from Standard is protected ;
|
||||
radiusmax : Real from Standard is protected ;
|
||||
radiusratio : Real from Standard is protected ;
|
||||
|
||||
end Curve;
|
201
src/DrawTrSurf/DrawTrSurf_Curve.cxx
Executable file
201
src/DrawTrSurf/DrawTrSurf_Curve.cxx
Executable file
@@ -0,0 +1,201 @@
|
||||
#include <DrawTrSurf_Curve.ixx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <GeomTools_CurveSet.hxx>
|
||||
#include <GeomLProp_CLProps.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Dir2d.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
Standard_Real DrawTrSurf_CurveLimit = 400;
|
||||
extern Standard_Boolean Draw_Bounds;
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Curve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Curve::DrawTrSurf_Curve (const Handle(Geom_Curve)& C,
|
||||
const Standard_Boolean DispOrigin) :
|
||||
DrawTrSurf_Drawable (16, 0.01, 1),
|
||||
curv(C),
|
||||
look(Draw_vert),
|
||||
disporigin(DispOrigin),
|
||||
dispcurvradius(Standard_False),
|
||||
radiusmax(1.0e3),
|
||||
radiusratio(0.1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Curve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Curve::DrawTrSurf_Curve (const Handle(Geom_Curve)& C,
|
||||
const Draw_Color& aColor,
|
||||
const Standard_Integer Discret,
|
||||
const Standard_Real Deflection,
|
||||
const Standard_Integer DrawMode,
|
||||
const Standard_Boolean DispOrigin,
|
||||
const Standard_Boolean DispCurvRadius,
|
||||
const Standard_Real RadiusMax,
|
||||
const Standard_Real RadiusRatio) :
|
||||
DrawTrSurf_Drawable (Discret,Deflection, DrawMode),
|
||||
curv(C),
|
||||
look(aColor),
|
||||
disporigin(DispOrigin),
|
||||
dispcurvradius(DispCurvRadius),
|
||||
radiusmax(RadiusMax),
|
||||
radiusratio(RadiusRatio)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Curve::DrawOn (Draw_Display& dis) const
|
||||
{
|
||||
Standard_Real First = curv->FirstParameter();
|
||||
Standard_Real Last = curv->LastParameter();
|
||||
Standard_Boolean firstInf = Precision::IsNegativeInfinite(First);
|
||||
Standard_Boolean lastInf = Precision::IsPositiveInfinite(Last);
|
||||
|
||||
if (firstInf || lastInf) {
|
||||
gp_Pnt P1,P2;
|
||||
Standard_Real delta = 1;
|
||||
if (firstInf && lastInf) {
|
||||
do {
|
||||
delta *= 2;
|
||||
First = - delta;
|
||||
Last = delta;
|
||||
curv->D0(First,P1);
|
||||
curv->D0(Last,P2);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_CurveLimit);
|
||||
}
|
||||
else if (firstInf) {
|
||||
curv->D0(Last,P2);
|
||||
do {
|
||||
delta *= 2;
|
||||
First = Last - delta;
|
||||
curv->D0(First,P1);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_CurveLimit);
|
||||
}
|
||||
else if (lastInf) {
|
||||
curv->D0(First,P1);
|
||||
do {
|
||||
delta *= 2;
|
||||
Last = First + delta;
|
||||
curv->D0(Last,P2);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_CurveLimit);
|
||||
}
|
||||
}
|
||||
|
||||
dis.SetColor (look);
|
||||
GeomAdaptor_Curve C(curv,First,Last);
|
||||
DrawCurveOn(C,dis);
|
||||
|
||||
// mark the orientation
|
||||
if (disporigin) {
|
||||
Draw_Bounds = Standard_False;
|
||||
gp_Pnt P;
|
||||
gp_Vec V;
|
||||
C.D1(Last,P,V);
|
||||
gp_Pnt2d p1,p2;
|
||||
dis.Project(P,p1);
|
||||
P.Translate(V);
|
||||
dis.Project(P,p2);
|
||||
gp_Vec2d v(p1,p2);
|
||||
if (v.Magnitude() > gp::Resolution()) {
|
||||
Standard_Real L = 20 / dis.Zoom();
|
||||
Standard_Real H = 10 / dis.Zoom();
|
||||
gp_Dir2d d(v);
|
||||
p2.SetCoord(p1.X() - L*d.X() - H*d.Y(), p1.Y() - L*d.Y() + H*d.X());
|
||||
dis.MoveTo(p2);
|
||||
p2.SetCoord(p1.X() - L*d.X() + H*d.Y(), p1.Y() - L*d.Y() - H*d.X());
|
||||
dis.DrawTo(p1);
|
||||
dis.DrawTo(p2);
|
||||
}
|
||||
Draw_Bounds = Standard_True;
|
||||
}
|
||||
// Draw the curvature Radius
|
||||
if (dispcurvradius && (C.GetType() != GeomAbs_Line)) {
|
||||
Standard_Integer ii;
|
||||
Standard_Integer intrv, nbintv = C.NbIntervals(GeomAbs_CN);
|
||||
TColStd_Array1OfReal TI(1,nbintv+1);
|
||||
C.Intervals(TI,GeomAbs_CN);
|
||||
Standard_Real Resolution = 1.0e-9, Curvature;
|
||||
GeomLProp_CLProps LProp(curv, 2, Resolution);
|
||||
gp_Pnt P1, P2;
|
||||
|
||||
for (intrv = 1; intrv <= nbintv; intrv++) {
|
||||
Standard_Real t = TI(intrv);
|
||||
Standard_Real step = (TI(intrv+1) - t) / GetDiscretisation();
|
||||
Standard_Real LRad, ratio;
|
||||
for (ii = 1; ii <= GetDiscretisation(); ii++) {
|
||||
LProp.SetParameter(t);
|
||||
if (LProp.IsTangentDefined()) {
|
||||
Curvature = Abs(LProp.Curvature());
|
||||
if ( Curvature > Resolution) {
|
||||
curv->D0(t, P1);
|
||||
dis.MoveTo(P1);
|
||||
LRad = 1./Curvature;
|
||||
ratio = ( ( LRad > radiusmax) ? radiusmax/LRad : 1 );
|
||||
ratio *= radiusratio;
|
||||
LProp.CentreOfCurvature(P2);
|
||||
gp_Vec V(P1, P2);
|
||||
dis.DrawTo(P1.Translated(ratio*V));
|
||||
}
|
||||
}
|
||||
t += step;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_Curve::Copy()const
|
||||
{
|
||||
Handle(DrawTrSurf_Curve) DC = new DrawTrSurf_Curve
|
||||
(Handle(Geom_Curve)::DownCast(curv->Copy()),
|
||||
look,
|
||||
GetDiscretisation(),GetDeflection(),GetDrawMode());
|
||||
|
||||
return DC;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Curve::Dump(Standard_OStream& S)const
|
||||
{
|
||||
GeomTools_CurveSet::PrintCurve(curv,S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Curve::Whatis(Draw_Interpretor& S)const
|
||||
{
|
||||
S << " a 3d curve";
|
||||
}
|
33
src/DrawTrSurf/DrawTrSurf_Curve.lxx
Executable file
33
src/DrawTrSurf/DrawTrSurf_Curve.lxx
Executable file
@@ -0,0 +1,33 @@
|
||||
|
||||
inline Handle(Geom_Curve) DrawTrSurf_Curve::GetCurve () const
|
||||
{ return curv; }
|
||||
|
||||
inline Draw_Color DrawTrSurf_Curve::Color () const
|
||||
{ return look; }
|
||||
|
||||
inline Standard_Boolean DrawTrSurf_Curve::DisplayOrigin () const
|
||||
{ return disporigin; }
|
||||
|
||||
inline void DrawTrSurf_Curve::DisplayOrigin (const Standard_Boolean V)
|
||||
{ disporigin = V; }
|
||||
|
||||
inline void DrawTrSurf_Curve::SetColor (const Draw_Color& aColor)
|
||||
{ look = aColor; }
|
||||
|
||||
inline void DrawTrSurf_Curve::ShowCurvature()
|
||||
{ dispcurvradius = Standard_True;}
|
||||
|
||||
inline void DrawTrSurf_Curve::ClearCurvature()
|
||||
{ dispcurvradius = Standard_False;}
|
||||
|
||||
inline Standard_Real DrawTrSurf_Curve::RadiusMax () const
|
||||
{ return radiusmax; }
|
||||
|
||||
inline Standard_Real DrawTrSurf_Curve::RadiusRatio () const
|
||||
{ return radiusratio; }
|
||||
|
||||
inline void DrawTrSurf_Curve::SetRadiusMax (const Standard_Real Radius)
|
||||
{ radiusmax = Radius; }
|
||||
|
||||
inline void DrawTrSurf_Curve::SetRadiusRatio (const Standard_Real Ratio)
|
||||
{ radiusratio = Ratio; }
|
111
src/DrawTrSurf/DrawTrSurf_Curve2d.cdl
Executable file
111
src/DrawTrSurf/DrawTrSurf_Curve2d.cdl
Executable file
@@ -0,0 +1,111 @@
|
||||
-- File: Curve2d.cdl
|
||||
-- Created: Fri May 22 10:48:44 1992
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
-- <jcv@sdsun4>
|
||||
-- Modified PMN CurvatureRadius added
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
|
||||
class Curve2d from DrawTrSurf
|
||||
|
||||
inherits Drawable
|
||||
|
||||
--- Purpose : This class defines a drawable curve in 2d space.
|
||||
-- The curve is drawned in the plane XOY.
|
||||
|
||||
uses Curve from Geom2d,
|
||||
Color from Draw,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw,
|
||||
Interpretor from Draw,
|
||||
OStream
|
||||
|
||||
|
||||
is
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Create (C : Curve from Geom2d;
|
||||
DispOrigin : Boolean from Standard = Standard_True)
|
||||
--- Purpose :
|
||||
-- creates a drawable curve from a curve of package Geom2d.
|
||||
returns mutable Curve2d from DrawTrSurf;
|
||||
|
||||
|
||||
Create (C : Curve from Geom2d; aColor : Color from Draw; Discret :Integer;
|
||||
DispOrigin : Boolean from Standard = Standard_True;
|
||||
DispCurvRadius : Boolean = Standard_False;
|
||||
RadiusMax : Real = 1.0e3;
|
||||
RatioOfRadius : Real = 0.1)
|
||||
returns mutable Curve2d from DrawTrSurf;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw);
|
||||
|
||||
|
||||
GetCurve (me) returns any Curve from Geom2d
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
SetColor(me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
ShowCurvature(me : mutable)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
ClearCurvature(me : mutable)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
SetRadiusMax(me : mutable; Radius : Real)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
SetRadiusRatio(me : mutable; Ratio : Real)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
Color (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
RadiusMax(me) returns Real
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
RadiusRatio(me) returns Real
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
---Purpose: For variable dump.
|
||||
is redefined;
|
||||
|
||||
Is3D(me) returns Boolean
|
||||
---Purpose: Returns False.
|
||||
is redefined;
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
---Purpose: For variable whatis command. Set as a result the
|
||||
-- type of the variable.
|
||||
|
||||
fields
|
||||
curv : Curve from Geom2d is protected ;
|
||||
look : Color from Draw is protected ;
|
||||
disporigin : Boolean from Standard is protected ;
|
||||
dispcurvradius : Boolean from Standard is protected ;
|
||||
radiusmax : Real from Standard is protected ;
|
||||
radiusratio : Real from Standard is protected ;
|
||||
end Curve2d;
|
208
src/DrawTrSurf/DrawTrSurf_Curve2d.cxx
Executable file
208
src/DrawTrSurf/DrawTrSurf_Curve2d.cxx
Executable file
@@ -0,0 +1,208 @@
|
||||
#include <DrawTrSurf_Curve2d.ixx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_OffsetCurve.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Geom2d_Parabola.hxx>
|
||||
#include <Geom2d_Hyperbola.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <GeomTools_Curve2dSet.hxx>
|
||||
#include <Geom2dLProp_CLProps2d.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
static Standard_Real DrawTrSurf_CurveLimit = 400;
|
||||
extern Standard_Boolean Draw_Bounds;
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Curve2d::DrawTrSurf_Curve2d (const Handle(Geom2d_Curve)& C,
|
||||
const Standard_Boolean DispOrigin) :
|
||||
DrawTrSurf_Drawable (50)
|
||||
{
|
||||
curv = C;
|
||||
look = Draw_vert;
|
||||
disporigin = DispOrigin ;
|
||||
dispcurvradius = Standard_False;
|
||||
radiusmax = 1.0e3;
|
||||
radiusratio = 0.1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Curve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Curve2d::DrawTrSurf_Curve2d (const Handle(Geom2d_Curve)& C,
|
||||
const Draw_Color& aColor,
|
||||
const Standard_Integer Discret,
|
||||
const Standard_Boolean DispOrigin,
|
||||
const Standard_Boolean DispCurvRadius,
|
||||
const Standard_Real RadiusMax,
|
||||
const Standard_Real RadiusRatio) :
|
||||
DrawTrSurf_Drawable (Discret)
|
||||
{
|
||||
curv = C;
|
||||
look = aColor;
|
||||
disporigin = DispOrigin ;
|
||||
dispcurvradius = DispCurvRadius;
|
||||
radiusmax = RadiusMax;
|
||||
radiusratio = RadiusRatio;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Curve2d::DrawOn (Draw_Display& dis) const
|
||||
{
|
||||
|
||||
Standard_Real First = curv->FirstParameter();
|
||||
Standard_Real Last = curv->LastParameter();
|
||||
Standard_Boolean firstInf = Precision::IsNegativeInfinite(First);
|
||||
Standard_Boolean lastInf = Precision::IsPositiveInfinite(Last);
|
||||
|
||||
if (firstInf || lastInf) {
|
||||
gp_Pnt2d P1,P2;
|
||||
Standard_Real delta = 1;
|
||||
if (firstInf && lastInf) {
|
||||
do {
|
||||
delta *= 2;
|
||||
First = - delta;
|
||||
Last = delta;
|
||||
curv->D0(First,P1);
|
||||
curv->D0(Last,P2);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_CurveLimit);
|
||||
}
|
||||
else if (firstInf) {
|
||||
curv->D0(Last,P2);
|
||||
do {
|
||||
delta *= 2;
|
||||
First = Last - delta;
|
||||
curv->D0(First,P1);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_CurveLimit);
|
||||
}
|
||||
else if (lastInf) {
|
||||
curv->D0(First,P1);
|
||||
do {
|
||||
delta *= 2;
|
||||
Last = First + delta;
|
||||
curv->D0(Last,P2);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_CurveLimit);
|
||||
}
|
||||
}
|
||||
|
||||
dis.SetColor (look);
|
||||
|
||||
Geom2dAdaptor_Curve C2d(curv,First,Last);
|
||||
DrawCurve2dOn (C2d, dis);
|
||||
|
||||
// mark the origin
|
||||
if (disporigin) {
|
||||
Draw_Bounds = Standard_False;
|
||||
gp_Pnt2d p1,p2;
|
||||
gp_Vec2d v;
|
||||
C2d.D1(Last,p1,v);
|
||||
if (v.Magnitude() > gp::Resolution()) {
|
||||
Standard_Real L = 20 / dis.Zoom();
|
||||
Standard_Real H = 10 / dis.Zoom();
|
||||
gp_Dir2d d(v);
|
||||
p2.SetCoord(p1.X() - L*d.X() - H*d.Y(), p1.Y() - L*d.Y() + H*d.X());
|
||||
dis.MoveTo(p2);
|
||||
p2.SetCoord(p1.X() - L*d.X() + H*d.Y(), p1.Y() - L*d.Y() - H*d.X());
|
||||
dis.DrawTo(p1);
|
||||
dis.DrawTo(p2);
|
||||
}
|
||||
Draw_Bounds = Standard_True;
|
||||
}
|
||||
|
||||
// Draw the curvature Radius
|
||||
if (dispcurvradius && (C2d.GetType() != GeomAbs_Line)) {
|
||||
Standard_Integer ii;
|
||||
Standard_Integer intrv, nbintv = C2d.NbIntervals(GeomAbs_CN);
|
||||
TColStd_Array1OfReal TI(1,nbintv+1);
|
||||
C2d.Intervals(TI,GeomAbs_CN);
|
||||
Standard_Real Resolution = 1.0e-9, Curvature;
|
||||
Geom2dLProp_CLProps2d LProp(curv, 2, Resolution);
|
||||
gp_Pnt2d P1, P2;
|
||||
|
||||
for (intrv = 1; intrv <= nbintv; intrv++) {
|
||||
Standard_Real t = TI(intrv);
|
||||
Standard_Real step = (TI(intrv+1) - t) / GetDiscretisation();
|
||||
Standard_Real LRad, ratio;
|
||||
for (ii = 1; ii <= GetDiscretisation(); ii++) {
|
||||
LProp.SetParameter(t);
|
||||
if (LProp.IsTangentDefined()) {
|
||||
Curvature = Abs(LProp.Curvature());
|
||||
if ( Curvature > Resolution) {
|
||||
curv->D0(t, P1);
|
||||
dis.MoveTo(P1);
|
||||
LRad = 1./Curvature;
|
||||
ratio = ( ( LRad > radiusmax) ? radiusmax/LRad : 1 );
|
||||
ratio *= radiusratio;
|
||||
LProp.CentreOfCurvature(P2);
|
||||
gp_Vec2d V(P1, P2);
|
||||
dis.DrawTo(P1.Translated(ratio*V));
|
||||
}
|
||||
}
|
||||
t += step;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_Curve2d::Copy()const
|
||||
{
|
||||
Handle(DrawTrSurf_Curve2d) DC = new DrawTrSurf_Curve2d
|
||||
(Handle(Geom2d_Curve)::DownCast(curv->Copy()),
|
||||
look,
|
||||
GetDiscretisation());
|
||||
|
||||
return DC;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Curve2d::Dump(Standard_OStream& S) const
|
||||
{
|
||||
GeomTools_Curve2dSet::PrintCurve2d(curv,S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Curve2d::Whatis(Draw_Interpretor& S)const
|
||||
{
|
||||
S << "2d curve";
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Is3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DrawTrSurf_Curve2d::Is3D() const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
29
src/DrawTrSurf/DrawTrSurf_Curve2d.lxx
Executable file
29
src/DrawTrSurf/DrawTrSurf_Curve2d.lxx
Executable file
@@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
inline Handle(Geom2d_Curve) DrawTrSurf_Curve2d::GetCurve () const {
|
||||
return curv;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_Curve2d::Color () const { return look; }
|
||||
|
||||
inline void DrawTrSurf_Curve2d::ShowCurvature()
|
||||
{ dispcurvradius = Standard_True;}
|
||||
|
||||
inline void DrawTrSurf_Curve2d::ClearCurvature()
|
||||
{ dispcurvradius = Standard_False;}
|
||||
|
||||
inline Standard_Real DrawTrSurf_Curve2d::RadiusMax () const { return radiusmax; }
|
||||
|
||||
inline Standard_Real DrawTrSurf_Curve2d::RadiusRatio () const { return radiusratio; }
|
||||
|
||||
inline void DrawTrSurf_Curve2d::SetColor (const Draw_Color& aColor)
|
||||
{ look = aColor; }
|
||||
|
||||
inline void DrawTrSurf_Curve2d::SetRadiusMax (const Standard_Real Radius)
|
||||
{ radiusmax = Radius; }
|
||||
|
||||
inline void DrawTrSurf_Curve2d::SetRadiusRatio (const Standard_Real Ratio)
|
||||
{ radiusratio = Ratio; }
|
||||
|
||||
|
90
src/DrawTrSurf/DrawTrSurf_Debug.cxx
Executable file
90
src/DrawTrSurf/DrawTrSurf_Debug.cxx
Executable file
@@ -0,0 +1,90 @@
|
||||
// File: DrawTrSurf_Debug.cxx
|
||||
// Created: Mon Jul 25 18:59:42 1994
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <GeomTools.hxx>
|
||||
#include <GeomTools_SurfaceSet.hxx>
|
||||
#include <GeomTools_CurveSet.hxx>
|
||||
#include <GeomTools_Curve2dSet.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
|
||||
//
|
||||
// method to call with dbx
|
||||
//
|
||||
|
||||
|
||||
void DrawTrSurf_Set(char* name, const Handle(Standard_Transient)& G)
|
||||
{
|
||||
Handle(Geom_Geometry) GG = Handle(Geom_Geometry)::DownCast(G);
|
||||
if (!GG.IsNull()) {
|
||||
DrawTrSurf::Set(name,GG);
|
||||
return;
|
||||
}
|
||||
Handle(Geom2d_Curve) GC = Handle(Geom2d_Curve)::DownCast(G);
|
||||
if (!GC.IsNull()) {
|
||||
DrawTrSurf::Set(name,GC);
|
||||
return;
|
||||
}
|
||||
|
||||
cout << "*** Not a geometric object ***" << endl;
|
||||
}
|
||||
|
||||
void DrawTrSurf_Get(const char* name, Handle(Standard_Transient)& G)
|
||||
{
|
||||
Handle(Geom_Geometry) GG = DrawTrSurf::Get(name);
|
||||
cout << "Nom : " << name << endl;
|
||||
if (!GG.IsNull()) {
|
||||
G = GG;
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(name);
|
||||
if (!GC.IsNull()) {
|
||||
G = GC;
|
||||
return;
|
||||
}
|
||||
|
||||
cout << "*** Not a geometric object ***" << endl;
|
||||
}
|
||||
|
||||
void DrawTrSurf_Dump(const Handle(Standard_Transient)& G)
|
||||
{
|
||||
cout << "\n\n";
|
||||
|
||||
Handle(Geom_Surface) GS = Handle(Geom_Surface)::DownCast(G);
|
||||
if (!GS.IsNull()) {
|
||||
GeomTools_SurfaceSet::PrintSurface(GS,cout);
|
||||
cout << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom_Curve) GC = Handle(Geom_Curve)::DownCast(G);
|
||||
if (!GC.IsNull()) {
|
||||
GeomTools_CurveSet::PrintCurve(GC,cout);
|
||||
cout << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom2d_Curve) GC2d = Handle(Geom2d_Curve)::DownCast(G);
|
||||
if (!GC2d.IsNull()) {
|
||||
GeomTools_Curve2dSet::PrintCurve2d(GC2d,cout);
|
||||
cout << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawTrSurf_Set(char* name, const gp_Pnt& P)
|
||||
{
|
||||
cout<<"point "<<name<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl;
|
||||
DrawTrSurf::Set(name,P);
|
||||
}
|
||||
|
||||
void DrawTrSurf_Set(char* name, const gp_Pnt2d& P)
|
||||
{
|
||||
cout<<"point "<<name<<" "<<P.X()<<" "<<P.Y()<<endl;
|
||||
DrawTrSurf::Set(name,P);
|
||||
}
|
80
src/DrawTrSurf/DrawTrSurf_Drawable.cdl
Executable file
80
src/DrawTrSurf/DrawTrSurf_Drawable.cdl
Executable file
@@ -0,0 +1,80 @@
|
||||
-- File: Drawable.cdl
|
||||
-- Created: Tue Jul 16 08:55:41 1991
|
||||
-- Author: Christophe MARION
|
||||
-- <cma@sdsun1>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
|
||||
deferred class Drawable from DrawTrSurf inherits Drawable3D from Draw
|
||||
|
||||
---Purpose: this class adds to the Drawable3D methods to
|
||||
-- display Curves and Curves on Surface.
|
||||
--
|
||||
-- The discretisation, number of points on a Curve,
|
||||
-- is stored in this class.
|
||||
|
||||
uses
|
||||
Display from Draw,
|
||||
Curve from Adaptor3d,
|
||||
Curve2d from Adaptor2d,
|
||||
IsoCurve from Adaptor3d,
|
||||
IsoType from GeomAbs
|
||||
|
||||
is
|
||||
Initialize(discret : Integer; deflection : Real = 0.01; DrawMode : Integer = 0);
|
||||
---Purpose: set the number of points on a curve at creation.
|
||||
|
||||
DrawCurve2dOn(me;
|
||||
C : in out Curve2d from Adaptor2d;
|
||||
D : in out Display from Draw);
|
||||
---Purpose: Draw a polygon of the curve on the Display
|
||||
|
||||
DrawCurveOn(me;
|
||||
C : in out Curve from Adaptor3d;
|
||||
D : in out Display from Draw);
|
||||
---Purpose: Draw a polygon of the curve on the Display
|
||||
|
||||
DrawIsoCurveOn(me;
|
||||
C : in out IsoCurve from Adaptor3d;
|
||||
T : IsoType from GeomAbs;
|
||||
P, F, L : Real;
|
||||
D : in out Display from Draw);
|
||||
---Purpose: Load C with the specified iso and Draw a polygon
|
||||
-- of the curve on the Display
|
||||
|
||||
DrawOn(me; dis : in out Display from Draw)
|
||||
---Purpose: this is defined only to tell C++ not to complain
|
||||
-- about inheriting a pure virtual method.
|
||||
is deferred;
|
||||
|
||||
|
||||
SetDiscretisation (me : mutable; Discret : Integer);
|
||||
---C++: inline
|
||||
|
||||
GetDiscretisation (me) returns Integer;
|
||||
---C++: inline
|
||||
|
||||
SetDeflection (me : mutable; Deflection : Real);
|
||||
---C++: inline
|
||||
|
||||
GetDeflection (me) returns Real;
|
||||
---C++: inline
|
||||
|
||||
SetDrawMode (me : mutable; DrawMode : Integer);
|
||||
---C++: inline
|
||||
|
||||
GetDrawMode (me) returns Integer;
|
||||
---C++: inline
|
||||
|
||||
|
||||
|
||||
|
||||
fields
|
||||
myDrawMode : Integer;
|
||||
--- Purpose : 0 parametre constant, 1 fleche constante
|
||||
myDiscret : Integer;
|
||||
myDeflection : Real;
|
||||
|
||||
end Drawable;
|
||||
|
199
src/DrawTrSurf/DrawTrSurf_Drawable.cxx
Executable file
199
src/DrawTrSurf/DrawTrSurf_Drawable.cxx
Executable file
@@ -0,0 +1,199 @@
|
||||
// File: DrawTrSurf_Drawable.cxx
|
||||
// Created: Tue Jul 16 09:22:44 1991
|
||||
// Author: Christophe MARION
|
||||
// <cma@sdsun1>
|
||||
|
||||
|
||||
#include <DrawTrSurf_Drawable.ixx>
|
||||
#include <GCPnts_UniformDeflection.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Drawable
|
||||
//purpose : initialise the discretisation
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Drawable::DrawTrSurf_Drawable (
|
||||
|
||||
const Standard_Integer discret,
|
||||
const Standard_Real deflection,
|
||||
const Standard_Integer DrawMode ) :
|
||||
myDrawMode (DrawMode),
|
||||
myDiscret(discret),
|
||||
myDeflection(deflection)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawCurve2dOn
|
||||
//purpose : draw a 2D curve
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Drawable::DrawCurve2dOn (Adaptor2d_Curve2d& C,
|
||||
Draw_Display& aDisplay) const
|
||||
{
|
||||
gp_Pnt P;
|
||||
|
||||
gp_Pnt2d aPoint2d,
|
||||
*aPoint2dPtr ;
|
||||
if (myDrawMode == 1) {
|
||||
Standard_Real Fleche = myDeflection/aDisplay.Zoom();
|
||||
GCPnts_UniformDeflection LineVu(C,Fleche);
|
||||
if (LineVu.IsDone()) {
|
||||
P = LineVu.Value(1) ;
|
||||
aPoint2dPtr = (gp_Pnt2d *) &P ;
|
||||
aDisplay.MoveTo(*aPoint2dPtr);
|
||||
for (Standard_Integer i = 2; i <= LineVu.NbPoints(); i++) {
|
||||
P = LineVu.Value(i) ;
|
||||
aPoint2dPtr = (gp_Pnt2d *) &P ;
|
||||
aDisplay.DrawTo(*aPoint2dPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Standard_Integer intrv, nbintv = C.NbIntervals(GeomAbs_CN);
|
||||
TColStd_Array1OfReal TI(1,nbintv+1);
|
||||
C.Intervals(TI,GeomAbs_CN);
|
||||
C.D0(C.FirstParameter(),aPoint2d);
|
||||
aDisplay.MoveTo(aPoint2d);
|
||||
for (intrv = 1; intrv <= nbintv; intrv++) {
|
||||
if (C.GetType() != GeomAbs_Line) {
|
||||
Standard_Real t = TI(intrv);
|
||||
Standard_Real step = (TI(intrv+1) - t) / myDiscret;
|
||||
for (Standard_Integer i = 1; i < myDiscret; i++) {
|
||||
t += step;
|
||||
C.D0(t,aPoint2d);
|
||||
aDisplay.DrawTo(aPoint2d);
|
||||
}
|
||||
}
|
||||
C.D0(TI(intrv+1),aPoint2d);
|
||||
aDisplay.DrawTo(aPoint2d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//static function : PlotCurve
|
||||
//purpose : draw a 3D curve
|
||||
//=======================================================================
|
||||
static void PlotCurve (Draw_Display& aDisplay,
|
||||
const Adaptor3d_Curve& C,
|
||||
Standard_Real& theFirstParam,
|
||||
Standard_Real theHalfStep,
|
||||
const gp_Pnt& theFirstPnt,
|
||||
const gp_Pnt& theLastPnt)
|
||||
{
|
||||
Standard_Real IsoRatio = 1.001;
|
||||
gp_Pnt Pm;
|
||||
|
||||
C.D0 (theFirstParam + theHalfStep, Pm);
|
||||
|
||||
Standard_Real dfLength = theFirstPnt.Distance(theLastPnt);
|
||||
if (dfLength < Precision::Confusion() ||
|
||||
Pm.Distance(theFirstPnt) + Pm.Distance(theLastPnt) <= IsoRatio*dfLength) {
|
||||
aDisplay.DrawTo (theLastPnt);
|
||||
} else {
|
||||
PlotCurve (aDisplay, C, theFirstParam, theHalfStep/2., theFirstPnt, Pm);
|
||||
Standard_Real aLocalF = theFirstParam + theHalfStep;
|
||||
PlotCurve (aDisplay, C, aLocalF, theHalfStep/2., Pm, theLastPnt);
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : DrawCurveOn
|
||||
//purpose : draw a 3D curve
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Drawable::DrawCurveOn (Adaptor3d_Curve& C,
|
||||
Draw_Display& aDisplay) const
|
||||
{
|
||||
gp_Pnt P;
|
||||
if (myDrawMode == 1) {
|
||||
Standard_Real Fleche = myDeflection/aDisplay.Zoom();
|
||||
GCPnts_UniformDeflection LineVu(C,Fleche);
|
||||
if (LineVu.IsDone()) {
|
||||
aDisplay.MoveTo(LineVu.Value(1));
|
||||
for (Standard_Integer i = 2; i <= LineVu.NbPoints(); i++) {
|
||||
aDisplay.DrawTo(LineVu.Value(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Standard_Real j;
|
||||
Standard_Integer intrv, nbintv = C.NbIntervals(GeomAbs_CN);
|
||||
TColStd_Array1OfReal TI(1,nbintv+1);
|
||||
C.Intervals(TI,GeomAbs_CN);
|
||||
C.D0(C.FirstParameter(),P);
|
||||
aDisplay.MoveTo(P);
|
||||
GeomAbs_CurveType CurvType = C.GetType();
|
||||
gp_Pnt aPPnt=P, aNPnt;
|
||||
|
||||
for (intrv = 1; intrv <= nbintv; intrv++) {
|
||||
Standard_Real t = TI(intrv);
|
||||
Standard_Real step = (TI(intrv+1) - t) / myDiscret;
|
||||
|
||||
switch (CurvType) {
|
||||
case GeomAbs_Line :
|
||||
break;
|
||||
case GeomAbs_Circle :
|
||||
case GeomAbs_Ellipse :
|
||||
for (j = 1; j < myDiscret; j++) {
|
||||
t += step;
|
||||
C.D0(t,P);
|
||||
aDisplay.DrawTo(P);
|
||||
}
|
||||
break;
|
||||
case GeomAbs_Parabola :
|
||||
case GeomAbs_Hyperbola :
|
||||
case GeomAbs_BezierCurve :
|
||||
case GeomAbs_BSplineCurve :
|
||||
case GeomAbs_OtherCurve :
|
||||
for (j = 1; j <= myDiscret/2; j++) {
|
||||
C.D0 (t+step*2., aNPnt);
|
||||
PlotCurve (aDisplay, C, t, step, aPPnt, aNPnt);
|
||||
aPPnt = aNPnt;
|
||||
t += step*2.;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
C.D0(TI(intrv+1),P);
|
||||
aDisplay.DrawTo(P);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawIsoCurveOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Drawable::DrawIsoCurveOn(Adaptor3d_IsoCurve& C,
|
||||
const GeomAbs_IsoType T,
|
||||
const Standard_Real P,
|
||||
const Standard_Real F,
|
||||
const Standard_Real L,
|
||||
Draw_Display& dis) const
|
||||
{
|
||||
C.Load(T,P,F,L);
|
||||
if ((C.GetType() == GeomAbs_BezierCurve) ||
|
||||
(C.GetType() == GeomAbs_BSplineCurve)) {
|
||||
GeomAdaptor_Curve GC;
|
||||
if (C.GetType() == GeomAbs_BezierCurve)
|
||||
GC.Load(C.Bezier(),F,L);
|
||||
else
|
||||
GC.Load(C.BSpline(),F,L);
|
||||
|
||||
DrawCurveOn(GC,dis);
|
||||
}
|
||||
else
|
||||
DrawCurveOn(C,dis);
|
||||
|
||||
}
|
50
src/DrawTrSurf/DrawTrSurf_Drawable.lxx
Executable file
50
src/DrawTrSurf/DrawTrSurf_Drawable.lxx
Executable file
@@ -0,0 +1,50 @@
|
||||
// File: DrawTrSurf_Drawable.lxx
|
||||
// Created: Tue Jul 16 09:22:58 1991
|
||||
// Author: Christophe MARION
|
||||
// <cma@sdsun1>
|
||||
|
||||
|
||||
|
||||
|
||||
inline void DrawTrSurf_Drawable::SetDrawMode (
|
||||
const Standard_Integer DrawMode) {
|
||||
|
||||
myDrawMode = DrawMode;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_Drawable::SetDiscretisation (
|
||||
const Standard_Integer Discret) {
|
||||
|
||||
myDiscret = Discret;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_Drawable::SetDeflection (
|
||||
const Standard_Real Deflection) {
|
||||
|
||||
myDeflection = Deflection;
|
||||
}
|
||||
|
||||
|
||||
inline Standard_Integer DrawTrSurf_Drawable::GetDiscretisation () const {
|
||||
|
||||
return myDiscret;
|
||||
}
|
||||
|
||||
inline Standard_Integer DrawTrSurf_Drawable::GetDrawMode () const {
|
||||
|
||||
return myDrawMode;
|
||||
}
|
||||
|
||||
inline Standard_Real DrawTrSurf_Drawable::GetDeflection () const {
|
||||
|
||||
return myDeflection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
85
src/DrawTrSurf/DrawTrSurf_Point.cdl
Executable file
85
src/DrawTrSurf/DrawTrSurf_Point.cdl
Executable file
@@ -0,0 +1,85 @@
|
||||
-- File: DrawTrSurf_Point.cdl
|
||||
-- Created: Mon Mar 28 15:49:05 1994
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@zerox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
|
||||
class Point from DrawTrSurf inherits Drawable3D from Draw
|
||||
|
||||
---Purpose: A drawable point.
|
||||
|
||||
uses
|
||||
Pnt from gp,
|
||||
Pnt2d from gp,
|
||||
MarkerShape from Draw,
|
||||
Color from Draw,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw,
|
||||
Interpretor from Draw
|
||||
|
||||
is
|
||||
|
||||
Create( P : Pnt from gp;
|
||||
Shape : MarkerShape from Draw;
|
||||
Col : Color from Draw)
|
||||
returns mutable Point from DrawTrSurf;
|
||||
|
||||
Create( P : Pnt2d from gp;
|
||||
Shape : MarkerShape from Draw;
|
||||
Col : Color from Draw)
|
||||
returns mutable Point from DrawTrSurf;
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw);
|
||||
|
||||
Is3D(me) returns Boolean
|
||||
---Purpose: Is a 3D object. (Default True).
|
||||
is redefined;
|
||||
|
||||
Point(me) returns Pnt from gp
|
||||
is static;
|
||||
|
||||
Point(me : mutable; P : Pnt from gp)
|
||||
is static;
|
||||
|
||||
Point2d(me) returns Pnt2d from gp
|
||||
is static;
|
||||
|
||||
Point2d(me : mutable; P : Pnt2d from gp)
|
||||
is static;
|
||||
|
||||
Color(me : mutable; aColor : Color from Draw)
|
||||
is static;
|
||||
|
||||
Color (me) returns Color from Draw
|
||||
is static;
|
||||
|
||||
Shape(me : mutable; S : MarkerShape from Draw)
|
||||
is static;
|
||||
|
||||
Shape(me) returns MarkerShape from Draw
|
||||
is static;
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
---Purpose: For variable dump.
|
||||
is redefined;
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
---Purpose: For variable whatis command.
|
||||
is redefined;
|
||||
|
||||
fields
|
||||
|
||||
myPoint : Pnt from gp;
|
||||
is3D : Boolean;
|
||||
myShape : MarkerShape from Draw;
|
||||
myColor : Color from Draw;
|
||||
|
||||
end Point;
|
||||
|
||||
|
206
src/DrawTrSurf/DrawTrSurf_Point.cxx
Executable file
206
src/DrawTrSurf/DrawTrSurf_Point.cxx
Executable file
@@ -0,0 +1,206 @@
|
||||
// File: DrawTrSurf_Point.cxx
|
||||
// Created: Mon Mar 28 16:24:02 1994
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@zerox>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IOS
|
||||
# include <ios>
|
||||
#elif defined(HAVE_IOS_H)
|
||||
# include <ios.h>
|
||||
#endif
|
||||
|
||||
#include <DrawTrSurf_Point.ixx>
|
||||
#include <Standard_Stream.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Point
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Point::DrawTrSurf_Point(const gp_Pnt& P,
|
||||
const Draw_MarkerShape Shape,
|
||||
const Draw_Color& Col) :
|
||||
myPoint(P),
|
||||
is3D(Standard_True),
|
||||
myShape(Shape),
|
||||
myColor(Col)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Point
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Point::DrawTrSurf_Point(const gp_Pnt2d& P,
|
||||
const Draw_MarkerShape Shape,
|
||||
const Draw_Color& Col) :
|
||||
myPoint(P.X(),P.Y(),0.),
|
||||
is3D(Standard_False),
|
||||
myShape(Shape),
|
||||
myColor(Col)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Is3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DrawTrSurf_Point::Is3D() const
|
||||
{
|
||||
return is3D;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Point::DrawOn(Draw_Display& dis) const
|
||||
{
|
||||
dis.SetColor(myColor);
|
||||
if (is3D)
|
||||
dis.DrawMarker(myPoint,myShape);
|
||||
else
|
||||
dis.DrawMarker(Point2d(),myShape);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Point
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt DrawTrSurf_Point::Point() const
|
||||
{
|
||||
return myPoint;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Point
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Point::Point(const gp_Pnt& P)
|
||||
{
|
||||
myPoint = P;
|
||||
is3D = Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Point2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt2d DrawTrSurf_Point::Point2d() const
|
||||
{
|
||||
return gp_Pnt2d(myPoint.X(),myPoint.Y());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Point2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Point::Point2d(const gp_Pnt2d& P)
|
||||
{
|
||||
myPoint.SetCoord(P.X(),P.Y(),0);
|
||||
is3D = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Color
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Point::Color(const Draw_Color& aColor)
|
||||
{
|
||||
myColor = aColor;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Color
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Color DrawTrSurf_Point::Color() const
|
||||
{
|
||||
return myColor;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Shape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Point::Shape(const Draw_MarkerShape S)
|
||||
{
|
||||
myShape = S;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Shape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_MarkerShape DrawTrSurf_Point::Shape() const
|
||||
{
|
||||
return myShape;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_Point::Copy() const
|
||||
{
|
||||
Handle(DrawTrSurf_Point) P;
|
||||
if (is3D)
|
||||
P = new DrawTrSurf_Point(myPoint,myShape,myColor);
|
||||
else
|
||||
P = new DrawTrSurf_Point(Point2d(),myShape,myColor);
|
||||
|
||||
return P;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Point::Dump(Standard_OStream& S) const
|
||||
{
|
||||
#if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
|
||||
ios::fmtflags F = S.flags();
|
||||
S.setf(ios::scientific,ios::floatfield);
|
||||
S.precision(15);
|
||||
#else
|
||||
long form = S.setf(ios::scientific);
|
||||
int prec = S.precision(15);
|
||||
#endif
|
||||
if (is3D)
|
||||
S << "Point : " << myPoint.X() << ", " << myPoint.Y() << ", " << myPoint.Z() <<endl;
|
||||
else
|
||||
S << "Point 2d : " << myPoint.X() << ", " << myPoint.Y() <<endl;
|
||||
#if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
|
||||
S.setf(F);
|
||||
#else
|
||||
S.setf(form);
|
||||
S.precision(prec);
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Point::Whatis(Draw_Interpretor& S) const
|
||||
{
|
||||
S << "point";
|
||||
}
|
54
src/DrawTrSurf/DrawTrSurf_Polygon2D.cdl
Executable file
54
src/DrawTrSurf/DrawTrSurf_Polygon2D.cdl
Executable file
@@ -0,0 +1,54 @@
|
||||
-- File: DrawTrSurf_Polygon2D.cdl
|
||||
-- Created: Fri Mar 10 10:11:24 1995
|
||||
-- Author: Laurent PAINNOT
|
||||
-- <lpa@metrox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
|
||||
class Polygon2D from DrawTrSurf inherits Drawable2D from Draw
|
||||
|
||||
---Purpose: Used to display a 2d polygon.
|
||||
--
|
||||
-- Optional display of nodes.
|
||||
|
||||
|
||||
uses Polygon2D from Poly,
|
||||
Display from Draw,
|
||||
Drawable3D from Draw,
|
||||
Interpretor from Draw,
|
||||
OStream
|
||||
is
|
||||
|
||||
Create(P: Polygon2D from Poly)
|
||||
returns mutable Polygon2D from DrawTrSurf;
|
||||
|
||||
Polygon2D(me) returns Polygon2D from Poly;
|
||||
|
||||
ShowNodes(me: mutable; B: Boolean);
|
||||
|
||||
ShowNodes(me) returns Boolean;
|
||||
|
||||
DrawOn(me; dis: in out Display);
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
is redefined;
|
||||
---Purpose: For variable copy.
|
||||
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
is redefined;
|
||||
---Purpose: For variable dump.
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
---Purpose: For variable whatis command. Set as a result the
|
||||
-- type of the variable.
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myPolygon2D: Polygon2D from Poly;
|
||||
myNodes: Boolean;
|
||||
|
||||
end Polygon2D;
|
107
src/DrawTrSurf/DrawTrSurf_Polygon2D.cxx
Executable file
107
src/DrawTrSurf/DrawTrSurf_Polygon2D.cxx
Executable file
@@ -0,0 +1,107 @@
|
||||
// File: DrawTrSurf_Polygon2D.cxx
|
||||
// Created: Tue Mar 14 16:13:44 1995
|
||||
// Author: Laurent PAINNOT
|
||||
// <lpa@metrox>
|
||||
|
||||
|
||||
#include <DrawTrSurf_Polygon2D.ixx>
|
||||
#include <Poly.hxx>
|
||||
#include <Draw_Color.hxx>
|
||||
#include <Draw_MarkerShape.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Polygon2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Polygon2D::DrawTrSurf_Polygon2D(const Handle(Poly_Polygon2D)& P):
|
||||
myPolygon2D(P),
|
||||
myNodes(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Polygon2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Polygon2D) DrawTrSurf_Polygon2D::Polygon2D() const
|
||||
{
|
||||
return myPolygon2D;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShowNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Polygon2D::ShowNodes(const Standard_Boolean B)
|
||||
{
|
||||
myNodes = B;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShowNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DrawTrSurf_Polygon2D::ShowNodes() const
|
||||
{
|
||||
return myNodes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Polygon2D::DrawOn(Draw_Display& dis) const
|
||||
{
|
||||
dis.SetColor(Draw_jaune);
|
||||
|
||||
|
||||
const TColgp_Array1OfPnt2d& Points = myPolygon2D->Nodes();
|
||||
|
||||
for (Standard_Integer i = Points.Lower(); i <= Points.Upper()-1; i++) {
|
||||
dis.Draw(Points(i), Points(i+1));
|
||||
}
|
||||
|
||||
|
||||
if (myNodes) {
|
||||
for (Standard_Integer i = Points.Lower(); i <= Points.Upper(); i++) {
|
||||
dis.DrawMarker(Points(i), Draw_X);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_Polygon2D::Copy() const
|
||||
{
|
||||
return new DrawTrSurf_Polygon2D(myPolygon2D);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Polygon2D::Dump(Standard_OStream& S) const
|
||||
{
|
||||
Poly::Dump(myPolygon2D, S);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Polygon2D::Whatis(Draw_Interpretor& I) const
|
||||
{
|
||||
I << "polygon2D";
|
||||
}
|
||||
|
53
src/DrawTrSurf/DrawTrSurf_Polygon3D.cdl
Executable file
53
src/DrawTrSurf/DrawTrSurf_Polygon3D.cdl
Executable file
@@ -0,0 +1,53 @@
|
||||
-- File: DrawTrSurf_Polygon3D.cdl
|
||||
-- Created: Thu Mar 9 17:00:59 1995
|
||||
-- Author: Laurent PAINNOT
|
||||
-- <lpa@metrox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class Polygon3D from DrawTrSurf inherits Drawable3D from Draw
|
||||
|
||||
---Purpose: Used to display a 3d polygon.
|
||||
--
|
||||
-- Optional display of nodes.
|
||||
|
||||
|
||||
uses Polygon3D from Poly,
|
||||
Display from Draw,
|
||||
Interpretor from Draw,
|
||||
OStream
|
||||
|
||||
is
|
||||
|
||||
Create(P: Polygon3D from Poly)
|
||||
returns mutable Polygon3D from DrawTrSurf;
|
||||
|
||||
Polygon3D(me) returns Polygon3D from Poly;
|
||||
|
||||
ShowNodes(me: mutable; B: Boolean);
|
||||
|
||||
ShowNodes(me) returns Boolean;
|
||||
|
||||
DrawOn(me; dis: in out Display);
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
is redefined;
|
||||
---Purpose: For variable copy.
|
||||
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
is redefined;
|
||||
---Purpose: For variable dump.
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
---Purpose: For variable whatis command. Set as a result the
|
||||
-- type of the variable.
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myPolygon3D: Polygon3D from Poly;
|
||||
myNodes: Boolean;
|
||||
|
||||
end Polygon3D;
|
108
src/DrawTrSurf/DrawTrSurf_Polygon3D.cxx
Executable file
108
src/DrawTrSurf/DrawTrSurf_Polygon3D.cxx
Executable file
@@ -0,0 +1,108 @@
|
||||
// File: DrawTrSurf_Polygon3D.cxx
|
||||
// Created: Fri Mar 10 15:19:08 1995
|
||||
// Author: Laurent PAINNOT
|
||||
// <lpa@metrox>
|
||||
|
||||
|
||||
#include <DrawTrSurf_Polygon3D.ixx>
|
||||
#include <Poly.hxx>
|
||||
#include <Draw_Color.hxx>
|
||||
#include <Draw_MarkerShape.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Polygon3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Polygon3D::DrawTrSurf_Polygon3D(const Handle(Poly_Polygon3D)& P):
|
||||
myPolygon3D(P),
|
||||
myNodes(Standard_False)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Polygon3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Polygon3D) DrawTrSurf_Polygon3D::Polygon3D() const
|
||||
{
|
||||
return myPolygon3D;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShowNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Polygon3D::ShowNodes(const Standard_Boolean B)
|
||||
{
|
||||
myNodes = B;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShowNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DrawTrSurf_Polygon3D::ShowNodes() const
|
||||
{
|
||||
return myNodes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Polygon3D::DrawOn(Draw_Display& dis) const
|
||||
{
|
||||
dis.SetColor(Draw_jaune);
|
||||
|
||||
const TColgp_Array1OfPnt& Points = myPolygon3D->Nodes();
|
||||
|
||||
for (Standard_Integer i = Points.Lower(); i <= Points.Upper()-1; i++) {
|
||||
dis.Draw(Points(i), Points(i+1));
|
||||
}
|
||||
|
||||
|
||||
if (myNodes) {
|
||||
for (Standard_Integer i = Points.Lower(); i <= Points.Upper(); i++) {
|
||||
dis.DrawMarker(Points(i), Draw_X);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_Polygon3D::Copy() const
|
||||
{
|
||||
return new DrawTrSurf_Polygon3D(myPolygon3D);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Polygon3D::Dump(Standard_OStream& S) const
|
||||
{
|
||||
Poly::Dump(myPolygon3D, S);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Polygon3D::Whatis(Draw_Interpretor& I) const
|
||||
{
|
||||
I << "polygon3D";
|
||||
}
|
||||
|
110
src/DrawTrSurf/DrawTrSurf_Surface.cdl
Executable file
110
src/DrawTrSurf/DrawTrSurf_Surface.cdl
Executable file
@@ -0,0 +1,110 @@
|
||||
-- File: Surface.cdl
|
||||
-- Created: Thu May 21 19:22:42 1992
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
-- <jcv@sdsun4>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Surface from DrawTrSurf
|
||||
|
||||
inherits Drawable
|
||||
|
||||
---Purpose: This class defines a drawable surface.
|
||||
-- With this class you can draw a general surface from
|
||||
-- package Geom.
|
||||
|
||||
uses Surface from Geom,
|
||||
Display from Draw,
|
||||
Color from Draw,
|
||||
Drawable3D from Draw,
|
||||
Interpretor from Draw
|
||||
|
||||
is
|
||||
|
||||
Create (S : Surface from Geom)
|
||||
--- Purpose : default drawing mode
|
||||
-- Just the middle isoparametric curves are drawn.
|
||||
-- The boundaries are yellow, the isoparametric curves are blues.
|
||||
-- For the discretisation 50 points are computed in each parametric
|
||||
-- direction.
|
||||
returns mutable Surface from DrawTrSurf;
|
||||
|
||||
|
||||
|
||||
Create (S : Surface from Geom;
|
||||
Nu, Nv : Integer;
|
||||
BoundsColor, IsosColor : Color from Draw;
|
||||
Discret : Integer;
|
||||
Deflection : Real;
|
||||
DrawMode : Integer)
|
||||
returns mutable Surface from DrawTrSurf;
|
||||
|
||||
|
||||
BoundsColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
ClearIsos (me : mutable) is virtual;
|
||||
--- Purpose : rub out all the isoparametric curves.
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw);
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display from Draw;
|
||||
Iso : Boolean from Standard)
|
||||
---Purpose: Iso = True : Draw the isos, the boundaries, the UVMarker.
|
||||
-- Iso = False: Only Draw the boundary and the UVMarker.
|
||||
is static;
|
||||
|
||||
|
||||
GetSurface (me) returns any Surface from Geom
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
IsosColor (me) returns Color from Draw
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
NbIsos (me; Nu, Nb : in out Integer)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
SetBoundsColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
SetIsosColor (me : mutable; aColor : Color from Draw)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
ShowIsos (me : mutable; Nu, Nv : Integer) is virtual;
|
||||
--- Purpose : change the number of isoparametric curves to be drawn.
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
---Purpose: For variable dump.
|
||||
is redefined;
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
---Purpose: For variable whatis command.
|
||||
is redefined;
|
||||
|
||||
fields
|
||||
|
||||
surf : Surface from Geom is protected;
|
||||
boundsLook : Color from Draw is protected;
|
||||
isosLook : Color from Draw is protected;
|
||||
nbUIsos : Integer is protected;
|
||||
nbVIsos : Integer is protected;
|
||||
|
||||
end Surface;
|
251
src/DrawTrSurf/DrawTrSurf_Surface.cxx
Executable file
251
src/DrawTrSurf/DrawTrSurf_Surface.cxx
Executable file
@@ -0,0 +1,251 @@
|
||||
#include <DrawTrSurf_Surface.ixx>
|
||||
#include <GeomTools_SurfaceSet.hxx>
|
||||
#include <GeomAdaptor_HSurface.hxx>
|
||||
#include <Adaptor3d_IsoCurve.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
Standard_Real DrawTrSurf_SurfaceLimit = 400;
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Surface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Surface::DrawTrSurf_Surface (const Handle(Geom_Surface)& S)
|
||||
: DrawTrSurf_Drawable (16, 0.01, 1)
|
||||
{
|
||||
surf = S;
|
||||
boundsLook = Draw_jaune;
|
||||
isosLook = Draw_bleu;
|
||||
nbUIsos = 1;
|
||||
nbVIsos = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Surface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Surface::DrawTrSurf_Surface
|
||||
(const Handle(Geom_Surface)& S, const Standard_Integer Nu,
|
||||
const Standard_Integer Nv,
|
||||
const Draw_Color& BoundsColor, const Draw_Color& IsosColor,
|
||||
const Standard_Integer Discret, const Standard_Real Deflection,
|
||||
const Standard_Integer DrawMode)
|
||||
: DrawTrSurf_Drawable (Discret, Deflection, DrawMode)
|
||||
{
|
||||
surf = S;
|
||||
boundsLook = BoundsColor;
|
||||
isosLook = IsosColor;
|
||||
nbUIsos = Abs(Nu);
|
||||
nbVIsos = Abs(Nv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Surface::DrawOn (Draw_Display& dis) const
|
||||
{
|
||||
DrawOn(dis,Standard_True);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Surface::DrawOn (Draw_Display& dis,
|
||||
const Standard_Boolean Iso) const
|
||||
{
|
||||
Standard_Real UFirst, ULast, VFirst, VLast;
|
||||
surf->Bounds (UFirst, ULast, VFirst, VLast);
|
||||
|
||||
Standard_Boolean UfirstInf = Precision::IsNegativeInfinite(UFirst);
|
||||
Standard_Boolean UlastInf = Precision::IsPositiveInfinite(ULast);
|
||||
Standard_Boolean VfirstInf = Precision::IsNegativeInfinite(VFirst);
|
||||
Standard_Boolean VlastInf = Precision::IsPositiveInfinite(VLast);
|
||||
|
||||
if (UfirstInf || UlastInf) {
|
||||
gp_Pnt P1,P2;
|
||||
Standard_Real v;
|
||||
if (VfirstInf && VlastInf)
|
||||
v = 0;
|
||||
else if (VfirstInf)
|
||||
v = VLast;
|
||||
else if (VlastInf)
|
||||
v = VFirst;
|
||||
else
|
||||
v = (VFirst + VLast) / 2;
|
||||
|
||||
Standard_Real delta = 1.;
|
||||
|
||||
if (UfirstInf && UlastInf) {
|
||||
do {
|
||||
delta *= 2;
|
||||
UFirst = - delta;
|
||||
ULast = delta;
|
||||
surf->D0(UFirst,v,P1);
|
||||
surf->D0(ULast,v,P2);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_SurfaceLimit);
|
||||
}
|
||||
else if (UfirstInf) {
|
||||
surf->D0(ULast,v,P2);
|
||||
do {
|
||||
delta *= 2;
|
||||
UFirst = ULast - delta;
|
||||
surf->D0(UFirst,v,P1);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_SurfaceLimit);
|
||||
}
|
||||
else if (UlastInf) {
|
||||
surf->D0(UFirst,v,P1);
|
||||
do {
|
||||
delta *= 2;
|
||||
ULast = UFirst + delta;
|
||||
surf->D0(ULast,v,P2);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_SurfaceLimit);
|
||||
}
|
||||
}
|
||||
|
||||
if (VfirstInf || VlastInf) {
|
||||
gp_Pnt P1,P2;
|
||||
Standard_Real u = (UFirst + ULast) /2 ;
|
||||
|
||||
Standard_Real delta = 1.;
|
||||
|
||||
if (VfirstInf && VlastInf) {
|
||||
do {
|
||||
delta *= 2;
|
||||
VFirst = - delta;
|
||||
VLast = delta;
|
||||
surf->D0(u,VFirst,P1);
|
||||
surf->D0(u,VLast,P2);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_SurfaceLimit);
|
||||
}
|
||||
else if (VfirstInf) {
|
||||
surf->D0(u,VLast,P2);
|
||||
do {
|
||||
delta *= 2;
|
||||
VFirst = VLast - delta;
|
||||
surf->D0(u,VFirst,P1);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_SurfaceLimit);
|
||||
}
|
||||
else if (VlastInf) {
|
||||
surf->D0(u,VFirst,P1);
|
||||
do {
|
||||
delta *= 2;
|
||||
VLast = VFirst + delta;
|
||||
surf->D0(u,VLast,P2);
|
||||
} while (P1.Distance(P2) < DrawTrSurf_SurfaceLimit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
|
||||
HS->ChangeSurface().Load(surf,UFirst,ULast,VFirst,VLast);
|
||||
|
||||
Adaptor3d_IsoCurve C(HS);
|
||||
|
||||
if (Iso) {
|
||||
dis.SetColor(isosLook);
|
||||
Standard_Integer i, j;
|
||||
|
||||
Standard_Real Du = (ULast - UFirst) / (nbUIsos + 1);
|
||||
Standard_Real U = UFirst;
|
||||
for (i = 1; i <= nbUIsos; i++) {
|
||||
U += Du;
|
||||
DrawIsoCurveOn(C,GeomAbs_IsoU,U,VFirst,VLast,dis);
|
||||
}
|
||||
|
||||
Standard_Real Dv = (VLast - VFirst) / (nbVIsos + 1);
|
||||
Standard_Real V = VFirst;
|
||||
for (j = 1; j <= nbVIsos; j++) {
|
||||
V += Dv;
|
||||
DrawIsoCurveOn(C,GeomAbs_IsoV,V,UFirst,ULast,dis);
|
||||
}
|
||||
}
|
||||
|
||||
// draw bounds
|
||||
dis.SetColor(boundsLook);
|
||||
if (!UfirstInf) DrawIsoCurveOn(C,GeomAbs_IsoU,UFirst,VFirst,VLast,dis);
|
||||
if (!UlastInf) DrawIsoCurveOn(C,GeomAbs_IsoU,ULast ,VFirst,VLast,dis);
|
||||
if (!VfirstInf) DrawIsoCurveOn(C,GeomAbs_IsoV,VFirst,UFirst,ULast,dis);
|
||||
if (!VlastInf) DrawIsoCurveOn(C,GeomAbs_IsoV,VLast ,UFirst,ULast,dis);
|
||||
|
||||
// draw marker
|
||||
DrawIsoCurveOn(C,GeomAbs_IsoU,
|
||||
UFirst+(ULast-UFirst)/10.,
|
||||
VFirst, VFirst + (VLast-VFirst)/10.,
|
||||
dis);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShowIsos
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Surface::ShowIsos ( const Standard_Integer Nu,
|
||||
const Standard_Integer Nv)
|
||||
{
|
||||
nbUIsos = Abs(Nu);
|
||||
nbVIsos = Abs(Nv);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ClearIsos
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Surface::ClearIsos ()
|
||||
{
|
||||
nbUIsos = 0;
|
||||
nbVIsos = 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_Surface::Copy() const
|
||||
{
|
||||
Handle(DrawTrSurf_Surface) DS = new DrawTrSurf_Surface
|
||||
(Handle(Geom_Surface)::DownCast(surf->Copy()),
|
||||
nbUIsos,nbVIsos,boundsLook,isosLook,
|
||||
GetDiscretisation(),GetDeflection(),GetDrawMode());
|
||||
|
||||
return DS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Surface::Dump(Standard_OStream& S)const
|
||||
{
|
||||
GeomTools_SurfaceSet::PrintSurface(surf,S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Surface::Whatis(Draw_Interpretor& S)const
|
||||
{
|
||||
S << "a surface";
|
||||
}
|
34
src/DrawTrSurf/DrawTrSurf_Surface.lxx
Executable file
34
src/DrawTrSurf/DrawTrSurf_Surface.lxx
Executable file
@@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
inline Handle(Geom_Surface) DrawTrSurf_Surface::GetSurface () const {
|
||||
return surf;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_Surface::BoundsColor () const {
|
||||
return boundsLook;
|
||||
}
|
||||
|
||||
|
||||
inline Draw_Color DrawTrSurf_Surface::IsosColor () const {
|
||||
return isosLook;
|
||||
}
|
||||
|
||||
|
||||
inline void DrawTrSurf_Surface::SetIsosColor (const Draw_Color& aColor) {
|
||||
|
||||
isosLook = aColor;
|
||||
}
|
||||
|
||||
inline void DrawTrSurf_Surface::SetBoundsColor (const Draw_Color& aColor) {
|
||||
|
||||
boundsLook = aColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void DrawTrSurf_Surface::NbIsos (Standard_Integer& Nu, Standard_Integer& Nv) const {
|
||||
|
||||
Nu = nbUIsos;
|
||||
Nv = nbVIsos;
|
||||
}
|
62
src/DrawTrSurf/DrawTrSurf_Triangulation.cdl
Executable file
62
src/DrawTrSurf/DrawTrSurf_Triangulation.cdl
Executable file
@@ -0,0 +1,62 @@
|
||||
-- File: DrawTrSurf_Triangulation.cdl
|
||||
-- Created: Mon Mar 6 16:10:04 1995
|
||||
-- Author: Laurent PAINNOT
|
||||
-- <lpa@metrox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class Triangulation from DrawTrSurf inherits Drawable3D from Draw
|
||||
|
||||
---Purpose: Used to display a triangulation.
|
||||
--
|
||||
-- Display internal edges in blue
|
||||
-- Display boundary edges in red
|
||||
-- Optional display of triangles and nodes indices.
|
||||
|
||||
uses
|
||||
HArray1OfInteger from TColStd,
|
||||
Triangulation from Poly,
|
||||
Display from Draw,
|
||||
Interpretor from Draw,
|
||||
OStream
|
||||
|
||||
is
|
||||
|
||||
Create(T : Triangulation from Poly)
|
||||
returns mutable Triangulation from DrawTrSurf;
|
||||
|
||||
Triangulation(me)
|
||||
returns Triangulation from Poly;
|
||||
|
||||
ShowNodes(me : mutable; B : Boolean);
|
||||
|
||||
ShowNodes(me) returns Boolean;
|
||||
|
||||
ShowTriangles(me : mutable; B : Boolean);
|
||||
|
||||
ShowTriangles(me) returns Boolean;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
is redefined;
|
||||
---Purpose: For variable copy.
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
is redefined;
|
||||
---Purpose: For variable dump.
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
---Purpose: For variable whatis command. Set as a result the
|
||||
-- type of the variable.
|
||||
|
||||
fields
|
||||
|
||||
myTriangulation : Triangulation from Poly;
|
||||
myInternals : HArray1OfInteger from TColStd;
|
||||
myFree : HArray1OfInteger from TColStd;
|
||||
myNodes : Boolean;
|
||||
myTriangles : Boolean;
|
||||
|
||||
end Triangulation;
|
215
src/DrawTrSurf/DrawTrSurf_Triangulation.cxx
Executable file
215
src/DrawTrSurf/DrawTrSurf_Triangulation.cxx
Executable file
@@ -0,0 +1,215 @@
|
||||
// File: DrawTrSurf_Triangulation.cxx
|
||||
// Created: Mon Mar 6 16:49:54 1995
|
||||
// Author: Laurent PAINNOT
|
||||
// <lpa@metrox>
|
||||
|
||||
|
||||
#include <DrawTrSurf_Triangulation.ixx>
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <Poly_Triangle.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Draw_Color.hxx>
|
||||
#include <Poly.hxx>
|
||||
|
||||
//#ifdef WNT
|
||||
#include <stdio.h>
|
||||
//#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Triangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Triangulation::DrawTrSurf_Triangulation
|
||||
(const Handle(Poly_Triangulation)& T):
|
||||
myTriangulation(T),
|
||||
myNodes(Standard_False),
|
||||
myTriangles(Standard_False)
|
||||
{
|
||||
// Build the connect tool
|
||||
Poly_Connect pc(T);
|
||||
|
||||
Standard_Integer i,j,nFree, nInternal, nbTriangles = T->NbTriangles();
|
||||
Standard_Integer t[3];
|
||||
|
||||
// count the free edges
|
||||
nFree = 0;
|
||||
for (i = 1; i <= nbTriangles; i++) {
|
||||
pc.Triangles(i,t[0],t[1],t[2]);
|
||||
for (j = 0; j < 3; j++)
|
||||
if (t[j] == 0) nFree++;
|
||||
}
|
||||
|
||||
// allocate the arrays
|
||||
myFree = new TColStd_HArray1OfInteger(1,2*nFree);
|
||||
nInternal = (3*nbTriangles - nFree) / 2;
|
||||
myInternals = new TColStd_HArray1OfInteger(1,2*nInternal);
|
||||
|
||||
TColStd_Array1OfInteger& Free = myFree->ChangeArray1();
|
||||
TColStd_Array1OfInteger& Internal = myInternals->ChangeArray1();
|
||||
|
||||
Standard_Integer fr = 1, in = 1;
|
||||
const Poly_Array1OfTriangle& triangles = T->Triangles();
|
||||
Standard_Integer n[3];
|
||||
for (i = 1; i <= nbTriangles; i++) {
|
||||
pc.Triangles(i,t[0],t[1],t[2]);
|
||||
triangles(i).Get(n[0],n[1],n[2]);
|
||||
for (j = 0; j < 3; j++) {
|
||||
Standard_Integer k = (j+1) % 3;
|
||||
if (t[j] == 0) {
|
||||
Free(fr) = n[j];
|
||||
Free(fr+1) = n[k];
|
||||
fr += 2;
|
||||
}
|
||||
// internal edge if this triangle has a lower index than the adjacent
|
||||
else if (i < t[j]) {
|
||||
Internal(in) = n[j];
|
||||
Internal(in+1) = n[k];
|
||||
in += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Triangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Triangulation) DrawTrSurf_Triangulation::Triangulation() const
|
||||
{
|
||||
return myTriangulation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShowNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Triangulation::ShowNodes(const Standard_Boolean B)
|
||||
{
|
||||
myNodes = B;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShowNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DrawTrSurf_Triangulation::ShowNodes() const
|
||||
{
|
||||
return myNodes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShowTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Triangulation::ShowTriangles(const Standard_Boolean B)
|
||||
{
|
||||
myTriangles = B;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShowTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DrawTrSurf_Triangulation::ShowTriangles() const
|
||||
{
|
||||
return myTriangles;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
|
||||
{
|
||||
// Display the edges
|
||||
Standard_Integer i,n;
|
||||
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangulation->Nodes();
|
||||
|
||||
// free edges
|
||||
|
||||
dis.SetColor(Draw_rouge);
|
||||
const TColStd_Array1OfInteger& Free = myFree->Array1();
|
||||
n = Free.Length() / 2;
|
||||
for (i = 1; i <= n; i++) {
|
||||
dis.Draw(Nodes(Free(2*i-1)),Nodes(Free(2*i)));
|
||||
}
|
||||
|
||||
// internal edges
|
||||
|
||||
dis.SetColor(Draw_bleu);
|
||||
const TColStd_Array1OfInteger& Internal = myInternals->Array1();
|
||||
n = Internal.Length() / 2;
|
||||
for (i = 1; i <= n; i++) {
|
||||
dis.Draw(Nodes(Internal(2*i-1)),Nodes(Internal(2*i)));
|
||||
}
|
||||
|
||||
// texts
|
||||
char text[50];
|
||||
if (myNodes) {
|
||||
dis.SetColor(Draw_jaune);
|
||||
n = myTriangulation->NbNodes();
|
||||
for (i = 1; i <= n; i++) {
|
||||
sprintf(text,"%d",i);
|
||||
dis.DrawString(Nodes(i),text);
|
||||
}
|
||||
}
|
||||
|
||||
if (myTriangles) {
|
||||
dis.SetColor(Draw_vert);
|
||||
n = myTriangulation->NbTriangles();
|
||||
Standard_Integer t[3],j;
|
||||
const Poly_Array1OfTriangle& triangle = myTriangulation->Triangles();
|
||||
for (i = 1; i <= n; i++) {
|
||||
triangle(i).Get(t[0],t[1],t[2]);
|
||||
gp_Pnt P(0,0,0);
|
||||
gp_XYZ& bary = P.ChangeCoord();
|
||||
for (j = 0; j < 3; j++)
|
||||
bary.Add(Nodes(t[j]).Coord());
|
||||
bary.Multiply(1./3.);
|
||||
|
||||
sprintf(text,"%d",i);
|
||||
dis.DrawString(P,text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_Triangulation::Copy() const
|
||||
{
|
||||
return new DrawTrSurf_Triangulation(myTriangulation);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Triangulation::Dump(Standard_OStream& S) const
|
||||
{
|
||||
Poly::Dump(myTriangulation,S);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Triangulation::Whatis(Draw_Interpretor& I) const
|
||||
{
|
||||
I << "triangulation";
|
||||
}
|
||||
|
53
src/DrawTrSurf/DrawTrSurf_Triangulation2D.cdl
Executable file
53
src/DrawTrSurf/DrawTrSurf_Triangulation2D.cdl
Executable file
@@ -0,0 +1,53 @@
|
||||
-- File: DrawTrSurf_Triangulation2D.cdl
|
||||
-- Created: Tue Jul 22 15:09:16 1997
|
||||
-- Author: Laurent PAINNOT
|
||||
-- <lpa@penox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
class Triangulation2D from DrawTrSurf inherits Drawable2D from Draw
|
||||
|
||||
---Purpose: Used to display a 2d triangulation.
|
||||
--
|
||||
-- Display internal edges in blue
|
||||
-- Display boundary edges in red
|
||||
-- Optional display of triangles and nodes indices.
|
||||
|
||||
uses
|
||||
HArray1OfInteger from TColStd,
|
||||
Triangulation from Poly,
|
||||
Drawable3D from Draw,
|
||||
Display from Draw,
|
||||
Interpretor from Draw,
|
||||
OStream
|
||||
|
||||
is
|
||||
|
||||
Create(T : Triangulation from Poly)
|
||||
returns mutable Triangulation2D from DrawTrSurf;
|
||||
|
||||
Triangulation(me)
|
||||
returns Triangulation from Poly;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
is redefined;
|
||||
---Purpose: For variable copy.
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
is redefined;
|
||||
---Purpose: For variable dump.
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
---Purpose: For variable whatis command. Set as a result the
|
||||
-- type of the variable.
|
||||
|
||||
fields
|
||||
|
||||
myTriangulation : Triangulation from Poly;
|
||||
myInternals : HArray1OfInteger from TColStd;
|
||||
myFree : HArray1OfInteger from TColStd;
|
||||
|
||||
end Triangulation2D;
|
148
src/DrawTrSurf/DrawTrSurf_Triangulation2D.cxx
Executable file
148
src/DrawTrSurf/DrawTrSurf_Triangulation2D.cxx
Executable file
@@ -0,0 +1,148 @@
|
||||
// File: DrawTrSurf_Triangulation2D.cxx
|
||||
// Created: Tue Jul 22 15:10:36 1997
|
||||
// Author: Laurent PAINNOT
|
||||
// <lpa@penox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DrawTrSurf_Triangulation2D.ixx>
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <Poly_Triangle.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <Draw_Color.hxx>
|
||||
#include <Poly.hxx>
|
||||
|
||||
#ifdef WNT
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawTrSurf_Triangulation2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DrawTrSurf_Triangulation2D::DrawTrSurf_Triangulation2D
|
||||
(const Handle(Poly_Triangulation)& T):
|
||||
myTriangulation(T)
|
||||
{
|
||||
// Build the connect tool
|
||||
Poly_Connect pc(T);
|
||||
|
||||
Standard_Integer i,j,nFree, nInternal, nbTriangles = T->NbTriangles();
|
||||
Standard_Integer t[3];
|
||||
|
||||
// count the free edges
|
||||
nFree = 0;
|
||||
for (i = 1; i <= nbTriangles; i++) {
|
||||
pc.Triangles(i,t[0],t[1],t[2]);
|
||||
for (j = 0; j < 3; j++)
|
||||
if (t[j] == 0) nFree++;
|
||||
}
|
||||
|
||||
// allocate the arrays
|
||||
myFree = new TColStd_HArray1OfInteger(1,2*nFree);
|
||||
nInternal = (3*nbTriangles - nFree) / 2;
|
||||
myInternals = new TColStd_HArray1OfInteger(1,2*nInternal);
|
||||
|
||||
TColStd_Array1OfInteger& Free = myFree->ChangeArray1();
|
||||
TColStd_Array1OfInteger& Internal = myInternals->ChangeArray1();
|
||||
|
||||
Standard_Integer fr = 1, in = 1;
|
||||
const Poly_Array1OfTriangle& triangles = T->Triangles();
|
||||
Standard_Integer n[3];
|
||||
for (i = 1; i <= nbTriangles; i++) {
|
||||
pc.Triangles(i,t[0],t[1],t[2]);
|
||||
triangles(i).Get(n[0],n[1],n[2]);
|
||||
for (j = 0; j < 3; j++) {
|
||||
Standard_Integer k = (j+1) % 3;
|
||||
if (t[j] == 0) {
|
||||
Free(fr) = n[j];
|
||||
Free(fr+1) = n[k];
|
||||
fr += 2;
|
||||
}
|
||||
// internal edge if this triangle has a lower index than the adjacent
|
||||
else if (i < t[j]) {
|
||||
Internal(in) = n[j];
|
||||
Internal(in+1) = n[k];
|
||||
in += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Triangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Triangulation) DrawTrSurf_Triangulation2D::Triangulation() const
|
||||
{
|
||||
return myTriangulation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Triangulation2D::DrawOn(Draw_Display& dis) const
|
||||
{
|
||||
// Display the edges
|
||||
Standard_Integer i,n;
|
||||
if (myTriangulation->HasUVNodes()) {
|
||||
|
||||
const TColgp_Array1OfPnt2d& Nodes = myTriangulation->UVNodes();
|
||||
|
||||
// free edges
|
||||
|
||||
dis.SetColor(Draw_rouge);
|
||||
const TColStd_Array1OfInteger& Free = myFree->Array1();
|
||||
n = Free.Length() / 2;
|
||||
for (i = 1; i <= n; i++) {
|
||||
dis.Draw(Nodes(Free(2*i-1)),Nodes(Free(2*i)));
|
||||
}
|
||||
|
||||
// internal edges
|
||||
|
||||
dis.SetColor(Draw_bleu);
|
||||
const TColStd_Array1OfInteger& Internal = myInternals->Array1();
|
||||
n = Internal.Length() / 2;
|
||||
for (i = 1; i <= n; i++) {
|
||||
dis.Draw(Nodes(Internal(2*i-1)),Nodes(Internal(2*i)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_Triangulation2D::Copy() const
|
||||
{
|
||||
return new DrawTrSurf_Triangulation2D(myTriangulation);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Triangulation2D::Dump(Standard_OStream& S) const
|
||||
{
|
||||
Poly::Dump(myTriangulation,S);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DrawTrSurf_Triangulation2D::Whatis(Draw_Interpretor& I) const
|
||||
{
|
||||
I << "triangulation";
|
||||
}
|
||||
|
1
src/DrawTrSurf/FILES
Executable file
1
src/DrawTrSurf/FILES
Executable file
@@ -0,0 +1 @@
|
||||
DrawTrSurf_Debug.cxx
|
Reference in New Issue
Block a user