Save/Restore interface has been moved to Draw_Drawable3D base class.
Create a singleton Draw_Params class for DRAW parameters
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <BinTools_ShapeSet.hxx>
+#include <DBRep.hxx>
+
#include <BRep_TEdge.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepGProp.hxx>
#include <BRepTools_ShapeSet.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <BinTools.hxx>
-#include <DBRep.hxx>
#include <DBRep_DrawableShape.hxx>
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <GProp_GProps.hxx>
#include <NCollection_Vector.hxx>
#include <OSD_OpenFile.hxx>
-#include <Poly_Triangulation.hxx>
#include <Precision.hxx>
-#include <Standard.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
-#include <TopoDS_Shape.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
return col;
}
-//==========================================
-// static variables
-//==========================================
-
-static Standard_Integer nbIsos = 2;
-static Standard_Real size = 100.;
-static Standard_Integer discret = 30;
-static Standard_Boolean disptriangles = Standard_False;
-static Standard_Boolean disppolygons = Standard_False;
-static Standard_Real anglHLR = 35 * M_PI / 180;
-static Standard_Real HAngMin = 1 * M_PI / 180;
-static Standard_Real HAngMax = 35 * M_PI / 180;
-static Standard_Boolean withHLR = Standard_False;
-static Standard_Boolean withRg1 = Standard_True;
-static Standard_Boolean withRgN = Standard_False;
-static Standard_Boolean withHid = Standard_False;
+//=======================================================================
+//function : Parameters
+//purpose :
+//=======================================================================
+DBRep_Params& DBRep::Parameters()
+{
+ static DBRep_Params aParams;
+ return aParams;
+}
//=======================================================================
// isos
//=======================================================================
-static Standard_Integer isos (Draw_Interpretor& di,
- Standard_Integer NbArg, const char **Arg)
+static Standard_Integer isos(Draw_Interpretor& di, Standard_Integer NbArg, const char **Arg)
{
+ DBRep_Params& aParams = DBRep::Parameters();
NbArg-- ;
-
- if (NbArg <= 0) {
- di << "Current number of isos : " << nbIsos << "\n" ;
+ if (NbArg <= 0)
+ {
+ di << "Current number of isos : " << aParams.NbIsos << "\n" ;
return 0 ;
}
- Standard_Integer NbIsos = 0 ;
+ Standard_Integer aNbIsos = 0;
Standard_Boolean Change = Standard_False ;
if (!Characters (NbArg) && Float (NbArg)) return 1 ;
- if (!Characters (NbArg)) {
- NbIsos = Draw::Atoi (Arg[NbArg]) ;
+ if (!Characters (NbArg))
+ {
+ aNbIsos = Draw::Atoi (Arg[NbArg]);
NbArg-- ;
Change = Standard_True ;
}
- if (NbArg <= 0) {
- nbIsos = NbIsos ;
- di << "New current number of isos : " << nbIsos << "\n" ;
- } else {
- for (Standard_Integer IArg = 1 ; IArg <= NbArg ; IArg++) {
+ if (NbArg <= 0)
+ {
+ aParams.NbIsos = aNbIsos;
+ di << "New current number of isos : " << aParams.NbIsos << "\n";
+ }
+ else
+ {
+ for (Standard_Integer IArg = 1 ; IArg <= NbArg ; IArg++)
+ {
Handle (Draw_Drawable3D) Shape1 = Draw::Get (Arg[IArg]) ;
- if (!Shape1.IsNull()) {
- Handle (DBRep_DrawableShape) Shape2 =
- Handle (DBRep_DrawableShape)::DownCast (Shape1) ;
- if (!Shape2.IsNull()) {
- if (Change) {
- Shape2->ChangeNbIsos (NbIsos) ;
- } else {
- di << "Number of isos for " << Arg[IArg] << " : " << Shape2->NbIsos() << "\n";
- }
- }
+ if (!Shape1.IsNull())
+ {
+ Handle (DBRep_DrawableShape) Shape2 = Handle (DBRep_DrawableShape)::DownCast (Shape1);
+ if (!Shape2.IsNull())
+ {
+ if (Change)
+ {
+ Shape2->ChangeNbIsos (aNbIsos);
+ }
+ else
+ {
+ di << "Number of isos for " << Arg[IArg] << " : " << Shape2->NbIsos() << "\n";
+ }
+ }
}
}
if (Change) dout.RepaintAll() ;
// hlr
//=======================================================================
-static Standard_Integer hlr (Draw_Interpretor& di,
- Standard_Integer n, const char **a)
+static Standard_Integer hlr (Draw_Interpretor& di, Standard_Integer n, const char **a)
{
- if (n <= 1) {
- if (withHLR) {
+ DBRep_Params& aParams = DBRep::Parameters();
+ if (n <= 1)
+ {
+ if (aParams.WithHLR)
+ {
di << " HLR";
- if (withRgN) di << " RgNLines";
- else {
- if (withRg1) di << " Rg1Lines";
- else di << " no RegLines";
- }
- if (withHid) di << " HiddenLines";
- else di << " no HiddenLines";
+ di << (aParams.WithRgN
+ ? " RgNLines"
+ : (aParams.WithRg1 ? " Rg1Lines" : " no RegLines"));
+ di << (aParams.WithHid ? " HiddenLines" : " no HiddenLines");
di << "\n";
- if (withHLR) {
- di << "Angle of discretization : ";
- di << anglHLR * 180 / M_PI << " degrees\n";
+ if (aParams.WithHLR)
+ {
+ di << "Angle of discretization : ";
+ di << aParams.HLRAngle * 180 / M_PI << " degrees\n";
}
}
else di << " wireframe";
return 0 ;
}
- if (n == 2) {
- if (!strcasecmp(a[1],"nohlr")) withHLR = Standard_False;
- else if (!strcasecmp(a[1],"hlr" )) withHLR = Standard_True;
- else if (!strcasecmp(a[1],"nohid")) withHid = Standard_False;
- else if (!strcasecmp(a[1],"hid" )) {
- withHLR = Standard_True;
- withHid = Standard_True;
- }
- else if (!strcasecmp(a[1],"norg1")) {
- withRg1 = Standard_False;
- withRgN = Standard_False;
- }
- else if (!strcasecmp(a[1],"rg1" )) {
- withHLR = Standard_True;
- withRg1 = Standard_True;
- withRgN = Standard_False;
- }
- else if (!strcasecmp(a[1],"norgn")) {
- withRgN = Standard_False;
- }
- else if (!strcasecmp(a[1],"rgn" )) {
- withHLR = Standard_True;
- withRg1 = Standard_True;
- withRgN = Standard_True;
- }
- else if (!strcasecmp(a[1],"ang" )) {
+ if (n == 2)
+ {
+ if (!strcasecmp(a[1], "nohlr"))
+ {
+ aParams.WithHLR = Standard_False;
+ }
+ else if (!strcasecmp (a[1], "hlr"))
+ {
+ aParams.WithHLR = Standard_True;
+ }
+ else if (!strcasecmp (a[1], "nohid"))
+ {
+ aParams.WithHid = Standard_False;
+ }
+ else if (!strcasecmp(a[1], "hid"))
+ {
+ aParams.WithHLR = Standard_True;
+ aParams.WithHid = Standard_True;
+ }
+ else if (!strcasecmp(a[1], "norg1"))
+ {
+ aParams.WithRg1 = Standard_False;
+ aParams.WithRgN = Standard_False;
+ }
+ else if (!strcasecmp (a[1], "rg1"))
+ {
+ aParams.WithHLR = Standard_True;
+ aParams.WithRg1 = Standard_True;
+ aParams.WithRgN = Standard_False;
+ }
+ else if (!strcasecmp (a[1], "norgn"))
+ {
+ aParams.WithRgN = Standard_False;
+ }
+ else if (!strcasecmp (a[1], "rgn"))
+ {
+ aParams.WithHLR = Standard_True;
+ aParams.WithRg1 = Standard_True;
+ aParams.WithRgN = Standard_True;
+ }
+ else if (!strcasecmp (a[1], "ang"))
+ {
di << "Angle de discretisation : ";
- di << anglHLR * 180 / M_PI << " degres\n";
+ di << aParams.HLRAngle * 180 / M_PI << " degres\n";
}
else return 1;
}
Standard_Integer nFirst = 2;
- if (n >= 3 && !strcasecmp(a[1],"ang" )) {
+ if (n >= 3 && !strcasecmp (a[1], "ang"))
+ {
nFirst = 3;
- if (n == 3) {
+ if(n == 3)
+ {
Standard_Real ang = Draw::Atof(a[2]);
- anglHLR = ang * M_PI / 180;
- if (anglHLR < HAngMin) anglHLR = HAngMin;
- if (anglHLR > HAngMax) anglHLR = HAngMax;
- }
- di << "Angle of discretization : ";
- di << anglHLR * 180 / M_PI << " degrees\n";
- }
-
- if (n >= nFirst + 1) {
-
- for (Standard_Integer i = nFirst ; i < n; i++) {
- Handle (Draw_Drawable3D) D = Draw::Get (a[i]) ;
- if (!D.IsNull()) {
- Handle (DBRep_DrawableShape) S =
- Handle (DBRep_DrawableShape)::DownCast (D) ;
- if (!S.IsNull()) {
- Standard_Boolean localHLR, localRg1, localRgN, localHid;
- Standard_Real localAng;
- S->GetDisplayHLR(localHLR, localRg1, localRgN, localHid,
- localAng);
- if (!strcasecmp(a[1],"nohlr")) localHLR = Standard_False;
- else if (!strcasecmp(a[1],"hlr" )) localHLR = Standard_True;
- else if (!strcasecmp(a[1],"nohid")) localHid = Standard_False;
- else if (!strcasecmp(a[1],"hid" )) {
- localHLR = Standard_True;
- localHid = Standard_True;
- }
- else if (!strcasecmp(a[1],"norg1")) {
- localRg1 = Standard_False;
- localRgN = Standard_False;
- }
- else if (!strcasecmp(a[1],"rg1" )) {
- localHLR = Standard_True;
- localRg1 = Standard_True;
- localRgN = Standard_False;
- }
- else if (!strcasecmp(a[1],"norgn")) {
- localRgN = Standard_False;
- }
- else if (!strcasecmp(a[1],"rgn" )) {
- localHLR = Standard_True;
- localRg1 = Standard_True;
- localRgN = Standard_True;
- }
- else if (!strcasecmp(a[1],"ang" )) {
- Standard_Real ang = Draw::Atof(a[2]);
- localAng = ang * M_PI / 180;
- }
- else return 1;
- S->DisplayHLR(localHLR, localRg1, localRgN, localHid,
- localAng);
- }
+ aParams.HLRAngle = ang * M_PI / 180;
+ if(aParams.HLRAngle < aParams.HAngMin)
+ {
+ aParams.HLRAngle = aParams.HAngMin;
+ }
+ if (aParams.HLRAngle > aParams.HAngMax)
+ {
+ aParams.HLRAngle = aParams.HAngMax;
}
}
+ di << "Angle of discretization : ";
+ di << aParams.HLRAngle * 180 / M_PI << " degrees\n";
}
- dout.RepaintAll() ;
- return 0 ;
+ for (Standard_Integer i = nFirst; i < n; i++)
+ {
+ Handle(Draw_Drawable3D) D = Draw::Get (a[i]);
+ Handle(DBRep_DrawableShape) S = Handle(DBRep_DrawableShape)::DownCast (D);
+ if (S.IsNull())
+ {
+ continue;
+ }
+
+ bool localHLR = false, localRg1 = false, localRgN = false, localHid = false;
+ Standard_Real localAng = 0.0;
+ S->GetDisplayHLR(localHLR, localRg1, localRgN, localHid, localAng);
+ if (!strcasecmp (a[1], "nohlr"))
+ {
+ localHLR = Standard_False;
+ }
+ else if (!strcasecmp (a[1], "hlr"))
+ {
+ localHLR = Standard_True;
+ }
+ else if (!strcasecmp (a[1], "nohid"))
+ {
+ localHid = Standard_False;
+ }
+ else if (!strcasecmp (a[1], "hid"))
+ {
+ localHLR = Standard_True;
+ localHid = Standard_True;
+ }
+ else if (!strcasecmp (a[1], "norg1"))
+ {
+ localRg1 = Standard_False;
+ localRgN = Standard_False;
+ }
+ else if (!strcasecmp (a[1], "rg1"))
+ {
+ localHLR = Standard_True;
+ localRg1 = Standard_True;
+ localRgN = Standard_False;
+ }
+ else if (!strcasecmp (a[1], "norgn"))
+ {
+ localRgN = Standard_False;
+ }
+ else if (!strcasecmp (a[1], "rgn"))
+ {
+ localHLR = Standard_True;
+ localRg1 = Standard_True;
+ localRgN = Standard_True;
+ }
+ else if (!strcasecmp (a[1], "ang"))
+ {
+ Standard_Real ang = Draw::Atof (a[2]);
+ localAng = ang * M_PI / 180;
+ }
+ else
+ {
+ di << "Syntax error";
+ return 1;
+ }
+
+ S->DisplayHLR (localHLR, localRg1, localRgN, localHid, localAng);
+ }
+ dout.RepaintAll();
+ return 0;
}
// dispor, dispcon
//=======================================================================
-static Standard_Integer dispor (Draw_Interpretor& ,
- Standard_Integer n, const char** a)
+static Standard_Integer dispor (Draw_Interpretor&, Standard_Integer n, const char** a)
{
Standard_Boolean d = !strcasecmp(a[0],"vori");
-
if (d)
+ {
DBRep_WriteColorOrientation();
+ }
- Standard_Integer i;
- for (i = 1; i < n; i++) {
- Handle(Draw_Drawable3D) d1 = Draw::Get(a[i]);
- if (!d1.IsNull()) {
- Handle(DBRep_DrawableShape) d2 =
- Handle(DBRep_DrawableShape)::DownCast(d1);
- if (!d2.IsNull()) {
- d2->DisplayOrientation(d);
+ for (Standard_Integer i = 1; i < n; i++)
+ {
+ Handle(Draw_Drawable3D) d1 = Draw::Get (a[i]);
+ if (Handle(DBRep_DrawableShape) d2 = Handle(DBRep_DrawableShape)::DownCast(d1))
+ {
+ d2->DisplayOrientation (d);
Draw::Repaint();
- }
}
}
return 0;
// discretisation
//=======================================================================
-static Standard_Integer discretisation(Draw_Interpretor& di,
- Standard_Integer n, const char** a)
+static Standard_Integer discretisation(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
+ DBRep_Params& aParams = DBRep::Parameters();
if (n <= 1)
- di << "Current number of points : "<<discret<<"\n";
- else {
- discret = Draw::Atoi(a[1]);
+ {
+ di << "Current number of points : "<< aParams.Discretization <<"\n";
+ }
+ else
+ {
+ aParams.Discretization = Draw::Atoi(a[1]);
}
return 0;
}
// triangles
//=======================================================================
-static Standard_Integer triangles(Draw_Interpretor& ,
- Standard_Integer n, const char** a)
+static Standard_Integer triangles(Draw_Interpretor&, Standard_Integer n, const char** a)
{
- if (n < 1) return 1;
-
- if (n == 1) {
- disptriangles = !disptriangles;
-#ifdef OCCT_DEBUG
- if (disptriangles) std::cout <<"Triangulations are always displayed"<<std::endl;
- else std::cout <<"Triangulations are displayed only if there is no geometric representation"<<std::endl;
-#endif
+ DBRep_Params& aParams = DBRep::Parameters();
+ if (n < 1)
+ {
+ return 1;
}
- else {
- Standard_Integer i;
- for (i = 1; i <= n-1; i++) {
+ if(n == 1)
+ {
+ aParams.DispTriangles = !aParams.DispTriangles;
+ }
+ else
+ {
+ for (Standard_Integer i = 1; i <= n-1; i++)
+ {
Handle(Draw_Drawable3D) d1 = Draw::Get(a[i]);
- if (!d1.IsNull()) {
- Handle(DBRep_DrawableShape) d2 =
- Handle(DBRep_DrawableShape)::DownCast(d1);
- if (!d2.IsNull()) {
- d2->DisplayTriangulation(!(d2->DisplayTriangulation()));
- }
+ if (Handle(DBRep_DrawableShape) d2 = Handle(DBRep_DrawableShape)::DownCast(d1))
+ {
+ d2->DisplayTriangulation(!(d2->DisplayTriangulation()));
}
}
}
// polygons
//=======================================================================
-static Standard_Integer polygons(Draw_Interpretor& ,
- Standard_Integer n, const char** a)
+static Standard_Integer polygons(Draw_Interpretor&, Standard_Integer n, const char** a)
{
- if (n < 1) return 1;
-
- if (n == 1) {
- disppolygons = !disppolygons;
-#ifdef OCCT_DEBUG
- if (disppolygons) std::cout <<"Polygons are always displayed"<<std::endl;
- else std::cout <<"Polygons are displayed only if there is no geometric representation"<<std::endl;
-#endif
+ DBRep_Params& aParams = DBRep::Parameters();
+ if (n < 1)
+ {
+ return 1;
}
- else {
- Standard_Integer i;
- for (i = 1; i <= n-1; i++) {
+ if (n == 1)
+ {
+ aParams.DisplayPolygons = !aParams.DisplayPolygons;
+ }
+ else
+ {
+ for (Standard_Integer i = 1; i <= n-1; i++)
+ {
Handle(Draw_Drawable3D) d1 = Draw::Get(a[i]);
- if (!d1.IsNull()) {
- Handle(DBRep_DrawableShape) d2 =
- Handle(DBRep_DrawableShape)::DownCast(d1);
- if (!d2.IsNull()) {
- d2->DisplayPolygons(!(d2->DisplayPolygons()));
- }
+ if (Handle(DBRep_DrawableShape) d2 = Handle(DBRep_DrawableShape)::DownCast(d1))
+ {
+ d2->DisplayPolygons(!(d2->DisplayPolygons()));
}
}
}
-
Draw::Repaint();
return 0;
}
//function : Set
//purpose :
//=======================================================================
-void DBRep::Set(const Standard_CString Name, const TopoDS_Shape& S)
+void DBRep::Set (const Standard_CString theName, const TopoDS_Shape& theShape)
{
- Handle(DBRep_DrawableShape) D =
- new DBRep_DrawableShape(S,
- Draw_vert,
- Draw_jaune,
- Draw_rouge,
- Draw_bleu,
- size,
- nbIsos,
- discret);
- D->DisplayTriangulation(disptriangles);
- D->DisplayPolygons(disppolygons);
- D->DisplayHLR(withHLR,withRg1,withRgN,withHid,anglHLR);
- Draw::Set(Name,D);
+ DBRep_Params& aParams = DBRep::Parameters();
+ Handle(DBRep_DrawableShape) aDrawShape =
+ new DBRep_DrawableShape (theShape, Draw_vert, Draw_jaune, Draw_rouge, Draw_bleu,
+ aParams.Size, aParams.NbIsos, aParams.Discretization);
+ aDrawShape->DisplayTriangulation (aParams.DispTriangles);
+ aDrawShape->DisplayPolygons (aParams.DisplayPolygons);
+ aDrawShape->DisplayHLR (aParams.WithHLR, aParams.WithRg1, aParams.WithRgN, aParams.WithHid, aParams.HLRAngle);
+ Draw::Set (theName, aDrawShape);
}
//=======================================================================
//function : getShape
done = Standard_True;
Draw::Commands(theCommands);
+ // Register save/restore tools
+ DBRep_DrawableShape::RegisterFactory();
+
const char* g = "Basic shape commands";
theCommands.Add("isos","isos [name1 ...] [nbisos]",__FILE__,isos,g);
"removes all internal sub-shapes\n",
__FILE__, removeInternals, g);
}
-
-//=======================================================================
-//function : HLRMode
-//purpose :
-//=======================================================================
-
-Standard_Boolean DBRep::HLRMode()
-{ return withHLR; }
-
-//=======================================================================
-//function : Rg1Mode
-//purpose :
-//=======================================================================
-
-Standard_Boolean DBRep::Rg1Mode()
-{ return withRg1; }
-
-//=======================================================================
-//function : RgNMode
-//purpose :
-//=======================================================================
-
-Standard_Boolean DBRep::RgNMode()
-{ return withRgN; }
-
-//=======================================================================
-//function : HidMode
-//purpose :
-//=======================================================================
-
-Standard_Boolean DBRep::HidMode()
-{ return withHid; }
-
-//=======================================================================
-//function : HLRAngle
-//purpose :
-//=======================================================================
-
-Standard_Real DBRep::HLRAngle()
-{ return anglHLR; }
-
-//=======================================================================
-//function :
-//purpose : save and restore shapes
-//=======================================================================
-
-static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DBRep_DrawableShape));
-}
-
-static void ssave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DBRep_DrawableShape)
- N = Handle(DBRep_DrawableShape)::DownCast(d);
- BRep_Builder B;
- BRepTools_ShapeSet S(B);
- S.Add (N->Shape());
- Handle(Draw_ProgressIndicator) aProgress = Draw::GetProgressBar();
- S.Write(OS, Message_ProgressIndicator::Start(aProgress));
- if (! aProgress.IsNull() && aProgress->UserBreak())
- return;
- S.Write(N->Shape(),OS);
-}
-
-static Handle(Draw_Drawable3D) srestore (std::istream& IS)
-{
- BRep_Builder B;
- BRepTools_ShapeSet S(B);
- Handle(Draw_ProgressIndicator) aProgress = Draw::GetProgressBar();
- S.Read(IS, Message_ProgressIndicator::Start(aProgress));
- Handle(DBRep_DrawableShape) N;
- if (! aProgress.IsNull() && aProgress->UserBreak())
- return N;
- TopoDS_Shape theShape;
- S.Read(theShape,IS );
- N = new DBRep_DrawableShape(theShape,
- Draw_vert,
- Draw_jaune,
- Draw_rouge,
- Draw_bleu,
- size,
- nbIsos,
- discret);
- N->DisplayTriangulation(disptriangles);
- N->DisplayPolygons(disppolygons);
- N->DisplayHLR(withHLR,withRg1,withRgN,withHid,anglHLR);
-
- return N;
-}
-
-
-static Draw_SaveAndRestore ssr("DBRep_DrawableShape",
- stest,ssave,srestore);
-
-
-void dumps (const TopoDS_Shape& S)
-{
- BRepTools::Dump(S,std::cout);
-}
-
-//=======================================================================
-//function : NbIsos
-//purpose :
-//=======================================================================
-
-Standard_Integer DBRep::NbIsos()
-{ return nbIsos; }
-
-
-//=======================================================================
-//function : Discretisation
-//purpose :
-//=======================================================================
-
-Standard_Integer DBRep::Discretisation()
-{ return discret; }
#ifndef _DBRep_HeaderFile
#define _DBRep_HeaderFile
+#include <DBRep_Params.hxx>
#include <Draw_Interpretor.hxx>
#include <TCollection_AsciiString.hxx>
-#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Shape.hxx>
//! Used to display BRep objects using the DrawTrSurf
//! Defines the basic commands.
Standard_EXPORT static void BasicCommands (Draw_Interpretor& theCommands);
-
+
+ //! Return global parameters.
+ Standard_EXPORT static DBRep_Params& Parameters();
+
//! True if HLR, False if wireframe.
- Standard_EXPORT static Standard_Boolean HLRMode();
-
+ static Standard_Boolean HLRMode() { return Parameters().WithHLR; }
+
//! True if display Rg1Lines.
- Standard_EXPORT static Standard_Boolean Rg1Mode();
-
+ static Standard_Boolean Rg1Mode() { return Parameters().WithRg1; }
+
//! True if display RgNLines.
- Standard_EXPORT static Standard_Boolean RgNMode();
-
+ static Standard_Boolean RgNMode() { return Parameters().WithRgN; }
+
//! True if display HiddenLines.
- Standard_EXPORT static Standard_Boolean HidMode();
-
+ static Standard_Boolean HidMode() { return Parameters().WithHid; }
+
//! discretisation angle for edges.
- Standard_EXPORT static Standard_Real HLRAngle();
-
+ static Standard_Real HLRAngle() { return Parameters().HLRAngle; }
+
//! number of iso in U and V
- Standard_EXPORT static Standard_Integer NbIsos();
-
- //! discretisation number of points for curves
- //! set progress indicator
- //! get progress indicator
- Standard_EXPORT static Standard_Integer Discretisation();
+ static Standard_Integer NbIsos() { return Parameters().NbIsos; }
+
+ //! Discretization number of points for curves
+ static Standard_Integer Discretisation() { return Parameters().Discretization; }
protected:
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DBRep_DrawableShape.hxx>
#include <Adaptor3d_Curve.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRepTools.hxx>
-#include <DBRep_DrawableShape.hxx>
+#include <BRepTools_ShapeSet.hxx>
+#include <DBRep.hxx>
#include <DBRep_Edge.hxx>
#include <DBRep_Face.hxx>
#include <DBRep_HideData.hxx>
#include <Draw_Appli.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
+#include <Draw_ProgressIndicator.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_BSplineSurface.hxx>
#include <GeomAdaptor_Surface.hxx>
-#include <GeomAdaptor_Surface.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Trsf.hxx>
+#include <Message_ProgressIndicator.hxx>
#include <HLRBRep.hxx>
#include <Poly_Connect.hxx>
#include <Poly_Polygon3D.hxx>
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-
-void DBRep_DrawableShape::Dump(Standard_OStream& S)const
+void DBRep_DrawableShape::Dump (Standard_OStream& S) const
{
BRepTools::Dump(myShape,S);
}
+//=======================================================================
+//function : Save
+//purpose :
+//=======================================================================
+void DBRep_DrawableShape::Save (Standard_OStream& theStream) const
+{
+ BRep_Builder aBuilder;
+ BRepTools_ShapeSet aShapeSet (aBuilder);
+ aShapeSet.Add (myShape);
+ Handle(Draw_ProgressIndicator) aProgress = Draw::GetProgressBar();
+ aShapeSet.Write (theStream, Message_ProgressIndicator::Start (aProgress));
+ if (aProgress.IsNull() || !aProgress->UserBreak())
+ {
+ aShapeSet.Write (myShape, theStream);
+ }
+}
//=======================================================================
-//function : Whatis
-//purpose :
+//function : Restore
+//purpose :
//=======================================================================
+Handle(Draw_Drawable3D) DBRep_DrawableShape::Restore (Standard_IStream& theStream)
+{
+ const DBRep_Params& aParams = DBRep::Parameters();
+ BRep_Builder aBuilder;
+ BRepTools_ShapeSet aShapeSet (aBuilder);
+ Handle(Draw_ProgressIndicator) aProgress = Draw::GetProgressBar();
+ aShapeSet.Read (theStream, Message_ProgressIndicator::Start(aProgress));
+ if (!aProgress.IsNull() && aProgress->UserBreak())
+ {
+ return Handle(Draw_Drawable3D)();
+ }
-void DBRep_DrawableShape::Whatis(Draw_Interpretor& s)const
+ TopoDS_Shape aTopoShape;
+ aShapeSet.Read (aTopoShape, theStream);
+ Handle(DBRep_DrawableShape) aDrawShape = new DBRep_DrawableShape (aTopoShape,
+ Draw_vert, Draw_jaune, Draw_rouge, Draw_bleu,
+ aParams.Size, aParams.NbIsos, aParams.Discretization);
+ aDrawShape->DisplayTriangulation (aParams.DispTriangles);
+ aDrawShape->DisplayPolygons (aParams.DisplayPolygons);
+ aDrawShape->DisplayHLR (aParams.WithHLR, aParams.WithRg1, aParams.WithRgN, aParams.WithHid, aParams.HLRAngle);
+ return aDrawShape;
+}
+
+//=======================================================================
+//function : Whatis
+//purpose :
+//=======================================================================
+void DBRep_DrawableShape::Whatis (Draw_Interpretor& s) const
{
if (myShape.IsNull())
{
class DBRep_DrawableShape : public Draw_Drawable3D
{
DEFINE_STANDARD_RTTIEXT(DBRep_DrawableShape, Draw_Drawable3D)
+ Draw_Drawable3D_FACTORY
public:
-
+
Standard_EXPORT DBRep_DrawableShape(const TopoDS_Shape& C, const Draw_Color& FreeCol, const Draw_Color& ConnCol, const Draw_Color& EdgeCol, const Draw_Color& IsosCol, const Standard_Real size, const Standard_Integer nbisos, const Standard_Integer discret);
//! Changes the number of isoparametric curves in a shape.
//! For variable dump.
Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-
+
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
+
//! For variable whatis command.
Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
--- /dev/null
+// Copyright (c) 2021 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef Draw_Params_HeaderFile
+#define Draw_Params_HeaderFile
+
+#include <Standard_Real.hxx>
+
+//! DBRep parameters.
+struct DBRep_Params
+{
+public:
+ Standard_Integer NbIsos; //!< number of iso in U and V
+ Standard_Real Size;
+ Standard_Integer Discretization; //!< Discretization number of points for curves
+ Standard_Boolean DispTriangles;
+ Standard_Boolean DisplayPolygons;
+ Standard_Real HLRAngle; //!< Discretization angle for edges
+ Standard_Real HAngMin;
+ Standard_Real HAngMax;
+ Standard_Boolean WithHLR; //!< True if HLR, False if wireframe
+ Standard_Boolean WithRg1; //!< True if display Rg1Lines
+ Standard_Boolean WithRgN; //!< True if display RgNLines
+ Standard_Boolean WithHid; //!< True if display HiddenLines
+
+ DBRep_Params()
+ : NbIsos (2),
+ Size (100.0),
+ Discretization (30),
+ DispTriangles(false),
+ DisplayPolygons (false),
+ HLRAngle(35.0 * M_PI / 180.0),
+ HAngMin ( 1.0 * M_PI / 180.0),
+ HAngMax (35.0 * M_PI / 180.0),
+ WithHLR (false),
+ WithRg1 (true),
+ WithRgN (false),
+ WithHid (false)
+ {}
+};
+
+#endif
DBRep_ListOfEdge.hxx
DBRep_ListOfFace.hxx
DBRep_ListOfHideData.hxx
+DBRep_Params.hxx
extern Standard_Boolean Draw_Batch;
#endif
-class Draw_SaveAndRestore {
- public :
- Standard_EXPORT Draw_SaveAndRestore
- (const char* name,
- Standard_Boolean (*test)(const Handle(Draw_Drawable3D)&),
- void (*save)(const Handle(Draw_Drawable3D)&, std::ostream&),
- Handle(Draw_Drawable3D) (*restore) (std::istream&),
- Standard_Boolean display = Standard_True);
-
-
- const char* Name() const {return myName;}
- Standard_Boolean Test(const Handle(Draw_Drawable3D)&d);
- void Save(const Handle(Draw_Drawable3D)& d, std::ostream& os) const;
- Handle(Draw_Drawable3D) Restore(std::istream&) const;
- Standard_Boolean Disp() const {return myDisplay;}
- Draw_SaveAndRestore* Next() {return myNext;}
-
- private :
-
- const char* myName;
- Standard_Boolean (*myTest)(const Handle(Draw_Drawable3D)&);
- void (*mySave)(const Handle(Draw_Drawable3D)&, std::ostream&);
- Handle(Draw_Drawable3D) (*myRestore) (std::istream&);
- Standard_Boolean myDisplay;
- Draw_SaveAndRestore* myNext;
-
-};
#endif
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <Draw_Drawable3D.hxx>
+#include <NCollection_DataMap.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
-#include <Standard_Type.hxx>
+#include <Standard_NotImplemented.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(Draw_Drawable3D, Standard_Transient)
+
+//! Return the map of factory functions.
+static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t>& getFactoryMap()
+{
+ static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t> myToolMap;
+ return myToolMap;
+}
+
+//=======================================================================
+//function : RegisterFactory
+//purpose :
+//=======================================================================
+void Draw_Drawable3D::RegisterFactory (const Standard_CString theType,
+ const FactoryFunction_t& theFactory)
+{
+ getFactoryMap().Bind (theType, theFactory);
+}
-IMPLEMENT_STANDARD_RTTIEXT(Draw_Drawable3D,Standard_Transient)
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) Draw_Drawable3D::Restore (const Standard_CString theType,
+ Standard_IStream& theStream)
+{
+ FactoryFunction_t aFactory = NULL;
+ if (getFactoryMap().Find (theType, aFactory))
+ {
+ return aFactory (theStream);
+ }
+ return Handle(Draw_Drawable3D)();
+}
//=======================================================================
//function : Draw_Drawable3D
-//purpose :
+//purpose :
//=======================================================================
-Draw_Drawable3D::Draw_Drawable3D() :
- myXmin(0.0),
+Draw_Drawable3D::Draw_Drawable3D()
+: myXmin(0.0),
myXmax(0.0),
myYmin(0.0),
myYmax(0.0),
+ myName(NULL),
isVisible(Standard_False),
- isProtected(Standard_False),
- myName(NULL)
+ isProtected(Standard_False)
{
}
//=======================================================================
//function : PickReject
-//purpose :
+//purpose :
//=======================================================================
-
Standard_Boolean Draw_Drawable3D::PickReject(const Standard_Real X,
const Standard_Real Y,
const Standard_Real Prec) const
return ((X+Prec < myXmin) || (X-Prec > myXmax) ||
(Y+Prec < myYmin) || (Y-Prec > myYmax));
}
-
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) Draw_Drawable3D::Copy() const
+Handle(Draw_Drawable3D) Draw_Drawable3D::Copy() const
{
return this;
}
-
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-
-void Draw_Drawable3D::Dump(Standard_OStream& S) const
+void Draw_Drawable3D::Dump (Standard_OStream& S) const
{
S << myXmin << " " << myXmax << "\n";
S << myYmin << " " << myYmax << "\n";
}
-
//=======================================================================
-//function : Whatis
-//purpose :
+//function : Save
+//purpose :
//=======================================================================
-
-void Draw_Drawable3D::Whatis(Draw_Interpretor& S) const
+void Draw_Drawable3D::Save (Standard_OStream& ) const
{
- S << "drawable 3d";
+ throw Standard_NotImplemented ("Draw_Drawable3D::Save() should be redefined in sub-class");
}
//=======================================================================
-//function : Is3D
-//purpose :
-//=======================================================================
-
-Standard_Boolean Draw_Drawable3D::Is3D() const
-{
- return Standard_True;
-}
-
-//=======================================================================
-//function : SetBounds
-//purpose :
-//=======================================================================
-
-void Draw_Drawable3D::SetBounds(const Standard_Real xmin,
- const Standard_Real xmax,
- const Standard_Real ymin,
- const Standard_Real ymax)
-{
- myXmin = xmin;
- myXmax = xmax;
- myYmin = ymin;
- myYmax = ymax;
-}
-
-
-//=======================================================================
-//function : Bounds
-//purpose :
+//function : Whatis
+//purpose :
//=======================================================================
-
-void Draw_Drawable3D::Bounds(Standard_Real& xmin,
- Standard_Real& xmax,
- Standard_Real& ymin,
- Standard_Real& ymax) const
+void Draw_Drawable3D::Whatis(Draw_Interpretor& S) const
{
- xmin = myXmin;
- xmax = myXmax;
- ymin = myYmin;
- ymax = myYmax;
+ S << "drawable 3d";
}
-
-
#ifndef _Draw_Drawable3D_HeaderFile
#define _Draw_Drawable3D_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Real.hxx>
-#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
+#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
+#include <Standard_IStream.hxx>
#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
-class Draw_Display;
+class Draw_Display;
-class Draw_Drawable3D;
DEFINE_STANDARD_HANDLE(Draw_Drawable3D, Standard_Transient)
-
class Draw_Drawable3D : public Standard_Transient
{
+ DEFINE_STANDARD_RTTIEXT(Draw_Drawable3D, Standard_Transient)
+public:
+
+ //! Function type for restoring drawable from stream.
+ typedef Handle(Draw_Drawable3D)(*FactoryFunction_t)(Standard_IStream& theStream);
+
+ //! Register factory for restoring drawable from stream (opposite to Draw_Drawable3D::Save()).
+ //! @param theType [in] class name
+ //! @param theFactory [in] factory function
+ Standard_EXPORT static void RegisterFactory (const Standard_CString theType,
+ const FactoryFunction_t& theFactory);
+
+ //! Restore drawable from stream (opposite to Draw_Drawable3D::Save()).
+ //! @param theType [in] class name
+ //! @param theStream [in] input stream
+ //! @return restored drawable or NULL if factory is undefined for specified class
+ Standard_EXPORT static Handle(Draw_Drawable3D) Restore (const Standard_CString theType,
+ Standard_IStream& theStream);
+
+ //! @def Draw_Drawable3D_FACTORY
+ //! Auxiliary macros defining Draw_Drawable3D restoration API to sub-class.
+ #define Draw_Drawable3D_FACTORY \
+ static void RegisterFactory() { Draw_Drawable3D::RegisterFactory (get_type_name(), &Restore); } \
+ Standard_EXPORT static Handle(Draw_Drawable3D) Restore (Standard_IStream& theStream);
public:
-
Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const = 0;
//! Returns True if the pick is outside the box
//! For variable dump.
Standard_EXPORT virtual void Dump (Standard_OStream& S) const;
-
- //! For variable whatis command. Set as a result the
- //! type of the variable.
+
+ //! Save drawable into stream; default implementation raises Standard_NotImplemented exception.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const;
+
+ //! For variable whatis command. Set as a result the type of the variable.
Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const;
//! Is a 3D object. (Default True).
- Standard_EXPORT virtual Standard_Boolean Is3D() const;
-
- Standard_EXPORT void SetBounds (const Standard_Real xmin, const Standard_Real xmax, const Standard_Real ymin, const Standard_Real ymax);
-
- Standard_EXPORT void Bounds (Standard_Real& xmin, Standard_Real& xmax, Standard_Real& ymin, Standard_Real& ymax) const;
-
- Standard_Boolean Visible() const;
-
- void Visible (const Standard_Boolean V);
-
- Standard_Boolean Protected() const;
-
- void Protected (const Standard_Boolean P);
-
- Standard_CString Name() const;
-
- virtual void Name (const Standard_CString N);
+ virtual bool Is3D() const { return true; }
+ //! Return TRUE if object can be displayed.
+ virtual bool IsDisplayable() const { return true; }
+ void SetBounds (const Standard_Real theXMin, const Standard_Real theXMax,
+ const Standard_Real theYMin, const Standard_Real theYMax)
+ {
+ myXmin = theXMin;
+ myXmax = theXMax;
+ myYmin = theYMin;
+ myYmax = theYMax;
+ }
+ void Bounds (Standard_Real& theXMin, Standard_Real& theXMax,
+ Standard_Real& theYMin, Standard_Real& theYMax) const
+ {
+ theXMin = myXmin;
+ theXMax = myXmax;
+ theYMin = myYmin;
+ theYMax = myYmax;
+ }
- DEFINE_STANDARD_RTTIEXT(Draw_Drawable3D,Standard_Transient)
+ Standard_Boolean Visible() const { return isVisible; }
-protected:
+ void Visible (const Standard_Boolean V) { isVisible = V; }
-
- Standard_EXPORT Draw_Drawable3D();
+ Standard_Boolean Protected() const { return isProtected; }
+ void Protected (const Standard_Boolean P) { isProtected = P; }
+ Standard_CString Name() const { return myName; }
-private:
+ virtual void Name (const Standard_CString N) { myName = N; }
+
+protected:
+
+ Standard_EXPORT Draw_Drawable3D();
+private:
Standard_Real myXmin;
Standard_Real myXmax;
Standard_Real myYmin;
Standard_Real myYmax;
+ Standard_CString myName;
Standard_Boolean isVisible;
Standard_Boolean isProtected;
- Standard_CString myName;
-
};
-
-#include <Draw_Drawable3D.lxx>
-
-
-
-
-
#endif // _Draw_Drawable3D_HeaderFile
+++ /dev/null
-// Created on: 1995-02-28
-// Created by: Remi LEQUETTE
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline Standard_Boolean Draw_Drawable3D::Visible() const
-{
- return isVisible;
-}
-
-inline void Draw_Drawable3D::Visible(const Standard_Boolean V)
-{
- isVisible = V;
-}
-
-inline Standard_Boolean Draw_Drawable3D::Protected() const
-{
- return isProtected;
-}
-
-inline void Draw_Drawable3D::Protected(const Standard_Boolean V)
-{
- isProtected = V;
-}
-
-inline Standard_CString Draw_Drawable3D::Name() const
-{
- return myName;
-}
-
-inline void Draw_Drawable3D::Name(const Standard_CString N)
-{
- myName = N;
-}
-
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <Draw_Number.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
-#include <Draw_Number.hxx>
-#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Draw_Number,Draw_Drawable3D)
//=======================================================================
//function : Draw_Number
-//purpose :
+//purpose :
//=======================================================================
-Draw_Number::Draw_Number(const Standard_Real V) :
- myValue(V)
+Draw_Number::Draw_Number (const Standard_Real theV)
+: myValue (theV)
{
+ //
}
-
//=======================================================================
-//function : Value
-//purpose :
+//function : DrawOn
+//purpose :
//=======================================================================
-
-Standard_Real Draw_Number::Value()const
+void Draw_Number::DrawOn (Draw_Display& ) const
{
- return myValue;
+ //
}
-
//=======================================================================
-//function : Value
-//purpose :
+//function : Copy
+//purpose :
//=======================================================================
-
-void Draw_Number::Value(const Standard_Real V)
+Handle(Draw_Drawable3D) Draw_Number::Copy() const
{
- myValue = V;
+ Handle(Draw_Number) D = new Draw_Number (myValue);
+ return D;
}
-
//=======================================================================
-//function : DrawOn
-//purpose :
+//function : Dump
+//purpose :
//=======================================================================
-
-void Draw_Number::DrawOn(Draw_Display&)const
+void Draw_Number::Dump (Standard_OStream& S) const
{
+ S << myValue;
}
-
//=======================================================================
-//function : Copy
-//purpose :
+//function : Save
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) Draw_Number::Copy()const
+void Draw_Number::Save (Standard_OStream& theStream) const
{
- Handle(Draw_Number) D = new Draw_Number(myValue);
- return D;
+ std::ios::fmtflags aFlags = theStream.flags();
+ theStream.setf (std::ios::scientific);
+ theStream.precision (15);
+ theStream.width (30);
+ theStream << myValue << "\n";
+ theStream.setf (aFlags);
}
-
//=======================================================================
-//function : Dump
-//purpose :
+//function : Restore
+//purpose :
//=======================================================================
-
-void Draw_Number::Dump(Standard_OStream& S)const
+Handle(Draw_Drawable3D) Draw_Number::Restore (Standard_IStream& theStream)
{
- S << myValue;
+ Standard_Real aVal = RealLast();
+ theStream >> aVal;
+ Handle(Draw_Number) aNumb = new Draw_Number (aVal);
+ return aNumb;
}
-
//=======================================================================
//function : Whatis
-//purpose :
+//purpose :
//=======================================================================
-
-void Draw_Number::Whatis(Draw_Interpretor& S)const
+void Draw_Number::Whatis (Draw_Interpretor& S) const
{
S << "numeric";
}
#ifndef _Draw_Number_HeaderFile
#define _Draw_Number_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Real.hxx>
#include <Draw_Drawable3D.hxx>
-#include <Standard_OStream.hxx>
-#include <Draw_Interpretor.hxx>
-class Draw_Display;
-class Draw_Drawable3D;
-
-class Draw_Number;
DEFINE_STANDARD_HANDLE(Draw_Number, Draw_Drawable3D)
//! To store numbers in variables.
class Draw_Number : public Draw_Drawable3D
{
-
+ DEFINE_STANDARD_RTTIEXT(Draw_Number, Draw_Drawable3D)
+ Draw_Drawable3D_FACTORY
public:
+ Standard_EXPORT Draw_Number (const Standard_Real theV);
+
+ Standard_Real Value() const { return myValue; }
+
+ void Value (const Standard_Real theV) { myValue = theV; }
- Standard_EXPORT Draw_Number(const Standard_Real V);
-
- Standard_EXPORT Standard_Real Value() const;
-
- Standard_EXPORT void Value (const Standard_Real V);
-
- //! Does nothhing,
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
+ //! Does nothing,
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+
+ //! Returns TRUE if object can be displayed.
+ virtual bool IsDisplayable() const Standard_OVERRIDE { return false; }
+
//! For variable copy.
Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
//! For variable dump.
Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-
- //! For variable whatis command. Set as a result the
- //! type of the variable.
- Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
-
-
-
-
- DEFINE_STANDARD_RTTIEXT(Draw_Number,Draw_Drawable3D)
-
-protected:
-
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
+ //! For variable whatis command. Set as a result the type of the variable.
+ Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
private:
-
Standard_Real myValue;
-
};
-
-
-
-
-
-
#endif // _Draw_Number_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <Draw_Axis2D.hxx>
#include <Draw_Drawable3D.hxx>
#include <Draw_Grid.hxx>
#include <Draw_Number.hxx>
-#include <Message.hxx>
#include <Draw_ProgressIndicator.hxx>
#include <Draw_SequenceOfDrawable3D.hxx>
#include <Message.hxx>
#include <NCollection_Map.hxx>
#include <Standard_SStream.hxx>
#include <Standard_Stream.hxx>
+#include <Standard_NotImplemented.hxx>
#include <TCollection_AsciiString.hxx>
#include <ios>
static Standard_Integer p_b;
static const char* p_Name = "";
-
-static Draw_SaveAndRestore* Draw_First = NULL;
-
-//=======================================================================
-//function : Draw_SaveAndRestore
-//purpose :
-//=======================================================================
-
-Draw_SaveAndRestore::Draw_SaveAndRestore
- (const char* name,
- Standard_Boolean (*test)(const Handle(Draw_Drawable3D)&),
- void (*save)(const Handle(Draw_Drawable3D)&, std::ostream&),
- Handle(Draw_Drawable3D) (*restore) (std::istream&),
- Standard_Boolean display) :
- myName(name),
- myTest(test),
- mySave(save),
- myRestore(restore),
- myDisplay(display),
- myNext(Draw_First)
-{
- Draw_First = this;
-}
-
-Standard_Boolean Draw_SaveAndRestore::Test(const Handle(Draw_Drawable3D)&d)
-{return (*myTest) (d);}
-
-void Draw_SaveAndRestore::Save(const Handle(Draw_Drawable3D)& d,
- std::ostream& os) const
-{ (*mySave) (d,os);}
-
-Handle(Draw_Drawable3D) Draw_SaveAndRestore::Restore(std::istream& is) const
-{return (*myRestore) (is);}
-
-//=======================================================================
-// numeric save and restore
-//=======================================================================
-
-static Standard_Boolean numtest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(Draw_Number));
-}
-
-static void numsave (const Handle(Draw_Drawable3D)& theDrawable,
- std::ostream& theStream)
-{
- Handle(Draw_Number) aNum = Handle(Draw_Number)::DownCast (theDrawable);
- std::ios::fmtflags aFlags = theStream.flags();
- theStream.setf (std::ios::scientific);
- theStream.precision (15);
- theStream.width (30);
- theStream << aNum->Value() << "\n";
- theStream.setf (aFlags);
-}
-
-static Handle(Draw_Drawable3D) numrestore (std::istream& is)
-{
- Standard_Real val;
- is >> val;
- Handle(Draw_Number) N = new Draw_Number(val);
- return N;
-}
-
-
-static Draw_SaveAndRestore numsr("Draw_Number",
- numtest,numsave,numrestore,
- Standard_False);
-
//=======================================================================
// save
//=======================================================================
-
-static Standard_Integer save(Draw_Interpretor& di, Standard_Integer n, const char** a)
+static Standard_Integer save (Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (n < 3)
+ if (theNbArgs != 3)
{
- di << "Syntax error: wrong number of arguments!\n";
- di.PrintHelp(a[0]);
+ theDI << "Syntax error: wrong number of arguments!\n";
+ theDI.PrintHelp (theArgVec[0]);
return 1;
}
- const char* name = a[2];
- std::ofstream os;
- os.precision(15);
- OSD_OpenStream(os, name, std::ios::out);
- if (!os.is_open() || !os.good())
+ Handle(Draw_Drawable3D) aDrawable = Draw::Get (theArgVec[1]);
+ if (aDrawable.IsNull())
{
- di << "Cannot open file for writing "<<name;
+ theDI << "Syntax error: '" << theArgVec[1] << "' is not a drawable";
return 1;
}
- Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
- if (!D.IsNull()) {
- // find a tool
- Draw_SaveAndRestore* tool = Draw_First;
- Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
-
- while (tool) {
- if (tool->Test(D)) break;
- tool = tool->Next();
- }
- if (tool) {
- os << tool->Name() << "\n";
- Draw::SetProgressBar(progress);
- tool->Save(D,os);
- os << "\n";
- }
- else {
- di << "No method for saving " << a[1];
- return 1;
- }
- Draw::SetProgressBar( 0 );
+ const char* aName = theArgVec[2];
+ std::ofstream aStream;
+ aStream.precision (15);
+ OSD_OpenStream (aStream, aName, std::ios::out);
+ if (!aStream.is_open() || !aStream.good())
+ {
+ theDI << "Error: cannot open file for writing " << aName;
+ return 1;
}
-
- os << "0\n\n";
- Standard_Boolean res = Standard_False;
+ try
+ {
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
+ Standard_CString aToolTypeName = aDrawable->DynamicType()->Name();
+ aStream << aToolTypeName << "\n";
+ Draw::SetProgressBar (aProgress);
+ aDrawable->Save (aStream);
+ }
+ catch (const Standard_NotImplemented& )
+ {
+ theDI << "Error: no method for saving " << theArgVec[1];
+ return 1;
+ }
+ aStream << "\n";
+ aStream << "0\n\n";
+ Draw::SetProgressBar (Handle(Draw_ProgressIndicator)());
errno = 0;
-
- res = os.good() && !errno;
- if( !res )
+ const Standard_Boolean aRes = aStream.good() && !errno;
+ if (!aRes)
{
- di<<"File has not been written";
+ theDI << "Error: file has not been written";
return 1;
}
- di << a[1];
+ theDI << theArgVec[1];
return 0;
}
//=======================================================================
// read
//=======================================================================
-
-static Standard_Integer restore(Draw_Interpretor& di, Standard_Integer n, const char** a)
+static Standard_Integer restore (Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
+ if (theNbArgs != 3)
+ {
+ return 1;
+ }
- if (n <= 2) return 1;
-
- const char* fname = a[1];
- const char* name = a[2];
+ const char* aFileName = theArgVec[1];
+ const char* aVarName = theArgVec[2];
- std::filebuf fic;
- std::istream in(&fic);
- OSD_OpenStream (fic, fname, std::ios::in);
- if (!fic.is_open()) {
- di << "Cannot open file for reading : "<<fname;
+ std::filebuf aFileBuf;
+ std::istream aStream (&aFileBuf);
+ OSD_OpenStream (aFileBuf, aFileName, std::ios::in);
+ if (!aFileBuf.is_open())
+ {
+ theDI << "Error: cannot open file for reading: '" << aFileName << "'";
return 1;
}
-
- char typ[255];
- in >> typ;
- if (!in.fail()) {
- // search a tool
- Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
- Draw::SetProgressBar(progress);
-
- Draw_SaveAndRestore* tool = Draw_First;
- Draw_SaveAndRestore* aDBRepTool = NULL;
- while (tool) {
- const char* toolName = tool->Name();
- if (!strcmp(typ,toolName)) break;
- if (!strcmp("DBRep_DrawableShape",toolName))
- aDBRepTool = tool;
- tool = tool->Next();
- }
- if (!tool)
- {
- //assume that this file stores a DBRep_DrawableShape variable
- tool = aDBRepTool;
- in.seekg(0, std::ios::beg);
- }
+ char aType[255] = {};
+ aStream >> aType;
+ if (aStream.fail())
+ {
+ theDI << "Error: cannot read file: '" << aFileName << "'";
+ return 1;
+ }
- if (tool)
+ {
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
+ Draw::SetProgressBar (aProgress);
+ Handle(Draw_Drawable3D) aDrawable = Draw_Drawable3D::Restore (aType, aStream);
+ if (aDrawable.IsNull())
{
- Handle(Draw_Drawable3D) D = tool->Restore(in);
- Draw::Set(name,D,tool->Disp() && autodisp);
+ // assume that this file stores a DBRep_DrawableShape variable
+ aStream.seekg (0, std::ios::beg);
+ aDrawable = Draw_Drawable3D::Restore ("DBRep_DrawableShape", aStream);
}
-
- else {
- di << "Cannot restore a " << typ;
+ if (aDrawable.IsNull())
+ {
+ theDI << "Error: cannot restore a " << aType;
return 1;
}
- Draw::SetProgressBar( 0 );
+
+ Draw::Set (aVarName, aDrawable, aDrawable->IsDisplayable() && autodisp);
+ Draw::SetProgressBar (Handle(Draw_ProgressIndicator)());
}
-
- di << name;
+
+ theDI << aVarName;
return 0;
}
Draw_BeforeCommand = &before;
Draw_AfterCommand = &after;
- // set up some variables
+ // Register save/restore tools
+ Draw_Number::RegisterFactory();
+ // set up some variables
const char* n;
Handle(Draw_Axis3D) theAxes3d = new Draw_Axis3D(gp_Pnt(0,0,0),Draw_bleu,20);
n = "axes";
Draw_Drawable2D.hxx
Draw_Drawable3D.cxx
Draw_Drawable3D.hxx
-Draw_Drawable3D.lxx
Draw_Failure.hxx
Draw_GraphicCommands.cxx
Draw_Grid.cxx
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf.hxx>
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <Draw_Color.hxx>
-#include <DrawTrSurf.hxx>
#include <DrawTrSurf_BezierCurve.hxx>
#include <DrawTrSurf_BezierCurve2d.hxx>
#include <DrawTrSurf_BezierSurface.hxx>
#include <DrawTrSurf_Curve.hxx>
#include <DrawTrSurf_Curve2d.hxx>
#include <DrawTrSurf_Drawable.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <DrawTrSurf_Point.hxx>
#include <DrawTrSurf_Polygon2D.hxx>
#include <DrawTrSurf_Polygon3D.hxx>
#include <Standard_Stream.hxx>
#include <TCollection_AsciiString.hxx>
-static Draw_Color PntColor(Draw_rouge);
-static Draw_Color CurvColor(Draw_jaune);
-static Draw_Color BoundsColor(Draw_vert);
-static Draw_Color IsosColor(Draw_bleu);
-static Draw_Color PolesColor(Draw_rouge);
-static Draw_Color KnotsColor(Draw_violet);
-
-static Draw_MarkerShape PntShape = Draw_Plus;
-static Draw_MarkerShape KnotsShape = Draw_Losange;
-static Standard_Boolean ShowPoles = Standard_True;
-static Standard_Boolean ShowKnots = Standard_True;
-static Standard_Boolean knotsIsos =Standard_True;
-static Standard_Real Deflection = 0.01;
-static Standard_Integer KnotsSize = 5;
-static Standard_Integer Discret = 30;
-static Standard_Integer DrawMode = 0;
-static Standard_Integer NbUIsos = 10;
-static Standard_Integer NbVIsos = 10;
-
static TCollection_AsciiString ColorsHint(
"The possible colors are: \n\
white, red, green, blue, cyan,\n\
// previous one to keep possibility to restore the initial
// state
//=======================================================================
-
-Standard_EXPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color col)
+Standard_EXPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color theColor)
{
- Draw_Color c = CurvColor;
- CurvColor = col;
- return c;
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Draw_Color aLastColor = aParams.CurvColor;
+ aParams.CurvColor = theColor;
+ return aLastColor;
}
//=======================================================================
// previous one to keep possibility to restore the initial
// state
//=======================================================================
-
-Standard_EXPORT Draw_Color DrawTrSurf_PointColor(const Draw_Color col)
+Standard_EXPORT Draw_Color DrawTrSurf_PointColor(const Draw_Color theColor)
{
- Draw_Color c = PntColor;
- PntColor = col;
- return c;
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Draw_Color aLastColor = aParams.PntColor;
+ aParams.PntColor = theColor;
+ return aLastColor;
}
//=======================================================================
// previous one to keep possibility to restore the initial
// state
//=======================================================================
+Standard_EXPORT Draw_MarkerShape DrawTrSurf_PointMarker(const Draw_MarkerShape theMarker)
+{
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Draw_MarkerShape aLastMarker = aParams.PntMarker;
+ aParams.PntMarker = theMarker;
+ return aLastMarker;
+}
-Standard_EXPORT Draw_MarkerShape DrawTrSurf_PointMarker(const Draw_MarkerShape marker)
+//=======================================================================
+//function : Parameters
+//purpose :
+//=======================================================================
+DrawTrSurf_Params& DrawTrSurf::Parameters()
{
- Draw_MarkerShape prev = PntShape;
- PntShape = marker;
- return prev;
+ static DrawTrSurf_Params aParams;
+ return aParams;
}
//=======================================================================
//=======================================================================
static Standard_Integer nbiso (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
- if (n < 4) {
- if (n == 3) {
- NbUIsos = Draw::Atoi(a[1]);
- NbVIsos = Draw::Atoi(a[2]);
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ if (n < 4)
+ {
+ if (n == 3)
+ {
+ aParams.NbUIsos = Draw::Atoi (a[1]);
+ aParams.NbVIsos = Draw::Atoi (a[2]);
}
- di << NbUIsos << " " << NbVIsos;
+ di << aParams.NbUIsos << " " << aParams.NbVIsos;
}
- else {
- for (Standard_Integer i = 1; i < n - 2; i++) {
+ else
+ {
+ for (Standard_Integer i = 1; i < n - 2; i++)
+ {
Handle(DrawTrSurf_Surface) DS = GetSurface(a[i]);
- if (!DS.IsNull()) {
- DS->ShowIsos(Draw::Atoi(a[n-2]),Draw::Atoi(a[n-1]));
- Draw::Repaint();
+ if (!DS.IsNull())
+ {
+ DS->ShowIsos (Draw::Atoi (a[n-2]), Draw::Atoi (a[n-1]));
+ Draw::Repaint();
}
}
}
Standard_Integer n,
const char** a)
{
- if ( n == 1) {
- if ( !strcmp(a[0],"shpoles")) {
- ShowPoles = Standard_True;
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ if ( n == 1)
+ {
+ if (!strcmp (a[0], "shpoles"))
+ {
+ aParams.IsShowPoles = Standard_True;
}
- else if ( !strcmp(a[0],"clpoles")) {
- ShowPoles = Standard_False;
+ else if (!strcmp(a[0],"clpoles"))
+ {
+ aParams.IsShowPoles = Standard_False;
}
- else if ( !strcmp(a[0],"shknots")) {
- ShowKnots = Standard_True;
+ else if (!strcmp (a[0], "shknots"))
+ {
+ aParams.IsShowKnots = Standard_True;
}
- else if ( !strcmp(a[0],"clknots")) {
- ShowKnots = Standard_False;
+ else if (!strcmp (a[0], "clknots"))
+ {
+ aParams.IsShowKnots = Standard_False;
}
}
- if ( n<2) return 0;
+ if (n < 2) { return 0; }
Handle(DrawTrSurf_BezierSurface) BZS;
BZS = GetBezierSurface(a[1]);
- if ( !BZS.IsNull()) {
- if ( !strcmp(a[0],"shpoles")) {
+ if (!BZS.IsNull())
+ {
+ if (!strcmp (a[0], "shpoles"))
+ {
BZS->ShowPoles();
}
- else if ( !strcmp(a[0],"clpoles")) {
+ else if (!strcmp (a[0], "clpoles"))
+ {
BZS->ClearPoles();
}
- else {
+ else
+ {
return 1;
}
}
- else {
+ else
+ {
Handle(DrawTrSurf_BSplineSurface) BSS = GetBSplineSurface(a[1]);
- if ( !BSS.IsNull()) {
- if ( !strcmp(a[0],"shpoles")) {
- BSS->ShowPoles();
+ if (!BSS.IsNull())
+ {
+ if (!strcmp (a[0], "shpoles"))
+ {
+ BSS->ShowPoles();
}
- else if ( !strcmp(a[0],"clpoles")) {
- BSS->ClearPoles();
+ else if (!strcmp (a[0], "clpoles"))
+ {
+ BSS->ClearPoles();
}
- else if ( !strcmp(a[0],"shknots")) {
- BSS->ShowKnots();
+ else if (!strcmp (a[0], "shknots"))
+ {
+ BSS->ShowKnots();
}
- else if ( !strcmp(a[0],"clknots")) {
- BSS->ClearKnots();
+ else if (!strcmp (a[0], "clknots"))
+ {
+ BSS->ClearKnots();
}
}
- else {
+ else
+ {
Handle(DrawTrSurf_BezierCurve) BZC = GetBezierCurve(a[1]);
- if ( !BZC.IsNull()) {
- if ( !strcmp(a[0],"shpoles")) {
- BZC->ShowPoles();
- }
- else if ( !strcmp(a[0],"clpoles")) {
- BZC->ClearPoles();
- }
- else {
- return 1;
- }
+ if (!BZC.IsNull())
+ {
+ if (!strcmp (a[0], "shpoles"))
+ {
+ BZC->ShowPoles();
+ }
+ else if (!strcmp (a[0], "clpoles"))
+ {
+ BZC->ClearPoles();
+ }
+ else
+ {
+ return 1;
+ }
}
- else {
- Handle(DrawTrSurf_BSplineCurve) BSC = GetBSplineCurve(a[1]);
- if ( !BSC.IsNull()) {
- if ( !strcmp(a[0],"shpoles")) {
- BSC->ShowPoles();
- }
- else if ( !strcmp(a[0],"clpoles")) {
- BSC->ClearPoles();
- }
- else if ( !strcmp(a[0],"shknots")) {
- BSC->ShowKnots();
- }
- else if ( !strcmp(a[0],"clknots")) {
- BSC->ClearKnots();
- }
- }
- else {
- Handle(DrawTrSurf_BezierCurve2d) BZ2 = GetBezierCurve2d(a[1]);
- if ( !BZ2.IsNull()) {
- if ( !strcmp(a[0],"shpoles")) {
- BZ2->ShowPoles();
- }
- else if ( !strcmp(a[0],"clpoles")) {
- BZ2->ClearPoles();
- }
- else {
- return 1;
- }
- }
- else {
- Handle(DrawTrSurf_BSplineCurve2d) BS2 = GetBSplineCurve2d(a[1]);
- if ( !BS2.IsNull()) {
- if ( !strcmp(a[0],"shpoles")) {
- BS2->ShowPoles();
- }
- else if ( !strcmp(a[0],"clpoles")) {
- BS2->ClearPoles();
- }
- else if ( !strcmp(a[0],"shknots")) {
- BS2->ShowKnots();
- }
- else if ( !strcmp(a[0],"clknots")) {
- BS2->ClearKnots();
- }
- }
- else {
- return 1;
- }
- }
- }
+ else
+ {
+ Handle(DrawTrSurf_BSplineCurve) BSC = GetBSplineCurve(a[1]);
+ if (!BSC.IsNull())
+ {
+ if (!strcmp (a[0],"shpoles"))
+ {
+ BSC->ShowPoles();
+ }
+ else if (!strcmp (a[0], "clpoles"))
+ {
+ BSC->ClearPoles();
+ }
+ else if (!strcmp (a[0], "shknots"))
+ {
+ BSC->ShowKnots();
+ }
+ else if (!strcmp (a[0], "clknots"))
+ {
+ BSC->ClearKnots();
+ }
+ }
+ else
+ {
+ Handle(DrawTrSurf_BezierCurve2d) BZ2 = GetBezierCurve2d(a[1]);
+ if (!BZ2.IsNull())
+ {
+ if (!strcmp (a[0], "shpoles"))
+ {
+ BZ2->ShowPoles();
+ }
+ else if ( !strcmp(a[0],"clpoles"))
+ {
+ BZ2->ClearPoles();
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ Handle(DrawTrSurf_BSplineCurve2d) BS2 = GetBSplineCurve2d(a[1]);
+ if (!BS2.IsNull())
+ {
+ if (!strcmp (a[0], "shpoles"))
+ {
+ BS2->ShowPoles();
+ }
+ else if (!strcmp (a[0], "clpoles"))
+ {
+ BS2->ClearPoles();
+ }
+ else if (!strcmp (a[0], "shknots"))
+ {
+ BS2->ShowKnots();
+ }
+ else if (!strcmp (a[0], "clknots"))
+ {
+ BS2->ClearKnots();
+ }
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ }
}
}
}
static Standard_Integer draw (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
- if (n <= 2) {
- if (!strcmp(a[0],"dmode")) {
- if (n == 2) {
- DrawMode = 1;
- }
- if (DrawMode)
- di << "u";
- else
- di << "d";
- }
-
- else if (!strcmp(a[0],"discr")) {
- if (n == 2)
- Discret = Draw::Atoi(a[n-1]);
- di << Discret;
- }
-
- else if (!strcmp(a[0],"defle")) {
- if (n == 2)
- Deflection = Draw::Atof(a[n-1]);
- di << Deflection;
- }
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ if (n <= 2)
+ {
+ if (!strcmp (a[0], "dmode"))
+ {
+ if (n == 2)
+ {
+ aParams.DrawMode = 1;
+ }
+ di << (aParams.DrawMode ? "u" : "d");
+ }
+ else if (!strcmp (a[0], "discr"))
+ {
+ if (n == 2)
+ {
+ aParams.Discret = Draw::Atoi (a[n - 1]);
+ }
+ di << aParams.Discret;
+ }
+ else if (!strcmp (a[0], "defle"))
+ {
+ if (n == 2)
+ {
+ aParams.Deflection = Draw::Atof (a[n-1]);
+ }
+ di << aParams.Deflection;
+ }
}
- else {
- for (Standard_Integer i = 1; i < n - 1; i++) {
- Handle(DrawTrSurf_Drawable) D = GetDrawable(a[1]);
- if (!D.IsNull()) {
- if (!strcmp(a[0],"dmode")) {
- Standard_Integer mod = 0;
- if ((*a[n-1] == 'U')||(*a[n-1] == 'u')) mod = 1;
- D->SetDrawMode(mod);
- }
-
- else if (!strcmp(a[0],"discr")) {
- D->SetDiscretisation(Draw::Atoi(a[n-1]));
- }
-
- else if (!strcmp(a[0],"defle")) {
- D->SetDeflection(Draw::Atof(a[n-1]));
- }
-
- Draw::Repaint();
+ else
+ {
+ for (Standard_Integer i = 1; i < n - 1; i++)
+ {
+ Handle(DrawTrSurf_Drawable) aDrawable = GetDrawable (a[1]);
+ if (!aDrawable.IsNull())
+ {
+ if (!strcmp (a[0], "dmode"))
+ {
+ Standard_Integer mod = 0;
+ if ((*a[n-1] == 'U')||(*a[n-1] == 'u')) mod = 1;
+ aDrawable->SetDrawMode (mod);
+ }
+ else if (!strcmp (a[0], "discr"))
+ {
+ aDrawable->SetDiscretisation (Draw::Atoi (a[n-1]));
+ }
+ else if (!strcmp (a[0], "defle"))
+ {
+ aDrawable->SetDeflection (Draw::Atof (a[n-1]));
+ }
+ Draw::Repaint();
}
}
}
//function : Set
//purpose : point
//=======================================================================
-void DrawTrSurf::Set(const Standard_CString Name,
- const gp_Pnt& P)
+void DrawTrSurf::Set (const Standard_CString theName,
+ const gp_Pnt& thePoint)
{
- Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
- Draw::Set(Name,DP);
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(DrawTrSurf_Point) aDrawPoint = new DrawTrSurf_Point (thePoint, aParams.PntMarker, aParams.PntColor);
+ Draw::Set (theName, aDrawPoint);
}
//=======================================================================
//function : Set
//purpose : point
//=======================================================================
-void DrawTrSurf::Set(const Standard_CString Name,
- const gp_Pnt2d& P)
+void DrawTrSurf::Set (const Standard_CString theName,
+ const gp_Pnt2d& thePoint)
{
- Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
- Draw::Set(Name,DP);
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(DrawTrSurf_Point) aDrawPoint = new DrawTrSurf_Point (thePoint, aParams.PntMarker, aParams.PntColor);
+ Draw::Set (theName, aDrawPoint);
}
//=======================================================================
//function : Set
//purpose : Geometry from Geom
//=======================================================================
-void DrawTrSurf::Set(const Standard_CString Name,
- const Handle(Geom_Geometry)& G,
+void DrawTrSurf::Set(const Standard_CString theName,
+ const Handle(Geom_Geometry)& theGeometry,
const Standard_Boolean isSenseMarker)
{
- Handle(DrawTrSurf_Drawable) D;
- if (!G.IsNull()) {
-
- Handle(Geom_Curve) C = Handle(Geom_Curve)::DownCast(G);
- if (!C.IsNull()) {
-
- Handle(Geom_BezierCurve) Bez =
- Handle(Geom_BezierCurve)::DownCast(C);
- if (!Bez.IsNull()) {
- Handle(DrawTrSurf_BezierCurve) DBez =
- new DrawTrSurf_BezierCurve(Bez,CurvColor,PolesColor,ShowPoles,
- Discret,Deflection,DrawMode);
- D = DBez;
- }
-
-
- Handle(Geom_BSplineCurve) BS =
- Handle(Geom_BSplineCurve)::DownCast(C);
- if (!BS.IsNull()) {
- Handle(DrawTrSurf_BSplineCurve) DBS =
- new DrawTrSurf_BSplineCurve(BS,
- CurvColor,PolesColor,
- KnotsColor,
- KnotsShape,KnotsSize,
- ShowPoles,ShowKnots,
- Discret,Deflection,DrawMode);
- D = DBS;
- }
-
- if (Bez.IsNull() && BS.IsNull()) {
- Handle(DrawTrSurf_Curve) DC =
- new DrawTrSurf_Curve(C,CurvColor,Discret,Deflection,DrawMode,isSenseMarker);
- D = DC;
- }
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(DrawTrSurf_Drawable) aDrawable;
+ if (Handle(Geom_BezierCurve) aGeomBezierCurve = Handle(Geom_BezierCurve)::DownCast(theGeometry))
+ {
+ aDrawable = new DrawTrSurf_BezierCurve (aGeomBezierCurve,
+ aParams.CurvColor, aParams.PolesColor,
+ aParams.IsShowPoles, aParams.Discret,
+ aParams.Deflection, aParams.DrawMode);
+ }
+ else if (Handle(Geom_BSplineCurve) aGeomBSplineCurve = Handle(Geom_BSplineCurve)::DownCast (theGeometry))
+ {
+ aDrawable = new DrawTrSurf_BSplineCurve (aGeomBSplineCurve,
+ aParams.CurvColor, aParams.PolesColor, aParams.KnotsColor,
+ aParams.KnotsMarker, aParams.KnotsSize,
+ aParams.IsShowPoles, aParams.IsShowKnots,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
+ }
+ else if (Handle(Geom_Curve) aCurve = Handle(Geom_Curve)::DownCast(theGeometry))
+ {
+ aDrawable = new DrawTrSurf_Curve (aCurve, aParams.CurvColor,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode,
+ isSenseMarker);
+ }
+ else if (Handle(Geom_BezierSurface) aBezSurf = Handle(Geom_BezierSurface)::DownCast(theGeometry))
+ {
+ aDrawable = new DrawTrSurf_BezierSurface (aBezSurf,
+ aParams.NbUIsos, aParams.NbVIsos,
+ aParams.BoundsColor, aParams.IsosColor, aParams.PolesColor,
+ aParams.IsShowPoles,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
+ }
+ else if (Handle(Geom_BSplineSurface) aBSplineSurf = Handle(Geom_BSplineSurface)::DownCast(theGeometry))
+ {
+ if (!aParams.NeedKnotsIsos)
+ {
+ aDrawable = new DrawTrSurf_BSplineSurface (aBSplineSurf,
+ aParams.NbUIsos, aParams.NbVIsos,
+ aParams.BoundsColor, aParams.IsosColor,
+ aParams.PolesColor, aParams.KnotsColor,
+ aParams.KnotsMarker, aParams.KnotsSize,
+ aParams.IsShowPoles, aParams.IsShowKnots,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
}
-
-
- Handle(Geom_Surface) S = Handle(Geom_Surface)::DownCast(G);
- if (!S.IsNull()) {
-
- Handle(Geom_BezierSurface) Bez =
- Handle(Geom_BezierSurface)::DownCast(S);
- if (!Bez.IsNull()) {
- Handle(DrawTrSurf_BezierSurface) DBez =
- new DrawTrSurf_BezierSurface(Bez,NbUIsos,NbVIsos,
- BoundsColor,IsosColor,PolesColor,
- ShowPoles,
- Discret,Deflection,DrawMode);
- D = DBez;
- }
-
-
- Handle(Geom_BSplineSurface) BS =
- Handle(Geom_BSplineSurface)::DownCast(S);
- if (!BS.IsNull()) {
- Handle(DrawTrSurf_BSplineSurface) DBS ;
- if (!knotsIsos)
- DBS = new DrawTrSurf_BSplineSurface(BS,
- NbUIsos,NbVIsos,
- BoundsColor,IsosColor,
- PolesColor,KnotsColor,
- KnotsShape,KnotsSize,
- ShowPoles,ShowKnots,
- Discret,Deflection,DrawMode);
- else
- DBS = new DrawTrSurf_BSplineSurface(BS,
- BoundsColor,IsosColor,
- PolesColor,KnotsColor,
- KnotsShape,KnotsSize,
- ShowPoles,ShowKnots,
- Discret,Deflection,DrawMode);
-
- D = DBS;
- }
-
- if (Bez.IsNull() && BS.IsNull()) {
- Handle(DrawTrSurf_Surface) DS =
- new DrawTrSurf_Surface(S,
- NbUIsos,NbVIsos,
- BoundsColor,IsosColor,
- Discret,Deflection,DrawMode);
- D = DS;
- }
+ else
+ {
+ aDrawable = new DrawTrSurf_BSplineSurface (aBSplineSurf,
+ aParams.BoundsColor, aParams.IsosColor,
+ aParams.PolesColor, aParams.KnotsColor,
+ aParams.KnotsMarker, aParams.KnotsSize,
+ aParams.IsShowPoles, aParams.IsShowKnots,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
}
-
}
- Draw::Set(Name,D);
-}
+ else if (Handle(Geom_Surface) aSurface = Handle(Geom_Surface)::DownCast(theGeometry))
+ {
+ aDrawable = new DrawTrSurf_Surface (aSurface,
+ aParams.NbUIsos, aParams.NbVIsos,
+ aParams.BoundsColor, aParams.IsosColor,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
+ }
+ Draw::Set (theName, aDrawable);
+}
//=======================================================================
//function : Set
//purpose : Curve from Geom2d
//=======================================================================
-void DrawTrSurf::Set(const Standard_CString Name,
- const Handle(Geom2d_Curve)& C,
+void DrawTrSurf::Set(const Standard_CString theName,
+ const Handle(Geom2d_Curve)& theCurve,
const Standard_Boolean isSenseMarker)
{
- Handle(DrawTrSurf_Drawable) D;
- if (!C.IsNull()) {
-
- Handle(Geom2d_BezierCurve) Bez =
- Handle(Geom2d_BezierCurve)::DownCast(C);
- if (!Bez.IsNull()) {
- Handle(DrawTrSurf_BezierCurve2d) DBez =
- new DrawTrSurf_BezierCurve2d(Bez,CurvColor,PolesColor,ShowPoles,
- Discret);
- D = DBez;
- }
-
-
- Handle(Geom2d_BSplineCurve) BS =
- Handle(Geom2d_BSplineCurve)::DownCast(C);
- if (!BS.IsNull()) {
- Handle(DrawTrSurf_BSplineCurve2d) DBS =
- new DrawTrSurf_BSplineCurve2d(BS,
- CurvColor,PolesColor,
- KnotsColor,
- KnotsShape,KnotsSize,
- ShowPoles,ShowKnots,
- Discret);
- D = DBS;
- }
-
- if (Bez.IsNull() && BS.IsNull()) {
- Handle(DrawTrSurf_Curve2d) DC =
- new DrawTrSurf_Curve2d(C,CurvColor,Discret,isSenseMarker);
- D = DC;
- }
- }
+ DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(DrawTrSurf_Drawable) aDrawable;
+ if (Handle(Geom2d_BezierCurve) aBezierCurve = Handle(Geom2d_BezierCurve)::DownCast(theCurve))
+ {
+ aDrawable = new DrawTrSurf_BezierCurve2d (aBezierCurve,
+ aParams.CurvColor, aParams.PolesColor, aParams.IsShowPoles,
+ aParams.Discret);
+ }
+ else if (Handle(Geom2d_BSplineCurve) aBSplineCurve = Handle(Geom2d_BSplineCurve)::DownCast(theCurve))
+ {
+ aDrawable = new DrawTrSurf_BSplineCurve2d (aBSplineCurve,
+ aParams.CurvColor, aParams.PolesColor, aParams.KnotsColor,
+ aParams.KnotsMarker, aParams.KnotsSize,
+ aParams.IsShowPoles, aParams.IsShowKnots, aParams.Discret);
+ }
+ else if (!theCurve.IsNull())
+ {
+ aDrawable = new DrawTrSurf_Curve2d (theCurve, aParams.CurvColor, aParams.Discret, isSenseMarker);
+ }
- Draw::Set(Name,D);
+ Draw::Set (theName, aDrawable);
}
//=======================================================================
if (done) return;
done = Standard_True;
+ DrawTrSurf_BezierCurve::RegisterFactory();
+ DrawTrSurf_BezierCurve2d::RegisterFactory();
+ DrawTrSurf_BezierSurface::RegisterFactory();
+ DrawTrSurf_BSplineCurve::RegisterFactory();
+ DrawTrSurf_BSplineCurve2d::RegisterFactory();
+ DrawTrSurf_BSplineSurface::RegisterFactory();
+ DrawTrSurf_Curve::RegisterFactory();
+ DrawTrSurf_Curve2d::RegisterFactory();
+ DrawTrSurf_Point::RegisterFactory();
+ DrawTrSurf_Polygon2D::RegisterFactory();
+ DrawTrSurf_Polygon3D::RegisterFactory();
+ DrawTrSurf_Surface::RegisterFactory();
+ DrawTrSurf_Triangulation::RegisterFactory();
+
const char* g;
g = "geometric display commands";
__FILE__,
d2transform,g);
}
-
-
-//=================================================================
-// save and restore curves
-//=================================================================
-
-static Standard_Boolean ctest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve));
-}
-
-static void csave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_Curve) N = Handle(DrawTrSurf_Curve)::DownCast(d);
- GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
-}
-
-static Handle(Draw_Drawable3D) crestore (std::istream& is)
-{
- Handle(Geom_Curve) G = GeomTools_CurveSet::ReadCurve(is);
- Handle(DrawTrSurf_Curve) N =
- new DrawTrSurf_Curve(G,CurvColor,Discret,Deflection,DrawMode);
- return N;
-}
-
-
-static Draw_SaveAndRestore csr("DrawTrSurf_Curve",
- ctest,csave,crestore);
-
-
-
-
-//=================================================================
-// save and restore bezier curves
-//=================================================================
-
-static Standard_Boolean bzctest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve));
-}
-
-static void bzcsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_BezierCurve)
- N = Handle(DrawTrSurf_BezierCurve)::DownCast(d);
- GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
-}
-
-static Handle(Draw_Drawable3D) bzcrestore (std::istream& is)
-{
- Handle(Geom_BezierCurve) G =
- Handle(Geom_BezierCurve)::DownCast (GeomTools_CurveSet::ReadCurve(is));
- Handle(DrawTrSurf_BezierCurve) N =
- new DrawTrSurf_BezierCurve(G,CurvColor,PolesColor,ShowPoles,
- Discret,Deflection,DrawMode);
- return N;
-}
-
-
-static Draw_SaveAndRestore bzcsr("DrawTrSurf_BezierCurve",
- bzctest,bzcsave,bzcrestore);
-
-
-
-
-//=================================================================
-// save and restore bspline curves
-//=================================================================
-
-static Standard_Boolean bsctest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve));
-}
-
-static void bscsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_BSplineCurve)
- N = Handle(DrawTrSurf_BSplineCurve)::DownCast(d);
- GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
-}
-
-static Handle(Draw_Drawable3D) bscrestore (std::istream& is)
-{
- Handle(Geom_BSplineCurve) G =
- Handle(Geom_BSplineCurve)::DownCast (GeomTools_CurveSet::ReadCurve(is));
- Handle(DrawTrSurf_BSplineCurve) N =
- new DrawTrSurf_BSplineCurve(G, CurvColor,PolesColor,
- KnotsColor,
- KnotsShape,KnotsSize,
- ShowPoles,ShowKnots,
- Discret,Deflection,DrawMode);
- return N;
-}
-
-
-static Draw_SaveAndRestore bscsr("DrawTrSurf_BSplineCurve",
- bsctest,bscsave,bscrestore);
-
-
-//=================================================================
-// save and restore curves 2d
-//=================================================================
-
-static Standard_Boolean c2dtest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve2d));
-}
-
-static void c2dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_Curve2d) N = Handle(DrawTrSurf_Curve2d)::DownCast(d);
- GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
-}
-
-static Handle(Draw_Drawable3D) c2drestore (std::istream& is)
-{
- Handle(Geom2d_Curve) G = GeomTools_Curve2dSet::ReadCurve2d(is);
- Handle(DrawTrSurf_Curve2d) N =
- new DrawTrSurf_Curve2d(G,CurvColor,Discret);
- return N;
-}
-
-
-static Draw_SaveAndRestore c2dsr("DrawTrSurf_Curve2d",
- c2dtest,c2dsave,c2drestore);
-
-
-
-
-//=================================================================
-// save and restore bezier curves 2d
-//=================================================================
-
-static Standard_Boolean bzc2dtest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve2d));
-}
-
-static void bzc2dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_BezierCurve2d)
- N = Handle(DrawTrSurf_BezierCurve2d)::DownCast(d);
- GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
-}
-
-static Handle(Draw_Drawable3D) bzc2drestore (std::istream& is)
-{
- Handle(Geom2d_BezierCurve) G =
- Handle(Geom2d_BezierCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d(is));
- Handle(DrawTrSurf_BezierCurve2d) N =
- new DrawTrSurf_BezierCurve2d(G,CurvColor,PolesColor,ShowPoles,
- Discret);
- return N;
-}
-
-
-static Draw_SaveAndRestore bzc2dsr("DrawTrSurf_BezierCurve2d",
- bzc2dtest,bzc2dsave,bzc2drestore);
-
-
-
-
-//=================================================================
-// save and restore bspline curves 2d
-//=================================================================
-
-static Standard_Boolean bsc2dtest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve2d));
-}
-
-static void bsc2dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_BSplineCurve2d)
- N = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(d);
- GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
-}
-
-static Handle(Draw_Drawable3D) bsc2drestore (std::istream& is)
-{
- Handle(Geom2d_BSplineCurve) G =
- Handle(Geom2d_BSplineCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d(is));
- Handle(DrawTrSurf_BSplineCurve2d) N =
- new DrawTrSurf_BSplineCurve2d(G, CurvColor,PolesColor,
- KnotsColor,
- KnotsShape,KnotsSize,
- ShowPoles,ShowKnots,
- Discret);
- return N;
-}
-
-
-static Draw_SaveAndRestore bsc2dsr("DrawTrSurf_BSplineCurve2d",
- bsc2dtest,bsc2dsave,bsc2drestore);
-
-
-//=================================================================
-// save and restore surfaces
-//=================================================================
-
-static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Surface));
-}
-
-static void ssave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_Surface) N = Handle(DrawTrSurf_Surface)::DownCast(d);
- GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
-}
-
-static Handle(Draw_Drawable3D) srestore (std::istream& is)
-{
- Handle(Geom_Surface) G = GeomTools_SurfaceSet::ReadSurface(is);
- Handle(DrawTrSurf_Surface) N =
- new DrawTrSurf_Surface(G,
- NbUIsos,NbVIsos,
- BoundsColor,IsosColor,
- Discret,Deflection,DrawMode);
- return N;
-}
-
-
-static Draw_SaveAndRestore ssr("DrawTrSurf_Surface",
- stest,ssave,srestore);
-
-
-
-
-//=================================================================
-// save and restore bezier surfaces
-//=================================================================
-
-static Standard_Boolean bzstest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierSurface));
-}
-
-static void bzssave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_BezierSurface)
- N = Handle(DrawTrSurf_BezierSurface)::DownCast(d);
- GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
-}
-
-static Handle(Draw_Drawable3D) bzsrestore (std::istream& is)
-{
- Handle(Geom_BezierSurface) G =
- Handle(Geom_BezierSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface(is));
- Handle(DrawTrSurf_BezierSurface) N =
- new DrawTrSurf_BezierSurface(G,NbUIsos,NbVIsos,
- BoundsColor,IsosColor,PolesColor,
- ShowPoles,
- Discret,Deflection,DrawMode);
- return N;
-}
-
-
-static Draw_SaveAndRestore bzssr("DrawTrSurf_BezierSurface",
- bzstest,bzssave,bzsrestore);
-
-
-
-
-//=================================================================
-// save and restore bspline surfaces
-//=================================================================
-
-static Standard_Boolean bsstest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineSurface));
-}
-
-static void bsssave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_BSplineSurface)
- N = Handle(DrawTrSurf_BSplineSurface)::DownCast(d);
- GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
-}
-
-static Handle(Draw_Drawable3D) bssrestore (std::istream& is)
-{
- Handle(Geom_BSplineSurface) G =
- Handle(Geom_BSplineSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface(is));
- Handle(DrawTrSurf_BSplineSurface) N;
- if (!knotsIsos)
- N = new DrawTrSurf_BSplineSurface(G,
- NbUIsos,NbVIsos,
- BoundsColor,IsosColor,
- PolesColor,KnotsColor,
- KnotsShape,KnotsSize,
- ShowPoles,ShowKnots,
- Discret,Deflection,DrawMode);
- else
- N = new DrawTrSurf_BSplineSurface(G,
- BoundsColor,IsosColor,
- PolesColor,KnotsColor,
- KnotsShape,KnotsSize,
- ShowPoles,ShowKnots,
- Discret,Deflection,DrawMode);
-
- return N;
-}
-
-
-static Draw_SaveAndRestore bsssr("DrawTrSurf_BSplineSurface",
- bsstest,bsssave,bssrestore);
-
-
-//=================================================================
-// save and restore points
-//=================================================================
-
-static Standard_Boolean pnttest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Point));
-}
-
-static void pntsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_Point)
- N = Handle(DrawTrSurf_Point)::DownCast(d);
-#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
- std::ios::fmtflags F = OS.flags();
- OS.setf(std::ios::scientific,std::ios::floatfield);
- OS.precision(15);
-#else
- long form = OS.setf(std::ios::scientific);
- std::streamsize prec = OS.precision(15);
-#endif
- gp_Pnt P = N->Point();
- if (N->Is3D()) {
- OS << "1 ";
- OS << P.X() << " " << P.Y() << " " << P.Z() << "\n";
- }
- else {
- OS << "0 ";
- OS << P.X() << " " << P.Y() << "\n";
- }
-#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
- OS.setf(F);
-#else
- OS.setf(form);
- OS.precision(prec);
-#endif
-}
-
-static Handle(Draw_Drawable3D) pntrestore (std::istream& is)
-{
- Standard_Integer is3d;
- is >> is3d;
- Standard_Real x,y,z = 0.;
- if (is3d)
- is >> x >> y >> z;
- else
- is >> x >> y;
- Handle(DrawTrSurf_Point) N;
- if (is3d)
- N = new DrawTrSurf_Point(gp_Pnt(x,y,z),PntShape,PntColor);
- else
- N = new DrawTrSurf_Point(gp_Pnt2d(x,y),PntShape,PntColor);
-
- return N;
-}
-
-
-static Draw_SaveAndRestore pntsr("DrawTrSurf_Point",
- pnttest,pntsave,pntrestore);
-
-
-
-//=================================================================
-// save and restore triangulation
-//=================================================================
-
-static Standard_Boolean triatest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Triangulation));
-}
-
-static void triasave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_Triangulation)
- T = Handle(DrawTrSurf_Triangulation)::DownCast(d);
-#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
- std::ios::fmtflags F = OS.flags();
- OS.setf(std::ios::scientific,std::ios::floatfield);
- OS.precision(15);
-#else
- long form = OS.setf(std::ios::scientific);
- std::streamsize prec = OS.precision(15);
-#endif
- Poly::Write(T->Triangulation(),OS);
-#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
- OS.setf(F);
-#else
- OS.setf(form);
- OS.precision(prec);
-#endif
-}
-
-static Handle(Draw_Drawable3D) triarestore (std::istream& is)
-{
- return new DrawTrSurf_Triangulation(Poly::ReadTriangulation(is));
-}
-
-
-static Draw_SaveAndRestore triasr("DrawTrSurf_Triangulation",
- triatest,triasave,triarestore);
-
-
-
-//=================================================================
-// save and restore polygon3d
-//=================================================================
-
-static Standard_Boolean poly3dtest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon3D));
-}
-
-static void poly3dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_Polygon3D)
- T = Handle(DrawTrSurf_Polygon3D)::DownCast(d);
-#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
- std::ios::fmtflags F = OS.flags();
- OS.setf(std::ios::scientific,std::ios::floatfield);
- OS.precision(15);
-#else
- long form = OS.setf(std::ios::scientific);
- std::streamsize prec = OS.precision(15);
-#endif
- Poly::Write(T->Polygon3D(),OS);
-#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
- OS.setf(F);
-#else
- OS.setf(form);
- OS.precision(prec);
-#endif
-}
-
-static Handle(Draw_Drawable3D) poly3drestore (std::istream& is)
-{
- return new DrawTrSurf_Polygon3D(Poly::ReadPolygon3D(is));
-}
-
-
-static Draw_SaveAndRestore poly3dsr("DrawTrSurf_Polygon3D",
- poly3dtest,poly3dsave,poly3drestore);
-
-
-//=================================================================
-// save and restore polygon2d
-//=================================================================
-
-static Standard_Boolean poly2dtest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon2D));
-}
-
-static void poly2dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(DrawTrSurf_Polygon2D)
- T = Handle(DrawTrSurf_Polygon2D)::DownCast(d);
-#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
- std::ios::fmtflags F = OS.flags();
- OS.setf(std::ios::scientific, std::ios::floatfield);
- OS.precision(15);
-#else
- long form = OS.setf(std::ios::scientific);
- std::streamsize prec = OS.precision(15);
-#endif
- Poly::Write(T->Polygon2D(),OS);
-#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
- OS.setf(F);
-#else
- OS.setf(form);
- OS.precision(prec);
-#endif
-}
-
-static Handle(Draw_Drawable3D) poly2drestore (std::istream& is)
-{
- return new DrawTrSurf_Polygon2D(Poly::ReadPolygon2D(is));
-}
-
-
-static Draw_SaveAndRestore poly2dsr("DrawTrSurf_Polygon2D",
- poly2dtest,poly2dsave,poly2drestore);
-
#ifndef _DrawTrSurf_HeaderFile
#define _DrawTrSurf_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
#include <Draw_Interpretor.hxx>
#include <Geom_Geometry.hxx>
#include <Geom_Surface.hxx>
#include <Geom2d_Curve.hxx>
-class gp_Pnt;
-class gp_Pnt2d;
-class Poly_Triangulation;
-class Poly_Polygon3D;
-class Poly_Polygon2D;
-class Geom_Curve;
class Geom_BezierCurve;
+class Geom_BezierSurface;
class Geom_BSplineCurve;
+class Geom_BSplineSurface;
class Geom2d_BezierCurve;
class Geom2d_BSplineCurve;
-class Geom_BezierSurface;
-class Geom_BSplineSurface;
-class DrawTrSurf_Drawable;
-class DrawTrSurf_Point;
-class DrawTrSurf_Curve;
-class DrawTrSurf_BSplineCurve;
-class DrawTrSurf_BezierCurve;
-class DrawTrSurf_Curve2d;
-class DrawTrSurf_BSplineCurve2d;
-class DrawTrSurf_BezierCurve2d;
-class DrawTrSurf_Triangulation2D;
-class DrawTrSurf_Surface;
-class DrawTrSurf_BSplineSurface;
-class DrawTrSurf_BezierSurface;
-class DrawTrSurf_Triangulation;
-class DrawTrSurf_Polygon3D;
-class DrawTrSurf_Polygon2D;
-
+class Poly_Polygon2D;
+class Poly_Polygon3D;
+class Poly_Triangulation;
+struct DrawTrSurf_Params;
-//! This package supports the display of parametric
-//! curves and surfaces.
+//! 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
//! 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.
+//! The Triangulation and Polygon from the package Poly are also supported.
class DrawTrSurf
{
public:
DEFINE_STANDARD_ALLOC
-
//! Sets <G> in the variable <Name>. Overwrite the
//! variable if already set.
Standard_EXPORT static void Set (const Standard_CString Name, const gp_Pnt& G);
//! Get the variable <S>. Returns a null handle if
//! none, and print a warning message.
Standard_EXPORT static Handle(Poly_Polygon2D) GetPolygon2D (Standard_CString& Name);
-
- //! defines display commands.
- Standard_EXPORT static void BasicCommands (Draw_Interpretor& I);
-
-
+ //! Return package global parameters.
+ Standard_EXPORT static DrawTrSurf_Params& Parameters();
-protected:
-
-
-
-
-
-private:
-
-
-
-
-friend class DrawTrSurf_Drawable;
-friend class DrawTrSurf_Point;
-friend class DrawTrSurf_Curve;
-friend class DrawTrSurf_BSplineCurve;
-friend class DrawTrSurf_BezierCurve;
-friend class DrawTrSurf_Curve2d;
-friend class DrawTrSurf_BSplineCurve2d;
-friend class DrawTrSurf_BezierCurve2d;
-friend class DrawTrSurf_Triangulation2D;
-friend class DrawTrSurf_Surface;
-friend class DrawTrSurf_BSplineSurface;
-friend class DrawTrSurf_BezierSurface;
-friend class DrawTrSurf_Triangulation;
-friend class DrawTrSurf_Polygon3D;
-friend class DrawTrSurf_Polygon2D;
+ //! defines display commands.
+ Standard_EXPORT static void BasicCommands (Draw_Interpretor& I);
};
-
-
-
-
-
-
#endif // _DrawTrSurf_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_BSplineCurve.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
#include <Draw_MarkerShape.hxx>
-#include <DrawTrSurf_BSplineCurve.hxx>
+#include <DrawTrSurf.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <Geom_BSplineCurve.hxx>
#include <gp_Pnt2d.hxx>
-#include <Standard_Type.hxx>
+#include <GeomTools_CurveSet.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve,DrawTrSurf_Curve)
-
-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;
- }
-
-
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve, DrawTrSurf_Curve)
+DrawTrSurf_BSplineCurve::DrawTrSurf_BSplineCurve (const Handle(Geom_BSplineCurve)& C)
+: DrawTrSurf_Curve (C, Draw_vert, 16, 0.05, 1)
+{
- 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;
- }
+ 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 {
+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);
+ }
+ }
+}
- 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);
+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++) {
+ 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);
- }
+ 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));
}
}
-
- 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));
+ 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;
}
- 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);
+ 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));
}
- }
-
-
- 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));
- }
+ for (Standard_Integer k = ka; k < kb; k++)
+ {
+ if (k == ka)
+ {
+ Ua = Uk1;
+ Ub = C->Knot (k+1);
}
- else if (Pindex == 1) {
- dis.MoveTo(CPoles(1));
- dis.DrawTo(CPoles(2));
+ else if (k == kb-1)
+ {
+ Ua = C->Knot (k);
+ Ub = Uk2;
}
- else if (Pindex == NbPoles) {
- dis.MoveTo(CPoles(NbPoles-1));
- dis.DrawTo(CPoles(NbPoles));
+ else
+ {
+ Ua = C->Knot (k);
+ Ub = C->Knot (k+1);
}
- else {
- dis.MoveTo(CPoles(Pindex-1));
- dis.DrawTo(CPoles(Pindex));
- dis.DrawTo(CPoles(Pindex+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));
}
+ }
-
-
- dis.SetColor(look);
- Standard_Integer Degree = C->Degree();
-
- if (Degree == 1) {
- dis.MoveTo(C->Value(U1));
- dis.DrawTo(C->Value(U2));
+ 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);
}
- 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));
- }
+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;
+}
-
- 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::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;
}
-
- }
-
-
-
- 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;
- }
-
+ Index++;
+ }
+ Index = 0;
+}
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve::Copy()const
+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;
}
-
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve::Restore (std::istream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(Geom_BSplineCurve) aGeomCurve = Handle(Geom_BSplineCurve)::DownCast (GeomTools_CurveSet::ReadCurve (theStream));
+ Handle(DrawTrSurf_BSplineCurve) aDrawCurve = new DrawTrSurf_BSplineCurve (aGeomCurve,
+ aParams.CurvColor, aParams.PolesColor, aParams.KnotsColor,
+ aParams.KnotsMarker, aParams.KnotsSize,
+ aParams.IsShowPoles, aParams.IsShowKnots,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
+ return aDrawCurve;
+}
#ifndef _DrawTrSurf_BSplineCurve_HeaderFile
#define _DrawTrSurf_BSplineCurve_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
#include <Draw_MarkerShape.hxx>
#include <Draw_Color.hxx>
-#include <Standard_Integer.hxx>
#include <DrawTrSurf_Curve.hxx>
-#include <Standard_Real.hxx>
+
class Geom_BSplineCurve;
class Draw_Color;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_BSplineCurve;
DEFINE_STANDARD_HANDLE(DrawTrSurf_BSplineCurve, DrawTrSurf_Curve)
-
class DrawTrSurf_BSplineCurve : public DrawTrSurf_Curve
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve, DrawTrSurf_Curve)
+ Draw_Drawable3D_FACTORY
public:
-
-
- //! creates a drawable BSpline curve from a BSpline curve of
- //! package Geom.
- Standard_EXPORT DrawTrSurf_BSplineCurve(const Handle(Geom_BSplineCurve)& C);
-
-
- //! creates a drawable BSpline curve from a BSpline curve of
- //! package Geom.
- Standard_EXPORT 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);
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- Standard_EXPORT void DrawOn (Draw_Display& dis, const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots) const;
-
- Standard_EXPORT void DrawOn (Draw_Display& dis, const Standard_Real U1, const Standard_Real U2, const Standard_Integer Pindex, const Standard_Boolean ShowPoles = Standard_True, const Standard_Boolean ShowKnots = Standard_True) const;
-
- Standard_EXPORT void ShowPoles();
-
- Standard_EXPORT void ShowKnots();
-
- Standard_EXPORT void ClearPoles();
-
- Standard_EXPORT void ClearKnots();
-
+ //! creates a drawable BSpline curve from a BSpline curve of package Geom.
+ Standard_EXPORT DrawTrSurf_BSplineCurve (const Handle(Geom_BSplineCurve)& C);
+
+ //! creates a drawable BSpline curve from a BSpline curve of package Geom.
+ Standard_EXPORT 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);
+
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+
+ Standard_EXPORT void DrawOn (Draw_Display& dis,
+ const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots) const;
+
+ Standard_EXPORT void DrawOn (Draw_Display& dis,
+ const Standard_Real U1, const Standard_Real U2, const Standard_Integer Pindex,
+ const Standard_Boolean ShowPoles = Standard_True, const Standard_Boolean ShowKnots = Standard_True) const;
+
+ void ShowPoles() { drawPoles = Standard_True; }
+
+ void ShowKnots() { drawKnots = Standard_True; }
+
+ void ClearPoles() { drawPoles = Standard_False; }
+
+ void ClearKnots() { drawKnots = Standard_False; }
//! Returns in <Index> the index of the first pole of the
//! curve projected by the Display <D> at a distance lower
//! set to 0, else index is always greater than the input
//! value of index.
Standard_EXPORT void FindPole (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& Index) const;
-
- Standard_EXPORT void FindKnot (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& Index) const;
-
- void SetPolesColor (const Draw_Color& aColor);
-
- void SetKnotsColor (const Draw_Color& aColor);
-
- void SetKnotsShape (const Draw_MarkerShape Shape);
-
- Draw_MarkerShape KnotsShape() const;
-
- Draw_Color KnotsColor() const;
-
- Draw_Color PolesColor() const;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
+ Standard_EXPORT void FindKnot (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& Index) const;
+ void SetPolesColor (const Draw_Color& theColor) { polesLook = theColor; }
+ void SetKnotsColor (const Draw_Color& theColor) { knotsLook = theColor; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve,DrawTrSurf_Curve)
+ void SetKnotsShape (const Draw_MarkerShape theShape) { knotsForm = theShape; }
-protected:
+ Draw_MarkerShape KnotsShape() const { return knotsForm; }
+ Draw_Color KnotsColor() const { return knotsLook; }
+ Draw_Color PolesColor() const { return polesLook; }
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
private:
-
Standard_Boolean drawPoles;
Standard_Boolean drawKnots;
Draw_MarkerShape knotsForm;
Standard_Integer knotsDim;
Draw_Color polesLook;
-
};
-
-#include <DrawTrSurf_BSplineCurve.lxx>
-
-
-
-
-
#endif // _DrawTrSurf_BSplineCurve_HeaderFile
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-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;
- }
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_BSplineCurve2d.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
#include <Draw_MarkerShape.hxx>
-#include <DrawTrSurf_BSplineCurve2d.hxx>
+#include <DrawTrSurf.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <Geom2d_BSplineCurve.hxx>
+#include <GeomTools_Curve2dSet.hxx>
#include <gp_Pnt.hxx>
-#include <Standard_Type.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve2d,DrawTrSurf_Curve2d)
-
-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;
- }
-
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
+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;
+}
-void DrawTrSurf_BSplineCurve2d::DrawOn (Draw_Display& dis) const
+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) {
}
}
+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::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;
- }
+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 :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve2d::Copy()const
+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;
}
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve2d::Restore (Standard_IStream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(Geom2d_BSplineCurve) aGeomCurve = Handle(Geom2d_BSplineCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d (theStream));
+ Handle(DrawTrSurf_BSplineCurve2d) aDrawCurve = new DrawTrSurf_BSplineCurve2d (aGeomCurve,
+ aParams.CurvColor, aParams.PolesColor, aParams.KnotsColor,
+ aParams.KnotsMarker, aParams.KnotsSize,
+ aParams.IsShowPoles, aParams.IsShowKnots,
+ aParams.Discret);
+ return aDrawCurve;
+}
#ifndef _DrawTrSurf_BSplineCurve2d_HeaderFile
#define _DrawTrSurf_BSplineCurve2d_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
#include <Draw_MarkerShape.hxx>
#include <Draw_Color.hxx>
-#include <Standard_Integer.hxx>
#include <DrawTrSurf_Curve2d.hxx>
-#include <Standard_Real.hxx>
+
class Geom2d_BSplineCurve;
class Draw_Color;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_BSplineCurve2d;
DEFINE_STANDARD_HANDLE(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
-
class DrawTrSurf_BSplineCurve2d : public DrawTrSurf_Curve2d
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
+ Draw_Drawable3D_FACTORY
public:
-
-
- //! creates a drawable BSpline curve from a BSpline curve of
- //! package Geom2d.
- Standard_EXPORT DrawTrSurf_BSplineCurve2d(const Handle(Geom2d_BSplineCurve)& C);
-
- Standard_EXPORT 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);
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- Standard_EXPORT void ShowPoles();
-
- Standard_EXPORT void ShowKnots();
-
- Standard_EXPORT void ClearPoles();
-
- Standard_EXPORT void ClearKnots();
-
+ //! creates a drawable BSpline curve from a BSpline curve of package Geom2d.
+ Standard_EXPORT DrawTrSurf_BSplineCurve2d (const Handle(Geom2d_BSplineCurve)& C);
+
+ Standard_EXPORT 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);
+
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+
+ void ShowPoles() { drawPoles = Standard_True; }
+
+ void ShowKnots() { drawKnots = Standard_True; }
+
+ void ClearPoles() { drawPoles = Standard_False; }
+
+ void ClearKnots() { drawKnots = Standard_False; }
+
//! 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.
Standard_EXPORT void FindPole (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& Index) const;
-
- Standard_EXPORT void FindKnot (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& Index) const;
-
- void SetPolesColor (const Draw_Color& aColor);
-
- void SetKnotsColor (const Draw_Color& aColor);
-
- void SetKnotsShape (const Draw_MarkerShape Shape);
-
- Draw_MarkerShape KnotsShape() const;
-
- Draw_Color KnotsColor() const;
-
- Draw_Color PolesColor() const;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
+ Standard_EXPORT void FindKnot (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& Index) const;
+ void SetPolesColor (const Draw_Color& theColor) { polesLook = theColor; }
+ void SetKnotsColor (const Draw_Color& theColor) { knotsLook = theColor; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve2d,DrawTrSurf_Curve2d)
+ void SetKnotsShape (const Draw_MarkerShape theShape) { knotsForm = theShape; }
-protected:
+ Draw_MarkerShape KnotsShape() const { return knotsForm; }
+ Draw_Color KnotsColor() const { return knotsLook; }
+ Draw_Color PolesColor() const { return polesLook; }
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
private:
-
Standard_Boolean drawPoles;
Standard_Boolean drawKnots;
Draw_MarkerShape knotsForm;
Standard_Integer knotsDim;
Draw_Color polesLook;
-
};
-
-#include <DrawTrSurf_BSplineCurve2d.lxx>
-
-
-
-
-
#endif // _DrawTrSurf_BSplineCurve2d_HeaderFile
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-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;
- }
-
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_BSplineSurface.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
#include <Draw_MarkerShape.hxx>
+#include <DrawTrSurf.hxx>
#include <DrawTrSurf_BSplineCurve.hxx>
-#include <DrawTrSurf_BSplineSurface.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <Geom_BSplineSurface.hxx>
#include <GeomAdaptor_Surface.hxx>
-#include <GeomAdaptor_Surface.hxx>
+#include <GeomTools_SurfaceSet.hxx>
#include <gp_Pnt2d.hxx>
-#include <Standard_Type.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BSplineSurface,DrawTrSurf_Surface)
-
-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;
- }
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BSplineSurface, DrawTrSurf_Surface)
+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 {
-
+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) {
+ 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++) {
+ for (j = 1; j <= NbVPoles; j++)
+ {
dis.MoveTo(SPoles(1, j));
- for (i = 2; i <= NbUPoles; i++) {
- dis.DrawTo(SPoles(i, j));
+ for (i = 2; i <= NbUPoles; i++)
+ {
+ dis.DrawTo(SPoles(i, j));
}
if (S->IsUPeriodic())
- dis.DrawTo(SPoles(1,j));
+ {
+ dis.DrawTo(SPoles(1,j));
+ }
}
- for (i = 1; i <= NbUPoles; i++) {
+ for (i = 1; i <= NbUPoles; i++)
+ {
dis.MoveTo(SPoles(i, 1));
- for (j = 2; j <= NbVPoles; j++) {
- dis.DrawTo(SPoles(i, j));
+ for (j = 2; j <= NbVPoles; j++)
+ {
+ dis.DrawTo(SPoles(i, j));
}
if (S->IsVPeriodic())
- dis.DrawTo(SPoles(i,1));
+ {
+ dis.DrawTo(SPoles(i,1));
+ }
}
}
-
- if (knotsIsos) {
+ if (knotsIsos)
+ {
Standard_Integer first, last;
Handle(GeomAdaptor_Surface) HS = new GeomAdaptor_Surface();
HS->Load(surf);
dis.SetColor(isosLook);
first = S->FirstUKnotIndex() + 1;
last = S->LastUKnotIndex() - 1;
- for (i = first; i <= last; i++) {
+ 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++) {
+ for (j = first; j <= last; j++)
+ {
DrawIsoCurveOn(C,GeomAbs_IsoV,S->VKnot(j),Ua,Ub,dis);
}
}
DrawTrSurf_Surface::DrawOn(dis,!knotsIsos);
- if (drawKnots) {
+ if (drawKnots)
+ {
Standard_Integer first, last;
Standard_Integer NbUKnots = S->NbUKnots();
TColStd_Array1OfReal SUKnots (1, NbUKnots);
dis.SetColor(knotsLook);
first = S->FirstUKnotIndex();
last = S->LastUKnotIndex();
- for (i = first; i <= last; i++) {
+ for (i = first; i <= last; i++)
+ {
dis.DrawMarker (S->Value (SUKnots(i), Va), knotsForm, knotsDim);
}
Standard_Integer NbVKnots = S->NbVKnots();
dis.SetColor(knotsLook);
first = S->FirstVKnotIndex();
last = S->LastVKnotIndex();
- for (j = first; j <= last; j++) {
+ for (j = first; j <= last; j++)
+ {
dis.DrawMarker (S->Value (Ua, SVKnots(j)), knotsForm, knotsDim);
}
}
}
+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::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::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::ShowIsos (
- const Standard_Integer Nu, const Standard_Integer Nv) {
-
- knotsIsos = Standard_False;
- nbUIsos = Abs(Nu);
- nbVIsos = Abs(Nv);
+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::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;
+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 :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_BSplineSurface::Copy()const
+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;
-
}
-
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_BSplineSurface::Restore (Standard_IStream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(Geom_BSplineSurface) aGeomSurface = Handle(Geom_BSplineSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface (theStream));
+ Handle(DrawTrSurf_BSplineSurface) aDrawSurface;
+ if (!aParams.NeedKnotsIsos)
+ {
+ aDrawSurface = new DrawTrSurf_BSplineSurface (aGeomSurface,
+ aParams.NbUIsos, aParams.NbVIsos,
+ aParams.BoundsColor, aParams.IsosColor,
+ aParams.PolesColor, aParams.KnotsColor,
+ aParams.KnotsMarker, aParams.KnotsSize,
+ aParams.IsShowPoles, aParams.IsShowKnots,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
+ }
+ else
+ {
+ aDrawSurface = new DrawTrSurf_BSplineSurface (aGeomSurface,
+ aParams.BoundsColor, aParams.IsosColor,
+ aParams.PolesColor, aParams.KnotsColor,
+ aParams.KnotsMarker, aParams.KnotsSize,
+ aParams.IsShowPoles, aParams.IsShowKnots,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
+ }
+ return aDrawSurface;
+}
#ifndef _DrawTrSurf_BSplineSurface_HeaderFile
#define _DrawTrSurf_BSplineSurface_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
#include <Draw_MarkerShape.hxx>
#include <Draw_Color.hxx>
-#include <Standard_Integer.hxx>
#include <DrawTrSurf_Surface.hxx>
-#include <Standard_Real.hxx>
+
class Geom_BSplineSurface;
class Draw_Color;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_BSplineSurface;
DEFINE_STANDARD_HANDLE(DrawTrSurf_BSplineSurface, DrawTrSurf_Surface)
-
//! This class defines a drawable BSplineSurface.
//! With this class you can draw the control points and the knots
//! of the surface.
//! if you just want to sea boundaries and isoparametric curves.
class DrawTrSurf_BSplineSurface : public DrawTrSurf_Surface
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineSurface, DrawTrSurf_Surface)
+ Draw_Drawable3D_FACTORY
public:
-
//! default drawing mode.
- //! The isoparametric curves corresponding to the knots values are
- //! drawn.
+ //! 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.
- Standard_EXPORT DrawTrSurf_BSplineSurface(const Handle(Geom_BSplineSurface)& S);
-
+ //! For the discretisation 50 points are computed in each parametric direction.
+ Standard_EXPORT DrawTrSurf_BSplineSurface (const Handle(Geom_BSplineSurface)& S);
+
+ //! The isoparametric curves corresponding to the knots values are drawn.
+ Standard_EXPORT 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);
- //! The isoparametric curves corresponding to the knots values are
- //! drawn.
- Standard_EXPORT 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);
-
//! Parametric equidistant iso curves are drawn.
- Standard_EXPORT 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);
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- Standard_EXPORT void ShowPoles();
-
- Standard_EXPORT void ShowKnots();
-
+ Standard_EXPORT 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);
+
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+
+ void ShowPoles() { drawPoles = Standard_True; }
+
+ void ShowKnots() { drawKnots = Standard_True; }
+
//! change the number of isoparametric curves to be drawn.
Standard_EXPORT virtual void ShowIsos (const Standard_Integer Nu, const Standard_Integer Nv) Standard_OVERRIDE;
-
+
//! change the number of isoparametric curves to be drawn.
Standard_EXPORT void ShowKnotsIsos();
-
+
//! rub out all the isoparametric curves.
Standard_EXPORT virtual void ClearIsos() Standard_OVERRIDE;
-
- Standard_EXPORT void ClearPoles();
-
- Standard_EXPORT void ClearKnots();
+
+ void ClearPoles() { drawPoles = Standard_False; }
+
+ void ClearKnots() { drawKnots = Standard_False; }
Standard_EXPORT void FindPole (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& UIndex, Standard_Integer& VIndex) const;
Standard_EXPORT void FindUKnot (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& UIndex) const;
Standard_EXPORT void FindVKnot (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& VIndex) const;
-
- void SetPolesColor (const Draw_Color& aColor);
-
- void SetKnotsColor (const Draw_Color& aColor);
-
- void SetKnotsShape (const Draw_MarkerShape Shape);
-
- Draw_MarkerShape KnotsShape() const;
-
- Draw_Color KnotsColor() const;
-
- Draw_Color PolesColor() const;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
+ void SetPolesColor (const Draw_Color& theColor) { polesLook = theColor; }
+ void SetKnotsColor (const Draw_Color& theColor) { knotsLook = theColor; }
+ void SetKnotsShape (const Draw_MarkerShape theShape) { knotsForm = theShape; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineSurface,DrawTrSurf_Surface)
-
-protected:
+ Draw_MarkerShape KnotsShape() const { return knotsForm; }
+ Draw_Color KnotsColor() const { return knotsLook; }
+ Draw_Color PolesColor() const { return polesLook; }
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
private:
-
Standard_Boolean drawPoles;
Standard_Boolean drawKnots;
Standard_Boolean knotsIsos;
Standard_Integer knotsDim;
Draw_Color polesLook;
-
};
-
-#include <DrawTrSurf_BSplineSurface.lxx>
-
-
-
-
-
#endif // _DrawTrSurf_BSplineSurface_HeaderFile
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-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;
- }
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_BezierCurve.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
-#include <DrawTrSurf_BezierCurve.hxx>
+#include <DrawTrSurf.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <Geom_BezierCurve.hxx>
+#include <GeomTools_CurveSet.hxx>
#include <gp_Pnt2d.hxx>
-#include <Standard_Type.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve,DrawTrSurf_Curve)
-
-DrawTrSurf_BezierCurve::DrawTrSurf_BezierCurve (
- const Handle(Geom_BezierCurve)& C)
- : DrawTrSurf_Curve (C, Draw_vert, 16, 0.05, 1) {
-
- drawPoles = Standard_True;
- polesLook = Draw_rouge;
- }
-
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve, DrawTrSurf_Curve)
+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) {
+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;
+}
- 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::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));
- }
+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;
}
-
- DrawTrSurf_Curve::DrawOn(dis);
+ Index++;
}
-
-
-
- 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;
- }
-
+ Index = 0;
+}
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve::Copy()const
+Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve::Copy() const
{
- Handle(DrawTrSurf_BezierCurve) DC = new DrawTrSurf_BezierCurve
- (Handle(Geom_BezierCurve)::DownCast(curv->Copy()),
- look,polesLook,
+ Handle(DrawTrSurf_BezierCurve) DC = new DrawTrSurf_BezierCurve (Handle(Geom_BezierCurve)::DownCast(curv->Copy()),
+ look, polesLook,
drawPoles,
GetDiscretisation(),GetDeflection(),GetDrawMode());
-
return DC;
}
-
-
-
-
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve::Restore (Standard_IStream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(Geom_BezierCurve) aGeomCurve = Handle(Geom_BezierCurve)::DownCast (GeomTools_CurveSet::ReadCurve (theStream));
+ Handle(DrawTrSurf_BezierCurve) aDrawCurve = new DrawTrSurf_BezierCurve (aGeomCurve,
+ aParams.CurvColor, aParams.PolesColor, aParams.IsShowPoles,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
+ return aDrawCurve;
+}
#ifndef _DrawTrSurf_BezierCurve_HeaderFile
#define _DrawTrSurf_BezierCurve_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
#include <Draw_Color.hxx>
#include <DrawTrSurf_Curve.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Real.hxx>
+
class Geom_BezierCurve;
class Draw_Color;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_BezierCurve;
DEFINE_STANDARD_HANDLE(DrawTrSurf_BezierCurve, DrawTrSurf_Curve)
-
class DrawTrSurf_BezierCurve : public DrawTrSurf_Curve
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve, DrawTrSurf_Curve)
+ Draw_Drawable3D_FACTORY
public:
-
-
- //! creates a drawable Bezier curve from a Bezier curve of
- //! package Geom.
- Standard_EXPORT DrawTrSurf_BezierCurve(const Handle(Geom_BezierCurve)& C);
-
- Standard_EXPORT 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);
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- Standard_EXPORT void ShowPoles();
-
- Standard_EXPORT void ClearPoles();
-
+ //! creates a drawable Bezier curve from a Bezier curve of package Geom.
+ Standard_EXPORT DrawTrSurf_BezierCurve (const Handle(Geom_BezierCurve)& C);
+
+ Standard_EXPORT 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);
+
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+
+ void ShowPoles() { drawPoles = Standard_True; }
+
+ void ClearPoles() { drawPoles = Standard_False; }
//! Returns in <Index> the index of the first pole of the
//! curve projected by the Display <D> at a distance lower
//! set to 0, else index is always greater than the input
//! value of index.
Standard_EXPORT void FindPole (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& Index) const;
-
- void SetPolesColor (const Draw_Color& aColor);
-
- Draw_Color PolesColor() const;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-
-
-
-
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve,DrawTrSurf_Curve)
-
-protected:
+ void SetPolesColor (const Draw_Color& theColor) { polesLook = theColor; }
+ Draw_Color PolesColor() const { return polesLook; }
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
private:
-
Standard_Boolean drawPoles;
Draw_Color polesLook;
-
};
-
-#include <DrawTrSurf_BezierCurve.lxx>
-
-
-
-
-
#endif // _DrawTrSurf_BezierCurve_HeaderFile
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline void DrawTrSurf_BezierCurve::SetPolesColor (
- const Draw_Color& aColor) {
-
- polesLook = aColor;
- }
-
-
-
- inline Draw_Color DrawTrSurf_BezierCurve::PolesColor () const {
-
- return polesLook;
- }
-
-
-
-
-
-
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_BezierCurve2d.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
-#include <DrawTrSurf_BezierCurve2d.hxx>
+#include <DrawTrSurf.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <Geom2d_BezierCurve.hxx>
+#include <GeomTools_Curve2dSet.hxx>
#include <gp_Pnt.hxx>
-#include <Standard_Type.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve2d,DrawTrSurf_Curve2d)
-
-DrawTrSurf_BezierCurve2d::DrawTrSurf_BezierCurve2d (
- const Handle(Geom2d_BezierCurve)& C) :
- DrawTrSurf_Curve2d (C, Draw_vert, 50) {
-
- drawPoles = Standard_True;
- polesLook = Draw_rouge;
- }
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve2d, DrawTrSurf_Curve2d)
+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;
- }
-
+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
+void DrawTrSurf_BezierCurve2d::DrawOn (Draw_Display& dis) const
{
-
Handle(Geom2d_BezierCurve) C = Handle(Geom2d_BezierCurve)::DownCast(curv);
-
- if (drawPoles) {
+ if (drawPoles)
+ {
dis.SetColor(polesLook);
TColgp_Array1OfPnt2d CPoles (1, C->NbPoles());
C->Poles (CPoles);
}
DrawTrSurf_Curve2d::DrawOn(dis);
-
}
-
-
-void DrawTrSurf_BezierCurve2d::ShowPoles ()
+void DrawTrSurf_BezierCurve2d::FindPole (const Standard_Real X, const Standard_Real Y,
+ const Draw_Display& D,
+ const Standard_Real XPrec,
+ Standard_Integer& Index) const
{
- 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();
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve2d::Copy()const
+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;
}
+
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve2d::Restore (Standard_IStream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(Geom2d_BezierCurve) aGeomCurve = Handle(Geom2d_BezierCurve)::DownCast(GeomTools_Curve2dSet::ReadCurve2d (theStream));
+ Handle(DrawTrSurf_BezierCurve2d) aDrawCurve = new DrawTrSurf_BezierCurve2d (aGeomCurve,
+ aParams.CurvColor, aParams.PolesColor,
+ aParams.IsShowPoles, aParams.Discret);
+ return aDrawCurve;
+}
#ifndef _DrawTrSurf_BezierCurve2d_HeaderFile
#define _DrawTrSurf_BezierCurve2d_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
#include <Draw_Color.hxx>
#include <DrawTrSurf_Curve2d.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Real.hxx>
+
class Geom2d_BezierCurve;
class Draw_Color;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_BezierCurve2d;
DEFINE_STANDARD_HANDLE(DrawTrSurf_BezierCurve2d, DrawTrSurf_Curve2d)
-
class DrawTrSurf_BezierCurve2d : public DrawTrSurf_Curve2d
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve2d, DrawTrSurf_Curve2d)
+ Draw_Drawable3D_FACTORY
public:
-
-
- //! creates a drawable Bezier curve from a Bezier curve of
- //! package Geom2d.
- Standard_EXPORT DrawTrSurf_BezierCurve2d(const Handle(Geom2d_BezierCurve)& C);
-
- Standard_EXPORT DrawTrSurf_BezierCurve2d(const Handle(Geom2d_BezierCurve)& C, const Draw_Color& CurvColor, const Draw_Color& PolesColor, const Standard_Boolean ShowPoles, const Standard_Integer Discret);
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- Standard_EXPORT void ShowPoles();
-
- Standard_EXPORT void ClearPoles();
-
+ //! creates a drawable Bezier curve from a Bezier curve of package Geom2d.
+ Standard_EXPORT DrawTrSurf_BezierCurve2d (const Handle(Geom2d_BezierCurve)& C);
+
+ Standard_EXPORT DrawTrSurf_BezierCurve2d (const Handle(Geom2d_BezierCurve)& C,
+ const Draw_Color& CurvColor, const Draw_Color& PolesColor, const Standard_Boolean ShowPoles, const Standard_Integer Discret);
+
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+
+ void ShowPoles() { drawPoles = Standard_True; }
+
+ void ClearPoles() { drawPoles = Standard_False; }
//! Returns in <Index> the index of the first pole of the
//! curve projected by the Display <D> at a distance lower
//! set to 0, else index is always greater than the input
//! value of index.
Standard_EXPORT void FindPole (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& Index) const;
-
- void SetPolesColor (const Draw_Color& aColor);
-
- Draw_Color PolesColor() const;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-
-
-
-
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve2d,DrawTrSurf_Curve2d)
-
-protected:
+ void SetPolesColor (const Draw_Color& theColor) { polesLook = theColor; }
+ Draw_Color PolesColor() const { return polesLook; }
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
private:
-
Standard_Boolean drawPoles;
Draw_Color polesLook;
-
};
-
-#include <DrawTrSurf_BezierCurve2d.lxx>
-
-
-
-
-
#endif // _DrawTrSurf_BezierCurve2d_HeaderFile
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline void DrawTrSurf_BezierCurve2d::SetPolesColor (
- const Draw_Color& aColor) {
-
- polesLook = aColor;
- }
-
-
-
- inline Draw_Color DrawTrSurf_BezierCurve2d::PolesColor () const {
-
- return polesLook;
- }
-
-
-
-
-
-
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_BezierSurface.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
+#include <DrawTrSurf.hxx>
#include <DrawTrSurf_BezierCurve.hxx>
-#include <DrawTrSurf_BezierSurface.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <Geom_BezierSurface.hxx>
+#include <GeomTools_SurfaceSet.hxx>
#include <gp_Pnt2d.hxx>
-#include <Standard_Type.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BezierSurface,DrawTrSurf_Surface)
-
-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;
- }
-
-
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BezierSurface, DrawTrSurf_Surface)
- 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 {
+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;
+}
- Standard_Integer i,j;
- Handle(Geom_BezierSurface) S = Handle(Geom_BezierSurface)::DownCast(surf);
+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;
+}
- 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));
- }
+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));
- }
+ }
+ 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);
}
+ 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;
- }
-
+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 :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_BezierSurface::Copy()const
+Handle(Draw_Drawable3D) DrawTrSurf_BezierSurface::Copy() const
{
Handle(DrawTrSurf_BezierSurface) DS = new DrawTrSurf_BezierSurface
(Handle(Geom_BezierSurface)::DownCast(surf->Copy()),
return DS;
}
-
-
-
-
-
-
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_BezierSurface::Restore (Standard_IStream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(Geom_BezierSurface) aGeomSurface = Handle(Geom_BezierSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface (theStream));
+ Handle(DrawTrSurf_BezierSurface) aDrawSurface = new DrawTrSurf_BezierSurface (aGeomSurface,
+ aParams.NbUIsos, aParams.NbVIsos,
+ aParams.BoundsColor, aParams.IsosColor, aParams.PolesColor,
+ aParams.IsShowPoles, aParams.Discret,
+ aParams.Deflection, aParams.DrawMode);
+ return aDrawSurface;
+}
#ifndef _DrawTrSurf_BezierSurface_HeaderFile
#define _DrawTrSurf_BezierSurface_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
#include <Draw_Color.hxx>
#include <DrawTrSurf_Surface.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Real.hxx>
+
class Geom_BezierSurface;
class Draw_Color;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_BezierSurface;
DEFINE_STANDARD_HANDLE(DrawTrSurf_BezierSurface, DrawTrSurf_Surface)
-
class DrawTrSurf_BezierSurface : public DrawTrSurf_Surface
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierSurface, DrawTrSurf_Surface)
+ Draw_Drawable3D_FACTORY
public:
-
-
- //! creates a drawable Bezier curve from a Bezier curve of
- //! package Geom.
- Standard_EXPORT DrawTrSurf_BezierSurface(const Handle(Geom_BezierSurface)& S);
-
- Standard_EXPORT 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);
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- Standard_EXPORT void ShowPoles();
-
- Standard_EXPORT void ClearPoles();
-
- Standard_EXPORT void FindPole (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& UIndex, Standard_Integer& VIndex) const;
-
- void SetPolesColor (const Draw_Color& aColor);
-
- Draw_Color PolesColor() const;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
+ //! creates a drawable Bezier curve from a Bezier curve of package Geom.
+ Standard_EXPORT DrawTrSurf_BezierSurface (const Handle(Geom_BezierSurface)& S);
+ Standard_EXPORT 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);
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+ void ShowPoles() { drawPoles = Standard_True; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierSurface,DrawTrSurf_Surface)
+ void ClearPoles() { drawPoles = Standard_False; }
-protected:
+ Standard_EXPORT void FindPole (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec, Standard_Integer& UIndex, Standard_Integer& VIndex) const;
+ void SetPolesColor (const Draw_Color& theColor) { polesLook = theColor; }
+ Draw_Color PolesColor() const { return polesLook; }
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
private:
-
Standard_Boolean drawPoles;
Draw_Color polesLook;
-
};
-
-#include <DrawTrSurf_BezierSurface.lxx>
-
-
-
-
-
#endif // _DrawTrSurf_BezierSurface_HeaderFile
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline Draw_Color DrawTrSurf_BezierSurface::PolesColor () const {
-
- return polesLook;
- }
-
-
- inline void DrawTrSurf_BezierSurface::SetPolesColor (
- const Draw_Color& aColor) {
-
- polesLook = aColor;
- }
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_Curve.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
-#include <DrawTrSurf_Curve.hxx>
#include <Geom_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomLProp_CLProps.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
+#include <DrawTrSurf.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <Precision.hxx>
-#include <Standard_Type.hxx>
#include <TColStd_Array1OfReal.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Curve,DrawTrSurf_Drawable)
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Curve, DrawTrSurf_Drawable)
Standard_Real DrawTrSurf_CurveLimit = 400;
extern Standard_Boolean Draw_Bounds;
-
//=======================================================================
//function : DrawTrSurf_Curve
-//purpose :
+//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)
+ 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 :
+//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)
+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 :
+//purpose :
//=======================================================================
-
void DrawTrSurf_Curve::DrawOn (Draw_Display& dis) const
{
Standard_Real First = curv->FirstParameter();
}
}
-
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_Curve::Copy()const
+Handle(Draw_Drawable3D) DrawTrSurf_Curve::Copy() const
{
Handle(DrawTrSurf_Curve) DC = new DrawTrSurf_Curve
(Handle(Geom_Curve)::DownCast(curv->Copy()),
return DC;
}
-
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
+void DrawTrSurf_Curve::Dump (Standard_OStream& S) const
+{
+ GeomTools_CurveSet::PrintCurve (curv, S);
+}
-void DrawTrSurf_Curve::Dump(Standard_OStream& S)const
+//=======================================================================
+//function : Save
+//purpose :
+//=======================================================================
+void DrawTrSurf_Curve::Save (Standard_OStream& theOs) const
{
- GeomTools_CurveSet::PrintCurve(curv,S);
+ GeomTools_CurveSet::PrintCurve (GetCurve(), theOs, true);
}
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_Curve::Restore (Standard_IStream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(Geom_Curve) aGeomCurve = GeomTools_CurveSet::ReadCurve (theStream);
+ Handle(DrawTrSurf_Curve) aDrawCurve = new DrawTrSurf_Curve (aGeomCurve, aParams.CurvColor, aParams.Discret, aParams.Deflection, aParams.DrawMode);
+ return aDrawCurve;
+}
//=======================================================================
//function : Whatis
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Curve::Whatis(Draw_Interpretor& S)const
+void DrawTrSurf_Curve::Whatis (Draw_Interpretor& S) const
{
S << " a 3d curve";
}
#ifndef _DrawTrSurf_Curve_HeaderFile
#define _DrawTrSurf_Curve_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <Draw_Color.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Real.hxx>
#include <DrawTrSurf_Drawable.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
+
class Geom_Curve;
class Draw_Color;
class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_Curve;
DEFINE_STANDARD_HANDLE(DrawTrSurf_Curve, DrawTrSurf_Drawable)
-
//! This class defines a drawable curve in 3d space.
class DrawTrSurf_Curve : public DrawTrSurf_Drawable
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Curve, DrawTrSurf_Drawable)
+ Draw_Drawable3D_FACTORY
public:
-
-
//! creates a drawable curve from a curve of package Geom.
- Standard_EXPORT DrawTrSurf_Curve(const Handle(Geom_Curve)& C, const Standard_Boolean DispOrigin = Standard_True);
-
- Standard_EXPORT 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 = Standard_True, const Standard_Boolean DispCurvRadius = Standard_False, const Standard_Real RadiusMax = 1.0e3, const Standard_Real RatioOfRadius = 0.1);
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- Handle(Geom_Curve) GetCurve() const;
-
- void SetColor (const Draw_Color& aColor);
-
- Standard_Boolean DisplayOrigin() const;
-
- void DisplayOrigin (const Standard_Boolean V);
-
- void ShowCurvature();
-
- void ClearCurvature();
-
- void SetRadiusMax (const Standard_Real Radius);
-
- void SetRadiusRatio (const Standard_Real Ratio);
-
- Draw_Color Color() const;
-
- Standard_Real RadiusMax() const;
-
- Standard_Real RadiusRatio() const;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-
- //! For variable dump.
- Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-
- //! For variable whatis command. Set as a result the
- //! type of the variable.
- Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
+ Standard_EXPORT DrawTrSurf_Curve (const Handle(Geom_Curve)& C, const Standard_Boolean DispOrigin = Standard_True);
+ Standard_EXPORT 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 = Standard_True, const Standard_Boolean DispCurvRadius = Standard_False,
+ const Standard_Real RadiusMax = 1.0e3, const Standard_Real RatioOfRadius = 0.1);
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+ Handle(Geom_Curve) GetCurve() const { return curv; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Curve,DrawTrSurf_Drawable)
+ void SetColor (const Draw_Color& theColor) { look = theColor; }
-protected:
+ Standard_Boolean DisplayOrigin() const { return disporigin; }
+ void DisplayOrigin (const Standard_Boolean V) { disporigin = V; }
- Handle(Geom_Curve) curv;
- Draw_Color look;
- Standard_Boolean disporigin;
- Standard_Boolean dispcurvradius;
- Standard_Real radiusmax;
- Standard_Real radiusratio;
+ void ShowCurvature() { dispcurvradius = Standard_True; }
+ void ClearCurvature() { dispcurvradius = Standard_False; }
-private:
+ void SetRadiusMax (const Standard_Real theRadius) { radiusmax = theRadius; }
+ void SetRadiusRatio (const Standard_Real theRatio) { radiusratio = theRatio; }
+ Draw_Color Color() const { return look; }
+ Standard_Real RadiusMax() const { return radiusmax; }
-};
+ Standard_Real RadiusRatio() const { return radiusratio; }
+
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
+ //! For variable dump.
+ Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-#include <DrawTrSurf_Curve.lxx>
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
+ //! For variable whatis command. Set as a result the type of the variable.
+ Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
+protected:
+ Handle(Geom_Curve) curv;
+ Draw_Color look;
+ Standard_Boolean disporigin;
+ Standard_Boolean dispcurvradius;
+ Standard_Real radiusmax;
+ Standard_Real radiusratio;
+};
#endif // _DrawTrSurf_Curve_HeaderFile
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-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; }
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_Curve2d.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
#include <Draw_Drawable3D.hxx>
-#include <DrawTrSurf_Curve2d.hxx>
+#include <DrawTrSurf.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_Line.hxx>
#include <GeomTools_Curve2dSet.hxx>
#include <gp.hxx>
#include <Precision.hxx>
-#include <Standard_Type.hxx>
#include <TColStd_Array1OfReal.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Curve2d,DrawTrSurf_Drawable)
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Curve2d, DrawTrSurf_Drawable)
static Standard_Real DrawTrSurf_CurveLimit = 400;
extern Standard_Boolean Draw_Bounds;
//=======================================================================
//function : DrawTrSurf_Curve2d
-//purpose :
+//purpose :
//=======================================================================
-
DrawTrSurf_Curve2d::DrawTrSurf_Curve2d (const Handle(Geom2d_Curve)& C,
- const Standard_Boolean DispOrigin) :
- DrawTrSurf_Drawable (50)
+ const Standard_Boolean DispOrigin)
+: DrawTrSurf_Drawable (50)
{
curv = C;
look = Draw_vert;
radiusratio = 0.1;
}
-
//=======================================================================
//function : DrawTrSurf_Curve2d
-//purpose :
+//purpose :
//=======================================================================
-
DrawTrSurf_Curve2d::DrawTrSurf_Curve2d (const Handle(Geom2d_Curve)& C,
const Draw_Color& aColor,
const Standard_Integer Discret,
radiusratio = RadiusRatio;
}
-
//=======================================================================
//function : DrawOn
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Curve2d::DrawOn (Draw_Display& dis) const
+void DrawTrSurf_Curve2d::DrawOn (Draw_Display& dis) const
{
Standard_Real First = curv->FirstParameter();
}
}
-
-
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-Handle(Draw_Drawable3D) DrawTrSurf_Curve2d::Copy()const
+Handle(Draw_Drawable3D) DrawTrSurf_Curve2d::Copy() const
{
Handle(DrawTrSurf_Curve2d) DC = new DrawTrSurf_Curve2d
(Handle(Geom2d_Curve)::DownCast(curv->Copy()),
return DC;
}
-
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
+void DrawTrSurf_Curve2d::Dump (Standard_OStream& S) const
+{
+ GeomTools_Curve2dSet::PrintCurve2d (curv, S);
+}
-void DrawTrSurf_Curve2d::Dump(Standard_OStream& S) const
+//=======================================================================
+//function : Save
+//purpose :
+//=======================================================================
+void DrawTrSurf_Curve2d::Save (Standard_OStream& theStream) const
{
- GeomTools_Curve2dSet::PrintCurve2d(curv,S);
+ GeomTools_Curve2dSet::PrintCurve2d (GetCurve(), theStream, true);
}
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_Curve2d::Restore (Standard_IStream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(Geom2d_Curve) aGeomCurve = GeomTools_Curve2dSet::ReadCurve2d (theStream);
+ Handle(DrawTrSurf_Curve2d) aDrawCurve = new DrawTrSurf_Curve2d (aGeomCurve, aParams.CurvColor, aParams.Discret);
+ return aDrawCurve;
+}
//=======================================================================
//function : Whatis
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Curve2d::Whatis(Draw_Interpretor& S)const
+void DrawTrSurf_Curve2d::Whatis (Draw_Interpretor& S) const
{
S << "2d curve";
}
-
//=======================================================================
//function : Is3D
-//purpose :
+//purpose :
//=======================================================================
-
Standard_Boolean DrawTrSurf_Curve2d::Is3D() const
{
return Standard_False;
#ifndef _DrawTrSurf_Curve2d_HeaderFile
#define _DrawTrSurf_Curve2d_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <Draw_Color.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Real.hxx>
#include <DrawTrSurf_Drawable.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
+
class Geom2d_Curve;
class Draw_Color;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_Curve2d;
DEFINE_STANDARD_HANDLE(DrawTrSurf_Curve2d, DrawTrSurf_Drawable)
//! This class defines a drawable curve in 2d space.
-//! The curve is drawned in the plane XOY.
+//! The curve is drawn in the plane XOY.
class DrawTrSurf_Curve2d : public DrawTrSurf_Drawable
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Curve2d, DrawTrSurf_Drawable)
+ Draw_Drawable3D_FACTORY
public:
-
-
//! creates a drawable curve from a curve of package Geom2d.
- Standard_EXPORT DrawTrSurf_Curve2d(const Handle(Geom2d_Curve)& C, const Standard_Boolean DispOrigin = Standard_True);
-
- Standard_EXPORT DrawTrSurf_Curve2d(const Handle(Geom2d_Curve)& C, const Draw_Color& aColor, const Standard_Integer Discret, const Standard_Boolean DispOrigin = Standard_True, const Standard_Boolean DispCurvRadius = Standard_False, const Standard_Real RadiusMax = 1.0e3, const Standard_Real RatioOfRadius = 0.1);
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- Handle(Geom2d_Curve) GetCurve() const;
-
- void SetColor (const Draw_Color& aColor);
-
- void ShowCurvature();
-
- void ClearCurvature();
-
- void SetRadiusMax (const Standard_Real Radius);
-
- void SetRadiusRatio (const Standard_Real Ratio);
-
- Draw_Color Color() const;
-
- Standard_Real RadiusMax() const;
-
- Standard_Real RadiusRatio() const;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-
- //! For variable dump.
- Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-
- //! Returns False.
- Standard_EXPORT virtual Standard_Boolean Is3D() const Standard_OVERRIDE;
-
- //! For variable whatis command. Set as a result the
- //! type of the variable.
- Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
+ Standard_EXPORT DrawTrSurf_Curve2d (const Handle(Geom2d_Curve)& C, const Standard_Boolean DispOrigin = Standard_True);
+ Standard_EXPORT DrawTrSurf_Curve2d (const Handle(Geom2d_Curve)& C,
+ const Draw_Color& aColor, const Standard_Integer Discret,
+ const Standard_Boolean DispOrigin = Standard_True, const Standard_Boolean DispCurvRadius = Standard_False,
+ const Standard_Real RadiusMax = 1.0e3, const Standard_Real RatioOfRadius = 0.1);
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+ Handle(Geom2d_Curve) GetCurve() const { return curv; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Curve2d,DrawTrSurf_Drawable)
+ void SetColor (const Draw_Color& theColor) { look = theColor; }
-protected:
+ void ShowCurvature() { dispcurvradius = Standard_True; }
+ void ClearCurvature() { dispcurvradius = Standard_False; }
- Handle(Geom2d_Curve) curv;
- Draw_Color look;
- Standard_Boolean disporigin;
- Standard_Boolean dispcurvradius;
- Standard_Real radiusmax;
- Standard_Real radiusratio;
+ void SetRadiusMax (const Standard_Real theRadius) { radiusmax = theRadius; }
+ void SetRadiusRatio (const Standard_Real theRatio) { radiusratio = theRatio; }
-private:
+ Draw_Color Color() const { return look; }
+ Standard_Real RadiusMax() const { return radiusmax; }
+ Standard_Real RadiusRatio() const { return radiusratio; }
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-};
+ //! For variable dump.
+ Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
-#include <DrawTrSurf_Curve2d.lxx>
+ //! Returns False.
+ Standard_EXPORT virtual Standard_Boolean Is3D() const Standard_OVERRIDE;
+ //! For variable whatis command. Set as a result the type of the variable.
+ Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
+protected:
+ Handle(Geom2d_Curve) curv;
+ Draw_Color look;
+ Standard_Boolean disporigin;
+ Standard_Boolean dispcurvradius;
+ Standard_Real radiusmax;
+ Standard_Real radiusratio;
+};
#endif // _DrawTrSurf_Curve2d_HeaderFile
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-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; }
-
-
#ifndef _DrawTrSurf_Drawable_HeaderFile
#define _DrawTrSurf_Drawable_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Integer.hxx>
-#include <Standard_Real.hxx>
#include <Draw_Drawable3D.hxx>
#include <GeomAbs_IsoType.hxx>
+
class Adaptor2d_Curve2d;
-class Draw_Display;
class Adaptor3d_Curve;
class Adaptor3d_IsoCurve;
-
-class DrawTrSurf_Drawable;
DEFINE_STANDARD_HANDLE(DrawTrSurf_Drawable, Draw_Drawable3D)
//! this class adds to the Drawable3D methods to
//! is stored in this class.
class DrawTrSurf_Drawable : public Draw_Drawable3D
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Drawable, Draw_Drawable3D)
public:
-
//! Draw a polygon of the curve on the Display
Standard_EXPORT void DrawCurve2dOn (Adaptor2d_Curve2d& C, Draw_Display& D) const;
//! this is defined only to tell C++ not to complain
//! about inheriting a pure virtual method.
Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE = 0;
-
- void SetDiscretisation (const Standard_Integer Discret);
-
- Standard_Integer GetDiscretisation() const;
-
- void SetDeflection (const Standard_Real Deflection);
-
- Standard_Real GetDeflection() const;
-
- void SetDrawMode (const Standard_Integer DrawMode);
-
- Standard_Integer GetDrawMode() const;
+ void SetDiscretisation (const Standard_Integer theDiscret) { myDiscret = theDiscret; }
+
+ Standard_Integer GetDiscretisation() const { return myDiscret; }
+ void SetDeflection (const Standard_Real theDeflection) { myDeflection = theDeflection; }
+ Standard_Real GetDeflection() const { return myDeflection; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Drawable,Draw_Drawable3D)
+ void SetDrawMode (const Standard_Integer theDrawMode) { myDrawMode = theDrawMode; }
+
+ Standard_Integer GetDrawMode() const { return myDrawMode; }
protected:
-
//! set the number of points on a curve at creation.
Standard_EXPORT DrawTrSurf_Drawable(const Standard_Integer discret, const Standard_Real deflection = 0.01, const Standard_Integer DrawMode = 0);
-
-
private:
-
Standard_Integer myDrawMode;
Standard_Integer myDiscret;
Standard_Real myDeflection;
-
};
-
-#include <DrawTrSurf_Drawable.lxx>
-
-
-
-
-
#endif // _DrawTrSurf_Drawable_HeaderFile
+++ /dev/null
-// Created on: 1991-07-16
-// Created by: Christophe MARION
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-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;
- }
-
-
-
-
-
-
-
--- /dev/null
+// Copyright (c) 2021 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef DrawTrSurf_Params_HeaderFile
+#define DrawTrSurf_Params_HeaderFile
+
+#include <Draw_Color.hxx>
+#include <Draw_MarkerShape.hxx>
+
+//! DrawTrSurf parameters.
+struct DrawTrSurf_Params
+{
+public:
+ Draw_Color PntColor;
+ Draw_Color CurvColor;
+ Draw_Color BoundsColor;
+ Draw_Color IsosColor;
+ Draw_Color PolesColor;
+ Draw_Color KnotsColor;
+
+ Draw_MarkerShape PntMarker;
+ Draw_MarkerShape KnotsMarker;
+ Standard_Boolean IsShowPoles;
+ Standard_Boolean IsShowKnots;
+ Standard_Boolean NeedKnotsIsos;
+ Standard_Real Deflection;
+ Standard_Integer KnotsSize;
+ Standard_Integer Discret;
+ Standard_Integer DrawMode;
+ Standard_Integer NbUIsos;
+ Standard_Integer NbVIsos;
+
+ DrawTrSurf_Params()
+ : PntColor (Draw_rouge),
+ CurvColor (Draw_jaune),
+ BoundsColor(Draw_vert),
+ IsosColor (Draw_bleu),
+ PolesColor (Draw_rouge),
+ KnotsColor (Draw_violet),
+ PntMarker (Draw_Plus),
+ KnotsMarker(Draw_Losange),
+ IsShowPoles (true),
+ IsShowKnots (true),
+ NeedKnotsIsos (true),
+ Deflection (0.01),
+ KnotsSize (5),
+ Discret (30),
+ DrawMode(0),
+ NbUIsos (10),
+ NbVIsos (10)
+ {}
+
+};
+
+#endif
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_Point.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
-#include <DrawTrSurf_Point.hxx>
+#include <DrawTrSurf.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
-#include <Standard_Stream.hxx>
-#include <Standard_Type.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Point,Draw_Drawable3D)
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Point, Draw_Drawable3D)
//=======================================================================
//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)
+//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)
+//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 :
+//purpose :
//=======================================================================
-
Standard_Boolean DrawTrSurf_Point::Is3D() const
{
return is3D;
//=======================================================================
//function : DrawOn
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Point::DrawOn(Draw_Display& dis) const
+void DrawTrSurf_Point::DrawOn (Draw_Display& dis) const
{
dis.SetColor(myColor);
if (is3D)
//=======================================================================
//function : Point
-//purpose :
-//=======================================================================
-
-gp_Pnt DrawTrSurf_Point::Point() const
-{
- return myPoint;
-}
-
-//=======================================================================
-//function : Point
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Point::Point(const gp_Pnt& P)
+void DrawTrSurf_Point::Point (const gp_Pnt& P)
{
myPoint = P;
is3D = Standard_True;
//=======================================================================
//function : Point2d
-//purpose :
+//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 :
+//purpose :
//=======================================================================
-
Handle(Draw_Drawable3D) DrawTrSurf_Point::Copy() const
{
Handle(DrawTrSurf_Point) P;
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Point::Dump(Standard_OStream& S) const
+void DrawTrSurf_Point::Dump (Standard_OStream& S) const
{
#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
std::ios::fmtflags F = S.flags();
}
//=======================================================================
-//function : Whatis
-//purpose :
+//function : Save
+//purpose :
+//=======================================================================
+void DrawTrSurf_Point::Save (Standard_OStream& theStream) const
+{
+#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
+ std::ios::fmtflags aFlags = theStream.flags();
+ theStream.setf (std::ios::scientific, std::ios::floatfield);
+ theStream.precision (15);
+#else
+ long aForm = theStream.setf (std::ios::scientific);
+ std::streamsize aPrec = theStream.precision (15);
+#endif
+ if (is3D)
+ {
+ theStream << "1 " << myPoint.X() << " " << myPoint.Y() << " " << myPoint.Z() << "\n";
+ }
+ else
+ {
+ theStream << "0 " << myPoint.X() << " " << myPoint.Y() << "\n";
+ }
+#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
+ theStream.setf (aFlags);
+#else
+ theStream.setf (aForm);
+ theStream.precision (aPrec);
+#endif
+}
+
//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_Point::Restore (Standard_IStream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Standard_Integer is3d = 0;
+ theStream >> is3d;
+ Standard_Real x,y,z = 0.0;
+ if (is3d)
+ {
+ theStream >> x >> y >> z;
+ }
+ else
+ {
+ theStream >> x >> y;
+ }
+ Handle(DrawTrSurf_Point) aDrawPoint;
+ if (is3d)
+ {
+ aDrawPoint = new DrawTrSurf_Point (gp_Pnt (x, y, z), aParams.PntMarker, aParams.PntColor);
+ }
+ else
+ {
+ aDrawPoint = new DrawTrSurf_Point (gp_Pnt2d (x, y), aParams.PntMarker, aParams.PntColor);
+ }
+ return aDrawPoint;
+}
-void DrawTrSurf_Point::Whatis(Draw_Interpretor& S) const
+//=======================================================================
+//function : Whatis
+//purpose :
+//=======================================================================
+void DrawTrSurf_Point::Whatis (Draw_Interpretor& S) const
{
- S << "point";
+ S << "point";
}
#ifndef _DrawTrSurf_Point_HeaderFile
#define _DrawTrSurf_Point_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <gp_Pnt.hxx>
-#include <Standard_Boolean.hxx>
#include <Draw_MarkerShape.hxx>
#include <Draw_Color.hxx>
#include <Draw_Drawable3D.hxx>
-#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
-class gp_Pnt;
+
class Draw_Color;
class gp_Pnt2d;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_Point;
DEFINE_STANDARD_HANDLE(DrawTrSurf_Point, Draw_Drawable3D)
//! A drawable point.
class DrawTrSurf_Point : public Draw_Drawable3D
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Point, Draw_Drawable3D)
+ Draw_Drawable3D_FACTORY
public:
-
- Standard_EXPORT DrawTrSurf_Point(const gp_Pnt& P, const Draw_MarkerShape Shape, const Draw_Color& Col);
-
- Standard_EXPORT DrawTrSurf_Point(const gp_Pnt2d& P, const Draw_MarkerShape Shape, const Draw_Color& Col);
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
+ Standard_EXPORT DrawTrSurf_Point (const gp_Pnt& P, const Draw_MarkerShape Shape, const Draw_Color& Col);
+
+ Standard_EXPORT DrawTrSurf_Point (const gp_Pnt2d& P, const Draw_MarkerShape Shape, const Draw_Color& Col);
+
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+
//! Is a 3D object. (Default True).
Standard_EXPORT virtual Standard_Boolean Is3D() const Standard_OVERRIDE;
-
- Standard_EXPORT gp_Pnt Point() const;
-
+
+ gp_Pnt Point() const { return myPoint; }
+
Standard_EXPORT void Point (const gp_Pnt& P);
-
- Standard_EXPORT gp_Pnt2d Point2d() const;
-
+
+ gp_Pnt2d Point2d() const { return gp_Pnt2d(myPoint.X(), myPoint.Y()); }
+
Standard_EXPORT void Point2d (const gp_Pnt2d& P);
-
- Standard_EXPORT void Color (const Draw_Color& aColor);
-
- Standard_EXPORT Draw_Color Color() const;
-
- Standard_EXPORT void Shape (const Draw_MarkerShape S);
-
- Standard_EXPORT Draw_MarkerShape Shape() const;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-
- //! For variable dump.
- Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-
- //! For variable whatis command.
- Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
+ void Color (const Draw_Color& theColor) { myColor = theColor; }
+ Draw_Color Color() const { return myColor; }
+ void Shape (const Draw_MarkerShape theS) { myShape = theS; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Point,Draw_Drawable3D)
+ Draw_MarkerShape Shape() const { return myShape; }
-protected:
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
+ //! For variable dump.
+ Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
+ //! For variable whatis command.
+ Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
private:
-
gp_Pnt myPoint;
Standard_Boolean is3D;
Draw_MarkerShape myShape;
Draw_Color myColor;
-
};
-
-
-
-
-
-
#endif // _DrawTrSurf_Point_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_Polygon2D.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
#include <Draw_MarkerShape.hxx>
-#include <DrawTrSurf_Polygon2D.hxx>
#include <Poly.hxx>
#include <Poly_Polygon2D.hxx>
-#include <Standard_Type.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Polygon2D,Draw_Drawable2D)
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Polygon2D, Draw_Drawable2D)
//=======================================================================
//function : DrawTrSurf_Polygon2D
-//purpose :
-//=======================================================================
-DrawTrSurf_Polygon2D::DrawTrSurf_Polygon2D(const Handle(Poly_Polygon2D)& P):
- myPolygon2D(P),
- myNodes(Standard_False)
-{
-}
-
-//=======================================================================
-//function : Polygon2D
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Poly_Polygon2D) DrawTrSurf_Polygon2D::Polygon2D() const
+DrawTrSurf_Polygon2D::DrawTrSurf_Polygon2D(const Handle(Poly_Polygon2D)& P)
+: myPolygon2D(P),
+ myNodes(Standard_False)
{
- 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 :
+//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++) {
+ 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++) {
+ if (myNodes)
+ {
+ for (Standard_Integer i = Points.Lower(); i <= Points.Upper(); i++)
+ {
dis.DrawMarker(Points(i), Draw_X);
}
}
-
}
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_Polygon2D::Copy() const
+Handle(Draw_Drawable3D) DrawTrSurf_Polygon2D::Copy() const
{
return new DrawTrSurf_Polygon2D(myPolygon2D);
}
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Polygon2D::Dump(Standard_OStream& S) const
+void DrawTrSurf_Polygon2D::Dump (Standard_OStream& S) const
{
Poly::Dump(myPolygon2D, S);
}
//=======================================================================
-//function : Whatis
-//purpose :
+//function : Save
+//purpose :
+//=======================================================================
+void DrawTrSurf_Polygon2D::Save (Standard_OStream& theStream) const
+{
+#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
+ std::ios::fmtflags aFlags = theStream.flags();
+ theStream.setf (std::ios::scientific, std::ios::floatfield);
+ theStream.precision (15);
+#else
+ long aForm = theStream.setf (std::ios::scientific);
+ std::streamsize aPrec = theStream.precision (15);
+#endif
+ Poly::Write (myPolygon2D, theStream);
+#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
+ theStream.setf (aFlags);
+#else
+ theStream.setf (aForm);
+ theStream.precision (aPrec);
+#endif
+}
+
+//=======================================================================
+//function : Restore
+//purpose :
//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_Polygon2D::Restore (Standard_IStream& theStream)
+{
+ return new DrawTrSurf_Polygon2D (Poly::ReadPolygon2D (theStream));
+}
-void DrawTrSurf_Polygon2D::Whatis(Draw_Interpretor& I) const
+//=======================================================================
+//function : Whatis
+//purpose :
+//=======================================================================
+void DrawTrSurf_Polygon2D::Whatis (Draw_Interpretor& I) const
{
I << "polygon2D";
}
-
#ifndef _DrawTrSurf_Polygon2D_HeaderFile
#define _DrawTrSurf_Polygon2D_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
#include <Draw_Drawable2D.hxx>
-#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
-class Poly_Polygon2D;
-class Draw_Display;
-class Draw_Drawable3D;
+class Poly_Polygon2D;
-class DrawTrSurf_Polygon2D;
DEFINE_STANDARD_HANDLE(DrawTrSurf_Polygon2D, Draw_Drawable2D)
//! Used to display a 2d polygon.
-//!
//! Optional display of nodes.
class DrawTrSurf_Polygon2D : public Draw_Drawable2D
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Polygon2D, Draw_Drawable2D)
+ Draw_Drawable3D_FACTORY
public:
-
- Standard_EXPORT DrawTrSurf_Polygon2D(const Handle(Poly_Polygon2D)& P);
-
- Standard_EXPORT Handle(Poly_Polygon2D) Polygon2D() const;
-
- Standard_EXPORT void ShowNodes (const Standard_Boolean B);
-
- Standard_EXPORT Standard_Boolean ShowNodes() const;
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-
- //! For variable dump.
- Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-
- //! For variable whatis command. Set as a result the
- //! type of the variable.
- Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
+ Standard_EXPORT DrawTrSurf_Polygon2D (const Handle(Poly_Polygon2D)& P);
+ Handle(Poly_Polygon2D) Polygon2D() const { return myPolygon2D; }
+ void ShowNodes (const Standard_Boolean theB) { myNodes = theB; }
+ Standard_Boolean ShowNodes() const { return myNodes; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Polygon2D,Draw_Drawable2D)
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-protected:
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
+ //! For variable dump.
+ Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
+ //! For variable whatis command. Set as a result the type of the variable.
+ Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
private:
-
Handle(Poly_Polygon2D) myPolygon2D;
Standard_Boolean myNodes;
-
};
-
-
-
-
-
-
#endif // _DrawTrSurf_Polygon2D_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_Polygon3D.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
#include <Draw_MarkerShape.hxx>
-#include <DrawTrSurf_Polygon3D.hxx>
#include <Poly.hxx>
#include <Poly_Polygon3D.hxx>
-#include <Standard_Type.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Polygon3D,Draw_Drawable3D)
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Polygon3D, Draw_Drawable3D)
//=======================================================================
//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 :
+//purpose :
//=======================================================================
-
-Standard_Boolean DrawTrSurf_Polygon3D::ShowNodes() const
+DrawTrSurf_Polygon3D::DrawTrSurf_Polygon3D (const Handle(Poly_Polygon3D)& P)
+: myPolygon3D(P),
+ myNodes(Standard_False)
{
- return myNodes;
+ //
}
//=======================================================================
//function : DrawOn
-//purpose :
+//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++) {
+ 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++) {
+ if (myNodes)
+ {
+ for (Standard_Integer i = Points.Lower(); i <= Points.Upper(); i++)
+ {
dis.DrawMarker(Points(i), Draw_X);
}
}
-
}
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_Polygon3D::Copy() const
+Handle(Draw_Drawable3D) DrawTrSurf_Polygon3D::Copy() const
{
return new DrawTrSurf_Polygon3D(myPolygon3D);
}
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Polygon3D::Dump(Standard_OStream& S) const
+void DrawTrSurf_Polygon3D::Dump (Standard_OStream& S) const
{
Poly::Dump(myPolygon3D, S);
}
//=======================================================================
-//function : Whatis
-//purpose :
+//function : Save
+//purpose :
//=======================================================================
+void DrawTrSurf_Polygon3D::Save (Standard_OStream& theStream) const
+{
+#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
+ std::ios::fmtflags aFlags = theStream.flags();
+ theStream.setf (std::ios::scientific,std::ios::floatfield);
+ theStream.precision (15);
+#else
+ long aForm = theStream.setf (std::ios::scientific);
+ std::streamsize aPrec = theStream.precision (15);
+#endif
+ Poly::Write (myPolygon3D, theStream);
+#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
+ theStream.setf (aFlags);
+#else
+ theStream.setf (aForm);
+ theStream.precision (aPrec);
+#endif
+}
-void DrawTrSurf_Polygon3D::Whatis(Draw_Interpretor& I) const
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_Polygon3D::Restore (Standard_IStream& theStream)
{
- I << "polygon3D";
+ return new DrawTrSurf_Polygon3D (Poly::ReadPolygon3D (theStream));
}
+//=======================================================================
+//function : Whatis
+//purpose :
+//=======================================================================
+void DrawTrSurf_Polygon3D::Whatis (Draw_Interpretor& I) const
+{
+ I << "polygon3D";
+}
#ifndef _DrawTrSurf_Polygon3D_HeaderFile
#define _DrawTrSurf_Polygon3D_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
#include <Draw_Drawable3D.hxx>
-#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
-class Poly_Polygon3D;
-class Draw_Display;
-class Draw_Drawable3D;
+class Poly_Polygon3D;
-class DrawTrSurf_Polygon3D;
DEFINE_STANDARD_HANDLE(DrawTrSurf_Polygon3D, Draw_Drawable3D)
//! Used to display a 3d polygon.
-//!
//! Optional display of nodes.
class DrawTrSurf_Polygon3D : public Draw_Drawable3D
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Polygon3D, Draw_Drawable3D)
+ Draw_Drawable3D_FACTORY
public:
-
- Standard_EXPORT DrawTrSurf_Polygon3D(const Handle(Poly_Polygon3D)& P);
-
- Standard_EXPORT Handle(Poly_Polygon3D) Polygon3D() const;
-
- Standard_EXPORT void ShowNodes (const Standard_Boolean B);
-
- Standard_EXPORT Standard_Boolean ShowNodes() const;
-
+ Standard_EXPORT DrawTrSurf_Polygon3D (const Handle(Poly_Polygon3D)& P);
+
+ Handle(Poly_Polygon3D) Polygon3D() const { return myPolygon3D; }
+
+ void ShowNodes (const Standard_Boolean theB) { myNodes = theB; }
+
+ Standard_Boolean ShowNodes() const { return myNodes; }
+
Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
//! For variable copy.
//! For variable dump.
Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-
+
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
+
//! For variable whatis command. Set as a result the
//! type of the variable.
Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
-
-
-
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Polygon3D,Draw_Drawable3D)
-
-protected:
-
-
-
-
private:
-
Handle(Poly_Polygon3D) myPolygon3D;
Standard_Boolean myNodes;
-
};
-
-
-
-
-
-
#endif // _DrawTrSurf_Polygon3D_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_Surface.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
-#include <DrawTrSurf_Surface.hxx>
+#include <DrawTrSurf.hxx>
+#include <DrawTrSurf_Params.hxx>
#include <Geom_Surface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomTools_SurfaceSet.hxx>
#include <Precision.hxx>
-#include <Standard_Type.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Surface,DrawTrSurf_Drawable)
+IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Surface, DrawTrSurf_Drawable)
Standard_Real DrawTrSurf_SurfaceLimit = 400;
-
//=======================================================================
//function : DrawTrSurf_Surface
-//purpose :
+//purpose :
//=======================================================================
-
DrawTrSurf_Surface::DrawTrSurf_Surface (const Handle(Geom_Surface)& S)
: DrawTrSurf_Drawable (16, 0.01, 1)
{
nbVIsos = 1;
}
-
-
-
//=======================================================================
//function : DrawTrSurf_Surface
-//purpose :
+//purpose :
//=======================================================================
-
DrawTrSurf_Surface::DrawTrSurf_Surface
(const Handle(Geom_Surface)& S, const Standard_Integer Nu,
const Standard_Integer Nv,
nbVIsos = Abs(Nv);
}
-
-
//=======================================================================
//function : DrawOn
-//purpose :
+//purpose :
//=======================================================================
-
void DrawTrSurf_Surface::DrawOn (Draw_Display& dis) const
{
DrawOn(dis,Standard_True);
//=======================================================================
//function : DrawOn
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Surface::DrawOn (Draw_Display& dis,
- const Standard_Boolean Iso) const
+void DrawTrSurf_Surface::DrawOn (Draw_Display& dis, const Standard_Boolean Iso) const
{
Standard_Real UFirst, ULast, VFirst, VLast;
surf->Bounds (UFirst, ULast, VFirst, VLast);
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 :
+//purpose :
//=======================================================================
-
void DrawTrSurf_Surface::ClearIsos ()
{
nbUIsos = 0;
nbVIsos = 0;
}
-
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_Surface::Copy() const
+Handle(Draw_Drawable3D) DrawTrSurf_Surface::Copy() const
{
Handle(DrawTrSurf_Surface) DS = new DrawTrSurf_Surface
(Handle(Geom_Surface)::DownCast(surf->Copy()),
return DS;
}
-
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Surface::Dump(Standard_OStream& S)const
+void DrawTrSurf_Surface::Dump (Standard_OStream& S) const
{
GeomTools_SurfaceSet::PrintSurface(surf,S);
}
+//=======================================================================
+//function : Save
+//purpose :
+//=======================================================================
+void DrawTrSurf_Surface::Save (Standard_OStream& theStream) const
+{
+ GeomTools_SurfaceSet::PrintSurface (surf, theStream, true);
+}
//=======================================================================
-//function : Whatis
-//purpose :
+//function : Restore
+//purpose :
//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_Surface::Restore (std::istream& theStream)
+{
+ const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
+ Handle(Geom_Surface) aGeomSurface = GeomTools_SurfaceSet::ReadSurface (theStream);
+ Handle(DrawTrSurf_Surface) aDrawSurface = new DrawTrSurf_Surface (aGeomSurface,
+ aParams.NbUIsos, aParams.NbVIsos,
+ aParams.BoundsColor, aParams.IsosColor,
+ aParams.Discret, aParams.Deflection, aParams.DrawMode);
+ return aDrawSurface;
+}
-void DrawTrSurf_Surface::Whatis(Draw_Interpretor& S)const
+//=======================================================================
+//function : Whatis
+//purpose :
+//=======================================================================
+void DrawTrSurf_Surface::Whatis (Draw_Interpretor& S) const
{
S << "a surface";
}
#ifndef _DrawTrSurf_Surface_HeaderFile
#define _DrawTrSurf_Surface_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <Draw_Color.hxx>
-#include <Standard_Integer.hxx>
#include <DrawTrSurf_Drawable.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
+
class Geom_Surface;
class Draw_Color;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class DrawTrSurf_Surface;
DEFINE_STANDARD_HANDLE(DrawTrSurf_Surface, DrawTrSurf_Drawable)
//! This class defines a drawable surface.
-//! With this class you can draw a general surface from
-//! package Geom.
+//! With this class you can draw a general surface from package Geom.
class DrawTrSurf_Surface : public DrawTrSurf_Drawable
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Surface, DrawTrSurf_Drawable)
+ Draw_Drawable3D_FACTORY
public:
-
//! 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.
- Standard_EXPORT DrawTrSurf_Surface(const Handle(Geom_Surface)& S);
-
- Standard_EXPORT 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);
-
- Draw_Color BoundsColor() const;
-
+ //! For the discretisation 50 points are computed in each parametric direction.
+ Standard_EXPORT DrawTrSurf_Surface (const Handle(Geom_Surface)& S);
+
+ Standard_EXPORT 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);
+
+ Draw_Color BoundsColor() const { return boundsLook; }
+
//! rub out all the isoparametric curves.
Standard_EXPORT virtual void ClearIsos();
-
+
Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
//! Iso = True : Draw the isos, the boundaries, the UVMarker.
//! Iso = False: Only Draw the boundary and the UVMarker.
Standard_EXPORT void DrawOn (Draw_Display& dis, const Standard_Boolean Iso) const;
- Handle(Geom_Surface) GetSurface() const;
-
- Draw_Color IsosColor() const;
-
- void NbIsos (Standard_Integer& Nu, Standard_Integer& Nb) const;
-
- void SetBoundsColor (const Draw_Color& aColor);
-
- void SetIsosColor (const Draw_Color& aColor);
-
+ Handle(Geom_Surface) GetSurface() const { return surf; }
+
+ Draw_Color IsosColor() const { return isosLook; }
+
+ void NbIsos (Standard_Integer& theNU, Standard_Integer& theNV) const
+ {
+ theNU = nbUIsos;
+ theNV = nbVIsos;
+ }
+
+ void SetBoundsColor (const Draw_Color& theColor) { boundsLook = theColor; }
+
+ void SetIsosColor (const Draw_Color& theColor) { isosLook = theColor; }
+
//! change the number of isoparametric curves to be drawn.
- Standard_EXPORT virtual void ShowIsos (const Standard_Integer Nu, const Standard_Integer Nv);
-
+ virtual void ShowIsos (const Standard_Integer theNu, const Standard_Integer theNv)
+ {
+ nbUIsos = Abs(theNu);
+ nbVIsos = Abs(theNv);
+ }
+
//! For variable copy.
Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-
+
//! For variable dump.
Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-
- //! For variable whatis command.
- Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
-
-
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Surface,DrawTrSurf_Drawable)
+ //! For variable whatis command.
+ Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
protected:
-
Handle(Geom_Surface) surf;
Draw_Color boundsLook;
Draw_Color isosLook;
Standard_Integer nbUIsos;
Standard_Integer nbVIsos;
-
-private:
-
-
-
-
};
-
-#include <DrawTrSurf_Surface.lxx>
-
-
-
-
-
#endif // _DrawTrSurf_Surface_HeaderFile
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-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;
- }
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <DrawTrSurf_Triangulation.hxx>
#include <Draw_Color.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
-#include <DrawTrSurf_Triangulation.hxx>
#include <gp_Pnt.hxx>
#include <Poly.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Poly_Connect.hxx>
#include <Poly_Triangle.hxx>
#include <Poly_Triangulation.hxx>
-#include <Standard_Type.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <stdio.h>
+
IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Triangulation,Draw_Drawable3D)
//=======================================================================
//function : DrawTrSurf_Triangulation
-//purpose :
+//purpose :
//=======================================================================
-DrawTrSurf_Triangulation::DrawTrSurf_Triangulation
-(const Handle(Poly_Triangulation)& T):
- myTriangulation(T),
- myNodes(Standard_False),
- myTriangles(Standard_False)
+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);
}
}
-//=======================================================================
-//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 :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
+void DrawTrSurf_Triangulation::DrawOn (Draw_Display& dis) const
{
// Display the edges
Standard_Integer i,n;
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) DrawTrSurf_Triangulation::Copy() const
+Handle(Draw_Drawable3D) DrawTrSurf_Triangulation::Copy() const
{
return new DrawTrSurf_Triangulation(myTriangulation);
}
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-
-void DrawTrSurf_Triangulation::Dump(Standard_OStream& S) const
+void DrawTrSurf_Triangulation::Dump (Standard_OStream& S) const
{
Poly::Dump(myTriangulation,S);
}
//=======================================================================
-//function : Whatis
-//purpose :
+//function : Save
+//purpose :
//=======================================================================
+void DrawTrSurf_Triangulation::Save (Standard_OStream& theStream) const
+{
+#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
+ std::ios::fmtflags aFlags = theStream.flags();
+ theStream.setf (std::ios::scientific, std::ios::floatfield);
+ theStream.precision (15);
+#else
+ long aForm = theStream.setf (std::ios::scientific);
+ std::streamsize aPrec = theStream.precision (15);
+#endif
+ Poly::Write (myTriangulation, theStream);
+#if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
+ theStream.setf (aFlags);
+#else
+ theStream.setf (aForm);
+ theStream.precision (aPrec);
+#endif
+}
-void DrawTrSurf_Triangulation::Whatis(Draw_Interpretor& I) const
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) DrawTrSurf_Triangulation::Restore (Standard_IStream& theStream)
{
- I << "triangulation";
+ return new DrawTrSurf_Triangulation (Poly::ReadTriangulation (theStream));
}
+//=======================================================================
+//function : Whatis
+//purpose :
+//=======================================================================
+void DrawTrSurf_Triangulation::Whatis (Draw_Interpretor& I) const
+{
+ I << "triangulation";
+}
#ifndef _DrawTrSurf_Triangulation_HeaderFile
#define _DrawTrSurf_Triangulation_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <TColStd_HArray1OfInteger.hxx>
-#include <Standard_Boolean.hxx>
#include <Draw_Drawable3D.hxx>
-#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
-class Poly_Triangulation;
-class Draw_Display;
-class Draw_Drawable3D;
+class Poly_Triangulation;
-class DrawTrSurf_Triangulation;
DEFINE_STANDARD_HANDLE(DrawTrSurf_Triangulation, Draw_Drawable3D)
//! Used to display a triangulation.
//! Optional display of triangles and nodes indices.
class DrawTrSurf_Triangulation : public Draw_Drawable3D
{
-
+ DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Triangulation, Draw_Drawable3D)
+ Draw_Drawable3D_FACTORY
public:
-
-
- Standard_EXPORT DrawTrSurf_Triangulation(const Handle(Poly_Triangulation)& T);
-
- Standard_EXPORT Handle(Poly_Triangulation) Triangulation() const;
-
- Standard_EXPORT void ShowNodes (const Standard_Boolean B);
-
- Standard_EXPORT Standard_Boolean ShowNodes() const;
-
- Standard_EXPORT void ShowTriangles (const Standard_Boolean B);
-
- Standard_EXPORT Standard_Boolean ShowTriangles() const;
-
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- //! For variable copy.
- Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-
- //! For variable dump.
- Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
- //! For variable whatis command. Set as a result the
- //! type of the variable.
- Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
+ Standard_EXPORT DrawTrSurf_Triangulation (const Handle(Poly_Triangulation)& T);
+ Handle(Poly_Triangulation) Triangulation() const { return myTriangulation; }
+ void ShowNodes (const Standard_Boolean theB) { myNodes = theB; }
+ Standard_Boolean ShowNodes() const { return myNodes; }
- DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Triangulation,Draw_Drawable3D)
+ void ShowTriangles (const Standard_Boolean theB) { myTriangles = theB; }
-protected:
+ Standard_Boolean ShowTriangles() const { return myTriangles; }
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+ //! For variable copy.
+ Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
+ //! For variable dump.
+ Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-private:
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
+ //! For variable whatis command. Set as a result the type of the variable.
+ Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
+
+private:
Handle(Poly_Triangulation) myTriangulation;
Handle(TColStd_HArray1OfInteger) myInternals;
Standard_Boolean myNodes;
Standard_Boolean myTriangles;
-
};
-
-
-
-
-
-
#endif // _DrawTrSurf_Triangulation_HeaderFile
DrawTrSurf.hxx
DrawTrSurf_BezierCurve.cxx
DrawTrSurf_BezierCurve.hxx
-DrawTrSurf_BezierCurve.lxx
DrawTrSurf_BezierCurve2d.cxx
DrawTrSurf_BezierCurve2d.hxx
-DrawTrSurf_BezierCurve2d.lxx
DrawTrSurf_BezierSurface.cxx
DrawTrSurf_BezierSurface.hxx
-DrawTrSurf_BezierSurface.lxx
DrawTrSurf_BSplineCurve.cxx
DrawTrSurf_BSplineCurve.hxx
-DrawTrSurf_BSplineCurve.lxx
DrawTrSurf_BSplineCurve2d.cxx
DrawTrSurf_BSplineCurve2d.hxx
-DrawTrSurf_BSplineCurve2d.lxx
DrawTrSurf_BSplineSurface.cxx
DrawTrSurf_BSplineSurface.hxx
-DrawTrSurf_BSplineSurface.lxx
DrawTrSurf_Curve.cxx
DrawTrSurf_Curve.hxx
-DrawTrSurf_Curve.lxx
DrawTrSurf_Curve2d.cxx
DrawTrSurf_Curve2d.hxx
-DrawTrSurf_Curve2d.lxx
DrawTrSurf_Debug.cxx
DrawTrSurf_Drawable.cxx
DrawTrSurf_Drawable.hxx
-DrawTrSurf_Drawable.lxx
+DrawTrSurf_Params.hxx
DrawTrSurf_Point.cxx
DrawTrSurf_Point.hxx
DrawTrSurf_Polygon2D.cxx
DrawTrSurf_Polygon3D.hxx
DrawTrSurf_Surface.cxx
DrawTrSurf_Surface.hxx
-DrawTrSurf_Surface.lxx
DrawTrSurf_Triangulation.cxx
DrawTrSurf_Triangulation.hxx
DrawTrSurf_Triangulation2D.cxx
HLRTest_OutLiner.lxx
HLRTest_Projector.cxx
HLRTest_Projector.hxx
-HLRTest_Projector.lxx
HLRTest_ShapeData.cxx
HLRTest_ShapeData.hxx
HLRTest_ShapeData.lxx
void HLRTest::Commands (Draw_Interpretor& theCommands)
{
+ // Register save/restore tool
+ HLRTest_Projector::RegisterFactory();
+
const char* g = "ADVALGOS HLR Commands";
theCommands.Add("hprj" ,"hprj name [view-id = 1]" ,__FILE__,hprj,g);
hider = new HLRBRep_Algo();
}
-
-//=======================================================================
-//function : save and restore projector
-//purpose :
-//=======================================================================
-
-static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
-{
- return d->IsInstance(STANDARD_TYPE(HLRTest_Projector));
-}
-
-//=======================================================================
-//function : ssave
-//purpose :
-//=======================================================================
-
-static void ssave (const Handle(Draw_Drawable3D)&d, std::ostream& OS)
-{
- Handle(HLRTest_Projector) HP =
- Handle(HLRTest_Projector)::DownCast(d);
-
- const HLRAlgo_Projector& P = HP->Projector();
- OS << (P.Perspective() ? "1" : "0") << "\n";
- if (P.Perspective())
- OS << P.Focus() << "\n";
-
- gp_Trsf T = P.Transformation();
- gp_XYZ V = T.TranslationPart();
- gp_Mat M = T.VectorialPart();
-
- OS << M(1,1) << " ";
- OS << M(1,2) << " ";
- OS << M(1,3) << " ";
- OS << V.Coord(1) << " ";
- OS << "\n";
- OS << M(2,1) << " ";
- OS << M(2,2) << " ";
- OS << M(2,3) << " ";
- OS << V.Coord(2) << " ";
- OS << "\n";
- OS << M(3,1) << " ";
- OS << M(3,2) << " ";
- OS << M(3,3) << " ";
- OS << V.Coord(3) << " ";
- OS << "\n";
-
-}
-
-//=======================================================================
-//function : srestore
-//purpose :
-//=======================================================================
-
-static Handle(Draw_Drawable3D) srestore (std::istream& IS)
-{
- Standard_Boolean pers;
- IS >> pers;
- Standard_Real focus = 1;
- if (pers) IS >> focus;
-
- gp_Trsf T;
- Standard_Real V1[3],V2[3],V3[3];
- Standard_Real V[3];
-
- IS >> V1[0] >> V1[1] >> V1[2] >> V[0];
- IS >> V2[0] >> V2[1] >> V2[2] >> V[1];
- IS >> V3[0] >> V3[1] >> V3[2] >> V[2];
-
- gp_Dir D1(V1[0],V1[1],V1[2]);
- gp_Dir D2(V2[0],V2[1],V2[2]);
- gp_Dir D3(V3[0],V3[1],V3[2]);
- gp_Ax3 axes(gp_Pnt(0,0,0),D3,D1);
- D3.Cross(D1);
- if (D3.Dot(D2) < 0) axes.YReverse();
- T.SetTransformation(axes);
-
- T.SetTranslationPart(gp_Vec(V[0],V[1],V[2]));
-
- HLRAlgo_Projector P(T,pers,focus);
- Handle(HLRTest_Projector) HP = new HLRTest_Projector(P);
- return HP;
-}
-
-//=======================================================================
-//function : ssr
-//purpose :
-//=======================================================================
-
-static Draw_SaveAndRestore ssr("HLRTest_Projector",stest,ssave,srestore);
-
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <HLRTest_Projector.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
+#include <gp_Ax3.hxx>
#include <HLRAlgo_Projector.hxx>
-#include <HLRTest_Projector.hxx>
-#include <Standard_Stream.hxx>
-#include <Standard_Type.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(HLRTest_Projector,Draw_Drawable3D)
+IMPLEMENT_STANDARD_RTTIEXT(HLRTest_Projector, Draw_Drawable3D)
//=======================================================================
//function : HLRTest_Projector
-//purpose :
+//purpose :
//=======================================================================
-HLRTest_Projector::HLRTest_Projector (const HLRAlgo_Projector& P) :
-myProjector(P)
+HLRTest_Projector::HLRTest_Projector (const HLRAlgo_Projector& P)
+: myProjector(P)
{
+ //
}
//=======================================================================
//function : DrawOn
-//purpose :
+//purpose :
//=======================================================================
-
-void HLRTest_Projector::DrawOn (Draw_Display&) const
+void HLRTest_Projector::DrawOn (Draw_Display&) const
{
+ //
}
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) HLRTest_Projector::Copy () const
+Handle(Draw_Drawable3D) HLRTest_Projector::Copy() const
{
return new HLRTest_Projector(myProjector);
}
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-
-void HLRTest_Projector::Dump (Standard_OStream& S) const
+void HLRTest_Projector::Dump (Standard_OStream& S) const
{
S << "Projector : \n";
if (myProjector.Perspective())
}
//=======================================================================
-//function : Whatis
-//purpose :
+//function : Save
+//purpose :
//=======================================================================
+void HLRTest_Projector::Save (Standard_OStream& theStream) const
+{
+ theStream << (myProjector.Perspective() ? "1" : "0") << "\n";
+ if (myProjector.Perspective())
+ {
+ theStream << myProjector.Focus() << "\n";
+ }
+
+ const gp_Trsf aTransformation = myProjector.Transformation();
+ const gp_XYZ aTranslationVector = aTransformation.TranslationPart();
+ const gp_Mat aMatrix = aTransformation.VectorialPart();
-void HLRTest_Projector::Whatis (Draw_Interpretor& I) const
+ theStream << aMatrix(1, 1) << " ";
+ theStream << aMatrix(1, 2) << " ";
+ theStream << aMatrix(1, 3) << " ";
+ theStream << aTranslationVector.Coord (1) << " ";
+ theStream << "\n";
+ theStream << aMatrix(2, 1) << " ";
+ theStream << aMatrix(2, 2) << " ";
+ theStream << aMatrix(2, 3) << " ";
+ theStream << aTranslationVector.Coord (2) << " ";
+ theStream << "\n";
+ theStream << aMatrix(3, 1) << " ";
+ theStream << aMatrix(3, 2) << " ";
+ theStream << aMatrix(3, 3) << " ";
+ theStream << aTranslationVector.Coord (3) << " ";
+ theStream << "\n";
+}
+
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) HLRTest_Projector::Restore (Standard_IStream& theStream)
{
- I << "projector";
+ Standard_Boolean aPerspective = false;
+ Standard_Real aFocus = 1.0;
+ Standard_Real aDirVect1[3], aDirVect2[3], aDirVect3[3];
+ Standard_Real aTranslationVector[3];
+ theStream >> aPerspective;
+ if (aPerspective)
+ {
+ theStream >> aFocus;
+ }
+ theStream >> aDirVect1[0] >> aDirVect1[1] >> aDirVect1[2] >> aTranslationVector[0];
+ theStream >> aDirVect2[0] >> aDirVect2[1] >> aDirVect2[2] >> aTranslationVector[1];
+ theStream >> aDirVect3[0] >> aDirVect3[1] >> aDirVect3[2] >> aTranslationVector[2];
+
+ gp_Dir aDir1 (aDirVect1[0], aDirVect1[1], aDirVect1[2]);
+ gp_Dir aDir2 (aDirVect2[0], aDirVect2[1], aDirVect2[2]);
+ gp_Dir aDir3 (aDirVect3[0], aDirVect3[1], aDirVect3[2]);
+ gp_Ax3 anAxis (gp_Pnt (0, 0, 0), aDir3, aDir1);
+ aDir3.Cross (aDir1);
+ if (aDir3.Dot (aDir2) < 0.0)
+ {
+ anAxis.YReverse();
+ }
+ gp_Trsf aTransformation;
+ aTransformation.SetTransformation (anAxis);
+ aTransformation.SetTranslationPart (gp_Vec (aTranslationVector[0], aTranslationVector[1], aTranslationVector[2]));
+
+ HLRAlgo_Projector anAlgoProtector (aTransformation, aPerspective, aFocus);
+ Handle(HLRTest_Projector) aTestProjector = new HLRTest_Projector (anAlgoProtector);
+ return aTestProjector;
}
+//=======================================================================
+//function : Whatis
+//purpose :
+//=======================================================================
+void HLRTest_Projector::Whatis (Draw_Interpretor& I) const
+{
+ I << "projector";
+}
#ifndef _HLRTest_Projector_HeaderFile
#define _HLRTest_Projector_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <HLRAlgo_Projector.hxx>
#include <Draw_Drawable3D.hxx>
-#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
-class HLRAlgo_Projector;
-class Draw_Display;
-class Draw_Drawable3D;
-
-class HLRTest_Projector;
DEFINE_STANDARD_HANDLE(HLRTest_Projector, Draw_Drawable3D)
//! Draw Variable Projector to test.
class HLRTest_Projector : public Draw_Drawable3D
{
-
+ DEFINE_STANDARD_RTTIEXT(HLRTest_Projector, Draw_Drawable3D)
+ Draw_Drawable3D_FACTORY
public:
-
Standard_EXPORT HLRTest_Projector(const HLRAlgo_Projector& P);
-
- const HLRAlgo_Projector& Projector() const;
-
- //! Does nothhing,
- Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
+
+ const HLRAlgo_Projector& Projector() const { return myProjector; }
+
+ //! Does nothing,
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+
//! For variable copy.
Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
-
+
//! For variable dump.
Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
-
+
+ //! Save drawable into stream.
+ Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
+
//! For variable whatis command. Set as a result the
//! type of the variable.
Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
-
-
-
- DEFINE_STANDARD_RTTIEXT(HLRTest_Projector,Draw_Drawable3D)
-
-protected:
-
-
-
-
private:
-
HLRAlgo_Projector myProjector;
-
};
-
-#include <HLRTest_Projector.lxx>
-
-
-
-
-
#endif // _HLRTest_Projector_HeaderFile
+++ /dev/null
-// Created on: 1995-04-05
-// Created by: Christophe MARION
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : Projector
-//purpose :
-//=======================================================================
-
-inline const HLRAlgo_Projector & HLRTest_Projector::Projector () const
-{
- return myProjector;
-}
-