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

0030493: Draw, ViewerTest - minor improvement of vdisplay command

vdisplay no longer opens BREP file in case if Draw variable is not found.

Draw::Get() unused Complain argument has been removed from method definition.
Added Draw::GetExisting() and DBRep::GetExisting() commands never performing picking.
This commit is contained in:
kgv
2019-02-12 12:22:26 +03:00
committed by apn
parent d95f5ce102
commit 1c8fc6bee2
18 changed files with 234 additions and 282 deletions

View File

@@ -1291,42 +1291,43 @@ void DBRep::Set(const Standard_CString Name, const TopoDS_Shape& S)
Draw::Set(Name,D);
}
//=======================================================================
//function : Get
//purpose :
//function : getShape
//purpose :
//=======================================================================
TopoDS_Shape DBRep::Get(Standard_CString& name,
const TopAbs_ShapeEnum typ,
const Standard_Boolean complain)
TopoDS_Shape DBRep::getShape (Standard_CString& theName,
TopAbs_ShapeEnum theType,
Standard_Boolean theToComplain)
{
Standard_Boolean pick = name[0] == '.';
TopoDS_Shape S;
Handle(DBRep_DrawableShape) D;
Handle(Draw_Drawable3D) DD = Draw::Get(name,complain);
if (!DD.IsNull())
D = Handle(DBRep_DrawableShape)::DownCast(DD);
if (!D.IsNull()) {
S = D->Shape();
if (typ != TopAbs_SHAPE) {
if (typ != S.ShapeType()) {
// try to find prom pick
if (pick) {
Standard_Real u,v;
DBRep_DrawableShape::LastPick(S,u,v);
}
}
if (typ != S.ShapeType()) {
if (complain) {
cout << name << " is not a ";
TopAbs::Print(typ,cout);
cout << " but a ";
TopAbs::Print(S.ShapeType(),cout);
cout << endl;
}
S = TopoDS_Shape();
}
}
const Standard_Boolean toPick = theName[0] == '.';
Handle(DBRep_DrawableShape) aDrawable = Handle(DBRep_DrawableShape)::DownCast (Draw::Get (theName));
if (aDrawable.IsNull())
{
return TopoDS_Shape();
}
return S;
TopoDS_Shape aShape = aDrawable->Shape();
if (theType != TopAbs_SHAPE
&& theType != aShape.ShapeType()
&& toPick)
{
// try to find prom pick
Standard_Real u, v;
DBRep_DrawableShape::LastPick (aShape, u, v);
}
if (theType != TopAbs_SHAPE
&& theType != aShape.ShapeType())
{
if (theToComplain)
{
std::cout << theName << " is not a ";
TopAbs::Print (theType, std::cout);
std::cout << " but a ";
TopAbs::Print (aShape.ShapeType(), std::cout);
std::cout << std::endl;
}
return TopoDS_Shape();
}
return aShape;
}
static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc, const char **argv)

View File

@@ -17,23 +17,10 @@
#ifndef _DBRep_HeaderFile
#define _DBRep_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_CString.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <Standard_Boolean.hxx>
#include <Draw_Interpretor.hxx>
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
class TopoDS_Shape;
class DBRep_Edge;
class DBRep_Face;
class DBRep_HideData;
class DBRep_DrawableShape;
class DBRep_IsoBuilder;
#include <TCollection_AsciiString.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Shape.hxx>
//! Used to display BRep objects using the DrawTrSurf
//! package.
@@ -54,12 +41,46 @@ public:
//! variable if already set.
Standard_EXPORT static void Set (const Standard_CString Name, const TopoDS_Shape& S);
//! Returns the shape in the variable <Name>. Returns
//! a null shape if the variable is not set or not of
//! the given <Typ>. If <Complain> is True a message
//! is printed on cout if the variable is not set.
Standard_EXPORT static TopoDS_Shape Get (Standard_CString& Name, const TopAbs_ShapeEnum Typ = TopAbs_SHAPE, const Standard_Boolean Complain = Standard_False);
//! Returns the shape in the variable.
//! @param theName [in] [out] variable name, or "." to pick up shape interactively (the picked name will be returned then)
//! @param theType [in] shape type filter; function will return NULL if shape has different type
//! @param theToComplain [in] when TRUE, prints a message on cout if the variable is not set
static TopoDS_Shape Get (Standard_CString& theName, TopAbs_ShapeEnum theType = TopAbs_SHAPE, Standard_Boolean theToComplain = Standard_False)
{
return getShape (theName, theType, theToComplain);
}
//! Returns the shape in the variable.
//! @param theName [in] [out] variable name, or "." to pick up shape interactively (the picked name will be returned then)
//! @param theType [in] shape type filter; function will return NULL if shape has different type
//! @param theToComplain [in] when TRUE, prints a message on cout if the variable is not set
static TopoDS_Shape Get (TCollection_AsciiString& theName, TopAbs_ShapeEnum theType = TopAbs_SHAPE, Standard_Boolean theToComplain = Standard_False)
{
Standard_CString aNamePtr = theName.ToCString();
TopoDS_Shape aShape = getShape (aNamePtr, theType, theToComplain);
if (aNamePtr != theName.ToCString())
{
theName = aNamePtr;
}
return aShape;
}
//! Returns the shape in the variable.
//! @param theName [in] variable name
//! @param theType [in] shape type filter; function will return NULL if shape has different type
//! @param theToComplain [in] when TRUE, prints a message on cout if the variable is not set
static TopoDS_Shape GetExisting (const TCollection_AsciiString& theName, TopAbs_ShapeEnum theType = TopAbs_SHAPE, Standard_Boolean theToComplain = Standard_False)
{
if (theName.Length() == 1
&& theName.Value (1) == '.')
{
return TopoDS_Shape();
}
Standard_CString aNamePtr = theName.ToCString();
return getShape (aNamePtr, theType, theToComplain);
}
//! Defines the basic commands.
Standard_EXPORT static void BasicCommands (Draw_Interpretor& theCommands);
@@ -86,32 +107,16 @@ public:
//! get progress indicator
Standard_EXPORT static Standard_Integer Discretisation();
protected:
private:
friend class DBRep_Edge;
friend class DBRep_Face;
friend class DBRep_HideData;
friend class DBRep_DrawableShape;
friend class DBRep_IsoBuilder;
//! Returns the shape in the variable.
//! @param theName [in] [out] variable name, or "." to pick up shape interactively (the picked name will be returned then)
//! @param theType [in] shape type filter; function will return NULL if shape has different type
//! @param theToComplain [in] when TRUE, prints a message on cout if the variable is not set
Standard_EXPORT static TopoDS_Shape getShape (Standard_CString& theName,
TopAbs_ShapeEnum theType,
Standard_Boolean theToComplain);
};
#endif // _DBRep_HeaderFile