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.
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();
+ }
+
+ 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 S;
+ return aShape;
}
static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc, const char **argv)
#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.
//! 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);
//! 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
Handle(TDF_Data)& DF,
const Standard_Boolean Complain)
{
- Handle(Standard_Transient) t = Draw::Get(Name, Complain);
+ Handle(Standard_Transient) t = Draw::Get (Name);
Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (t);
//Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (Draw::Get(Name, Complain));
if (!DDF.IsNull()) {
{
if (n < 2) return 1;
- Handle(DDF_Browser) browser =
- Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
+ Handle(DDF_Browser) browser = Handle(DDF_Browser)::DownCast (Draw::GetExisting (a[1]));
+ if (browser.IsNull())
+ {
+ std::cout << "Syntax error: browser '" << a[1] << "' not found\n";
+ return 1;
+ }
TDF_Label lab;
if (n == 3) TDF_Tool::Label(browser->Data(),a[2],lab);
{
if (n < 3) return 1;
- Handle(DDF_Browser) browser =
- Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
+ Handle(DDF_Browser) browser = Handle(DDF_Browser)::DownCast (Draw::GetExisting (a[1]));
+ if (browser.IsNull())
+ {
+ std::cout << "Syntax error: browser '" << a[1] << "' not found\n";
+ return 1;
+ }
TDF_Label lab;
TDF_Tool::Label(browser->Data(),a[2],lab);
{
if (n < 3) return 1;
- Handle(DDF_Browser) browser =
- Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
+ Handle(DDF_Browser) browser = Handle(DDF_Browser)::DownCast (Draw::GetExisting (a[1]));
+ if (browser.IsNull())
+ {
+ std::cout << "Syntax error: browser '" << a[1] << "' not found\n";
+ return 1;
+ }
const Standard_Integer index = Draw::Atoi(a[2]);
TCollection_AsciiString list = browser->OpenAttribute(index);
//purpose : Rmdraw (name)
//=======================================================================
-static Standard_Integer DDataStd_Rmdraw (Draw_Interpretor& di,
+static Standard_Integer DDataStd_Rmdraw (Draw_Interpretor& ,
Standard_Integer nb,
const char** arg)
{
- if (nb == 2) {
- Handle(Draw_Drawable3D) D3D;
- D3D = Draw::Get(arg[1],Standard_True);
- if (!D3D.IsNull()) dout.RemoveDrawable(D3D);
+ if (nb != 2)
+ {
+ std::cout << "Syntax error: wrong number of arguments\n";
+ return 1;
+ }
+
+ if (Handle(Draw_Drawable3D) D3D = Draw::Get (arg[1]))
+ {
+ dout.RemoveDrawable (D3D);
return 0;
}
- di << "DDataStd_Rmdraw : Error : not done\n";
- return 1;
+ else
+ {
+ std::cout << "Syntax error: variable '" << arg[1] << "' not found\n";
+ return 1;
+ }
}
//=======================================================================
{
if (n < 2) return 1;
- Handle(DDataStd_TreeBrowser) browser =
- Handle(DDataStd_TreeBrowser)::DownCast (Draw::Get(a[1], Standard_True));
+ Handle(DDataStd_TreeBrowser) browser = Handle(DDataStd_TreeBrowser)::DownCast (Draw::GetExisting (a[1]));
+ if (browser.IsNull())
+ {
+ std::cout << "Syntax error: browser '" << a[1] << "' not found\n";
+ return 1;
+ }
TDF_Label lab;
if (n == 3) TDF_Tool::Label(browser->Label().Data(),a[2],lab);
Handle(TDocStd_Document)& DOC,
const Standard_Boolean Complain)
{
-
- Handle(Draw_Drawable3D) D = Draw::Get(Name,Standard_False);
-
- Handle(DDocStd_DrawDocument) DD = Handle(DDocStd_DrawDocument)::DownCast (D);
+ Handle(DDocStd_DrawDocument) DD = Handle(DDocStd_DrawDocument)::DownCast (Draw::GetExisting (Name));
if (DD.IsNull()) {
if (Complain) cout << Name << " is not a Document" << endl;
return Standard_False;
aDocApp->Close (aDoc);
- Handle(Draw_Drawable3D) aDrawable = Draw::Get (aDocName, Standard_False);
- dout.RemoveDrawable (aDrawable);
+ if (Handle(Draw_Drawable3D) aDrawable = Draw::GetExisting (aDocName))
+ {
+ dout.RemoveDrawable (aDrawable);
+ }
Draw::Set (theArgVec[1], Handle(Draw_Drawable3D)());
return 0;
}
static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- if ( argc <4 ) { di << "ERROR: Too few args\n"; return 0; }
- Handle(DDF_Browser) browser =
- Handle(DDF_Browser)::DownCast (Draw::Get(argv[1], Standard_True));
- if ( browser.IsNull() ) { di << "ERROR: Not a browser: " << argv[1] << "\n"; return 0; }
+ if ( argc < 4 ) { di << "ERROR: Too few args\n"; return 1; }
+ Handle(DDF_Browser) browser = Handle(DDF_Browser)::DownCast (Draw::GetExisting (argv[1]));
+ if ( browser.IsNull() ) { std::cout << "Syntax error: Not a browser: " << argv[1] << "\n"; return 1; }
TDF_Label lab;
TDF_Tool::Label(browser->Data(),argv[2],lab);
- if ( lab.IsNull() ) { di << "ERROR: label is Null: " << argv[2] << "\n"; return 0; }
+ if ( lab.IsNull() ) { di << "Syntax error: label is Null: " << argv[2] << "\n"; return 1; }
Standard_Integer num = Draw::Atoi ( argv[3] );
TDF_AttributeIterator itr(lab,Standard_False);
for (Standard_Integer i=1; itr.More() && i < num; i++) itr.Next();
- if ( ! itr.More() ) { di << "ERROR: Attribute #" << num << " not found\n"; return 0; }
+ if ( ! itr.More() ) { di << "Syntax error: Attribute #" << num << " not found\n"; return 1; }
const Handle(TDF_Attribute)& att = itr.Value();
if ( att->IsKind(STANDARD_TYPE(TDataStd_TreeNode)) )
DNaming_DataMapIteratorOfDataMapOfShapeOfName itrn(aDMapOfShapeOfName);
for(;itrn.More();itrn.Next()) {
TCollection_AsciiString name = itrn.Value();
- const TopoDS_Shape& Result = TR.Copied(itrn.Key());
+ const TopoDS_Shape Result = TR.Copied(itrn.Key());
DBRep::Set(name.ToCString(), Result);
di.AppendElement(name.ToCString());
}
//! Returns main DRAW interpretor.
Standard_EXPORT static Draw_Interpretor& GetInterpretor();
-
- //! Returns a variable value. Null if the variable
- //! does not exist, a warning is printed if Complain
- //! is True.
- //!
- //! The name "." does a graphic selection. If the
- //! selection is a variable <Name> is overwritten with
- //! the name of the variable.
- Standard_EXPORT static Handle(Draw_Drawable3D) Get (Standard_CString& Name, const Standard_Boolean Complain = Standard_True);
-
+
+ //! Returns a variable value.
+ //! The name "." does a graphic selection; in this case theName will be is overwritten with the name of the variable.
+ static Handle(Draw_Drawable3D) Get (Standard_CString& theName) { return getDrawable (theName, Standard_True); }
+
+ //! Returns a variable value.
+ static Handle(Draw_Drawable3D) GetExisting (const Standard_CString& theName)
+ {
+ Standard_CString aName = theName;
+ return getDrawable (aName, Standard_False);
+ }
+
//! Gets a numeric variable. Returns True if the
//! variable exist.
Standard_EXPORT static Standard_Boolean Get (const Standard_CString Name, Standard_Real& val);
//! Defines Draw unit commands
Standard_EXPORT static void UnitCommands (Draw_Interpretor& I);
-
-
-
protected:
-
-
-
+ //! Returns a variable value.
+ //! @param theName [in] [out] variable name, or "." to activate picking
+ //! @param theToAllowPick [in] when TRUE, "." name will activate picking
+ Standard_EXPORT static Handle(Draw_Drawable3D) getDrawable (Standard_CString& theName,
+ Standard_Boolean theToAllowPick);
private:
-
-
-
friend class Draw_Drawable3D;
friend class Draw_Drawable2D;
friend class Draw_Color;
static Standard_Integer isdraw(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n != 2) return 1;
- Handle(Draw_Drawable3D) D = Draw::Get(a[1],Standard_False);
+ Handle(Draw_Drawable3D) D = Draw::Get (a[1]);
if (D.IsNull())
di << "0";
else
Standard_Integer isprot(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n != 2) return 1;
- Handle(Draw_Drawable3D) D = Draw::Get(a[1],Standard_False);
+ Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
if (D.IsNull())
di << "0";
else {
//function : Set
//purpose :
//=======================================================================
-void Draw::Set(const Standard_CString Name, const Standard_Real val)
+void Draw::Set(const Standard_CString theName, const Standard_Real theValue)
{
- if ((Name[0] == '.') && (Name[1] == '\0')) return;
- Standard_CString aName = Name;
- Handle(Draw_Drawable3D) D = Draw::Get(aName,Standard_False);
- Handle(Draw_Number) N;
- if (!D.IsNull()) {
- N = Handle(Draw_Number)::DownCast(D);
- }
- if (N.IsNull()) {
- N = new Draw_Number(val);
- Draw::Set(aName,N,Standard_False);
+ if (Handle(Draw_Number) aNumber = Handle(Draw_Number)::DownCast (Draw::GetExisting (theName)))
+ {
+ aNumber->Value (theValue);
}
else
- N->Value(val);
+ {
+ aNumber = new Draw_Number (theValue);
+ Draw::Set (theName, aNumber, Standard_False);
+ }
}
+
//=======================================================================
-//function : Get
-//purpose :
+//function : getDrawable
+//purpose :
//=======================================================================
-Handle(Draw_Drawable3D) Draw::Get(Standard_CString& name,
- const Standard_Boolean )
+Handle(Draw_Drawable3D) Draw::getDrawable (Standard_CString& theName,
+ Standard_Boolean theToAllowPick)
{
- Standard_Boolean pick = ((name[0] == '.') && (name[1] == '\0'));
- Handle(Draw_Drawable3D) D;
- if (pick) {
- cout << "Pick an object" << endl;
- dout.Select(p_id,p_X,p_Y,p_b);
- dout.Pick(p_id,p_X,p_Y,5,D,0);
- if (!D.IsNull()) {
- if (D->Name()) {
- name = p_Name = D->Name();
- //p_Name = (char *)D->Name();
- }
- }
+ const Standard_Boolean toPick = ((theName[0] == '.') && (theName[1] == '\0'));
+ if (!toPick)
+ {
+ ClientData aCD = Tcl_VarTraceInfo (Draw::GetInterpretor().Interp(), theName, TCL_TRACE_UNSETS | TCL_TRACE_WRITES, tracevar, NULL);
+ Handle(Draw_Drawable3D) aDrawable = reinterpret_cast<Draw_Drawable3D*>(aCD);
+ return theVariables.Contains (aDrawable)
+ ? aDrawable
+ : Handle(Draw_Drawable3D)();
}
- else {
- ClientData aCD =
- Tcl_VarTraceInfo(Draw::GetInterpretor().Interp(),name,TCL_TRACE_UNSETS | TCL_TRACE_WRITES,
- tracevar, NULL);
- D = reinterpret_cast<Draw_Drawable3D*>(aCD);
- if (!theVariables.Contains(D))
- D.Nullify();
-#if 0
- if (D.IsNull() && complain)
- cout <<name<<" does not exist"<<endl;
-#endif
+ else if (!theToAllowPick)
+ {
+ return Handle(Draw_Drawable3D)();
}
- return D;
+
+ std::cout << "Pick an object" << std::endl;
+ Handle(Draw_Drawable3D) aDrawable;
+ dout.Select (p_id, p_X, p_Y, p_b);
+ dout.Pick (p_id, p_X, p_Y, 5, aDrawable, 0);
+ if (!aDrawable.IsNull()
+ && aDrawable->Name() != NULL)
+ {
+ theName = p_Name = aDrawable->Name();
+ }
+ return aDrawable;
}
//=======================================================================
//function : Get
//purpose :
//=======================================================================
-Standard_Boolean Draw::Get(const Standard_CString name,
- Standard_Real& val)
+Standard_Boolean Draw::Get (const Standard_CString theName,
+ Standard_Real& theValue)
{
- if ((name[0] == '.') && (name[1] == '\0')) {
- return Standard_False;
- }
- Standard_CString aName = name;
- Handle(Draw_Drawable3D) D = Draw::Get(aName,Standard_False);
- if (!D.IsNull()) {
- Handle(Draw_Number) N = Handle(Draw_Number)::DownCast(D);
- if (!N.IsNull()) {
- val = N->Value();
- return Standard_True;
- }
+ if (Handle(Draw_Number) aNumber = Handle(Draw_Number)::DownCast (Draw::GetExisting (theName)))
+ {
+ theValue = aNumber->Value();
+ return Standard_True;
}
return Standard_False;
}
Handle(TDocStd_Application) A = DDocStd::GetApplication();
A->Close(D);
- Handle(Draw_Drawable3D) DD = Draw::Get(argv[1],Standard_False);
- dout.RemoveDrawable (DD);
+ if (Handle(Draw_Drawable3D) DD = Draw::GetExisting (argv[1]))
+ {
+ dout.RemoveDrawable (DD);
+ }
Handle(TDocStd_Document) OwnerD2 = Owner->GetDocument();
if (OwnerD2.IsNull()) {
}
TopoDS_Shape aShape = DBRep::Get(argv[1]);
Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
-// Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
aContext->Display (anIO, Standard_True);
return 0;
DNaming_DataMapIteratorOfDataMapOfShapeOfName itrn(aDMapOfShapeOfName);
for(;itrn.More();itrn.Next()) {
TCollection_AsciiString name = itrn.Value();
- const TopoDS_Shape& Result = TR.Copied(itrn.Key());
+ const TopoDS_Shape Result = TR.Copied(itrn.Key());
DBRep::Set(name.ToCString(), Result);
di.AppendElement(name.ToCString());
}
return Standard_True;
}
-//==============================================================================
-//function : GetShapeFromName
-//purpose : Compute an Shape from a draw variable or a file name
-//==============================================================================
-
-static TopoDS_Shape GetShapeFromName(const char* name)
-{
- TopoDS_Shape S = DBRep::Get(name);
-
- if ( S.IsNull() ) {
- BRep_Builder aBuilder;
- BRepTools::Read( S, name, aBuilder);
- }
-
- return S;
-}
-
-//==============================================================================
-//function : GetAISShapeFromName
-//purpose : Compute an AIS_Shape from a draw variable or a file name
-//==============================================================================
-Handle(AIS_Shape) GetAISShapeFromName(const char* name)
-{
- Handle(AIS_InteractiveObject) aPrs;
- if (GetMapOfAIS().Find2 (name, aPrs)
- && !aPrs.IsNull())
- {
- if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aPrs))
- {
- return aShapePrs;
- }
-
- std::cout << "an Object which is not an AIS_Shape already has this name!!!\n";
- return Handle(AIS_Shape)();
- }
-
- TopoDS_Shape aShape = GetShapeFromName (name);
- if (!aShape.IsNull())
- {
- return new AIS_Shape(aShape);
- }
- return Handle(AIS_Shape)();
-}
-
-
//==============================================================================
//function : Clear
//purpose : Remove all the object from the viewer
// Display interactive objects
for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter)
{
- const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value(anIter);
+ const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value (anIter);
Handle(AIS_InteractiveObject) aShape;
if (!GetMapOfAIS().Find2 (aName, aShape))
{
// create the AIS_Shape from a name
- aShape = GetAISShapeFromName (aName.ToCString());
- if (!aShape.IsNull())
+ TopoDS_Shape aDrawShape = DBRep::GetExisting (aName);
+ if (!aDrawShape.IsNull())
{
+ aShape = new AIS_Shape (aDrawShape);
if (isMutable != -1)
{
aShape->SetMutable (isMutable == 1);
}
else
{
- theDI << "Display " << aName.ToCString() << "\n";
+ theDI << "Display " << aName << "\n";
// update the Shape in the AIS_Shape
- TopoDS_Shape aNewShape = GetShapeFromName (aName.ToCString());
+ TopoDS_Shape aNewShape = DBRep::GetExisting (aName);
Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aShape);
if (!aShapePrs.IsNull())
{
TCollection_AsciiString name=argv[1];
GetMapOfAIS().Find2(name, TheAisIO);
if (TheAisIO.IsNull())
- TheAisIO=GetAISShapeFromName(name.ToCString());
+ {
+ TopoDS_Shape aDrawShape = DBRep::GetExisting (name);
+ if (!aDrawShape.IsNull())
+ {
+ TheAisIO = new AIS_Shape (aDrawShape);
+ }
+ }
if (HaveToSet)
TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True);
}
// Parse input arguments
- TColStd_SequenceOfAsciiString aNamesOfIO;
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{
const TCollection_AsciiString aName = theArgVec[anArgIter];
- aNamesOfIO.Append (aName);
- }
-
- if (aNamesOfIO.IsEmpty())
- {
- std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
- return 1;
- }
-
- // Load selection of interactive objects
- for (Standard_Integer anIter = 1; anIter <= aNamesOfIO.Length(); ++anIter)
- {
- const TCollection_AsciiString& aName = aNamesOfIO.Value (anIter);
-
Handle(AIS_InteractiveObject) aShape;
if (!GetMapOfAIS().Find2 (aName, aShape))
{
- aShape = GetAISShapeFromName (aName.ToCString());
- }
-
- if (!aShape.IsNull())
- {
- if (!GetMapOfAIS().IsBound2 (aName))
+ TopoDS_Shape aDrawShape = DBRep::GetExisting (aName);
+ if (!aDrawShape.IsNull())
{
+ aShape = new AIS_Shape (aDrawShape);
GetMapOfAIS().Bind (aShape, aName);
}
-
- aCtx->Load (aShape, -1);
- aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True);
}
- }
+ if (aShape.IsNull())
+ {
+ std::cout << "Syntax error: presentation '" << aName << "' not found\n";
+ return 1;
+ }
+ aCtx->Load (aShape, -1);
+ aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True);
+ }
return 0;
}
Standard_Real anAngle = 0;
Standard_Boolean Rev = Standard_False;
Standard_Integer rev = 0;
- TopoDS_Shape Solid = GetShapeFromName(argv[1]);
- TopoDS_Shape face = GetShapeFromName(argv[2]);
+ TopoDS_Shape Solid = DBRep::Get (argv[1]);
+ TopoDS_Shape face = DBRep::Get (argv[2]);
TopoDS_Face Face = TopoDS::Face(face);
- TopoDS_Shape Plane = GetShapeFromName(argv[3]);
+ TopoDS_Shape Plane = DBRep::Get (argv[3]);
if (Plane.IsNull ()) {
di << "TEST : Plane is NULL\n";
return 1;
# include <stdio.h>
#endif
-extern Handle(AIS_Shape) GetAISShapeFromName(const char* name);
-
-
static Standard_Real t3d = 1.e-4;
static Standard_Real t2d = 1.e-5;
static Standard_Real ta = 1.e-2;
TopoDS_Shape res = Rakk->Shape();
DBRep::Set(a[1],res);
-
// visu resultat...
- Handle(AIS_Shape) AS = GetAISShapeFromName(a[1]);
- Handle(AIS_Shape) Start = GetAISShapeFromName(a[2]);
- Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
- Ctx->Erase(Start,Standard_False);
- if(Ctx->IsDisplayed(AS))
- Ctx->Redisplay (AS, Standard_True);
- else
- Ctx->Display (AS, Standard_True);
+ ViewerTest::Display (a[2], Handle(AIS_InteractiveObject)(), false);
+ ViewerTest::Display (a[1], new AIS_Shape (res), true);
return 0;
}
//=======================================================================
static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- if ( argc <4 ) { di << "ERROR: Too few args\n"; return 0; }
- Handle(DDF_Browser) browser =
- Handle(DDF_Browser)::DownCast (Draw::Get(argv[1], Standard_True));
- if ( browser.IsNull() ) { di << "ERROR: Not a browser: " << argv[1] << "\n"; return 0; }
+ if ( argc < 4 ) { std::cout << "Syntax error: Too few args\n"; return 1; }
+ Handle(DDF_Browser) browser = Handle(DDF_Browser)::DownCast (Draw::GetExisting (argv[1]));
+ if ( browser.IsNull() ) { std::cout << "Syntax error: Not a browser: " << argv[1] << "\n"; return 1; }
TDF_Label lab;
TDF_Tool::Label(browser->Data(),argv[2],lab);
- if ( lab.IsNull() ) { di << "ERROR: label is Null: " << argv[2] << "\n"; return 0; }
+ if ( lab.IsNull() ) { std::cout << "Syntax error: label is Null: " << argv[2] << "\n"; return 1; }
Standard_Integer num = Draw::Atoi ( argv[3] );
TDF_AttributeIterator itr(lab,Standard_False);
for (Standard_Integer i=1; itr.More() && i < num; i++) itr.Next();
- if ( ! itr.More() ) { di << "ERROR: Attribute #" << num << " not found\n"; return 0; }
+ if ( ! itr.More() ) { std::cout << "Syntax error: Attribute #" << num << " not found\n"; return 1; }
const Handle(TDF_Attribute)& att = itr.Value();
if ( att->IsKind(STANDARD_TYPE(TDataStd_TreeNode)) ) {