TopAbs::ShapeTypeToString() is now used instead of duplicating TopAbs_ShapeEnum printing code.
vselmode now accepts shape type string for activating standard AIS_Shape selection modes.
#include <TopoDS_Shape.hxx>
#include <stdio.h>
-static
- void DumpType(const TopAbs_ShapeEnum aTS);
//=======================================================================
//function : Dump
//=======================================================================
void BOPDS_ShapeInfo::Dump()const
{
- Standard_Integer n;
- TopAbs_ShapeEnum aTS;
- BOPCol_ListIteratorOfListOfInteger aIt;
- //
- aTS=ShapeType();
- DumpType(aTS);
- //
+ const TopAbs_ShapeEnum aTS = ShapeType();
+ printf(" %s", TopAbs::ShapeTypeToString (aTS));
printf(" {");
- aIt.Initialize(mySubShapes);
- for (; aIt.More(); aIt.Next()) {
- n=aIt.Value();
+ for (BOPCol_ListIteratorOfListOfInteger aIt(mySubShapes); aIt.More(); aIt.Next()) {
+ Standard_Integer n = aIt.Value();
printf(" %d", n);
}
printf(" }");
}
-//=======================================================================
-//function : DumpType
-//purpose :
-//=======================================================================
-void DumpType(const TopAbs_ShapeEnum aTS)
-{
- const char *pT[]={
- "COMPOUND",
- "COMPSOLID",
- "SOLID",
- "SHELL",
- "FACE",
- "WIRE",
- "EDGE",
- "VERTEX",
- "SHAPE"
- };
- printf(" %s", pT[(int)aTS]);
-}
void PrintShape(const TopoDS_Shape& theShape, const Standard_Integer upper) {
if (!theShape.IsNull()) {
Standard_Integer code = theShape.HashCode(upper);
-
- switch (theShape.ShapeType()) {
- case TopAbs_COMPOUND :
- cout << "COMPOUND";
- break;
- case TopAbs_COMPSOLID :
- cout << "COMPSOLID";
- break;
- case TopAbs_SOLID :
- cout << "SOLID";
- break;
- case TopAbs_SHELL :
- cout << "SHELL";
- break;
- case TopAbs_FACE :
- cout << "FACE";
- break;
- case TopAbs_WIRE :
- cout << "WIRE";
- break;
- case TopAbs_EDGE :
- cout << "EDGE";
- break;
- case TopAbs_VERTEX :
- cout << "VERTEX";
- break;
- case TopAbs_SHAPE :
- cout << "SHAPE";
- break;
- }
- cout << " : " << code << " ";
- switch (theShape.Orientation()) {
- case TopAbs_FORWARD :
- cout << "FORWARD";
- break;
- case TopAbs_REVERSED :
- cout << "REVERSED";
- break;
- case TopAbs_INTERNAL :
- cout << "INTERNAL";
- break;
- case TopAbs_EXTERNAL :
- cout << "EXTERNAL";
- break;
- }
- cout << endl;
+ std::cout << TopAbs::ShapeTypeToString (theShape.ShapeType()) << " : " << code
+ << " " << TopAbs::ShapeOrientationToString(theShape.Orientation()) << std::endl;
}
}
void DBRep_DrawableShape::Whatis(Draw_Interpretor& s)const
{
- if (!myShape.IsNull()) {
- s << "shape ";
- switch (myShape.ShapeType()) {
- case TopAbs_COMPOUND :
- s << "COMPOUND";
- break;
- case TopAbs_COMPSOLID :
- s << "COMPSOLID";
- break;
- case TopAbs_SOLID :
- s << "SOLID";
- break;
- case TopAbs_SHELL :
- s << "SHELL";
- break;
- case TopAbs_FACE :
- s << "FACE";
- break;
- case TopAbs_WIRE :
- s << "WIRE";
- break;
- case TopAbs_EDGE :
- s << "EDGE";
- break;
- case TopAbs_VERTEX :
- s << "VERTEX";
- break;
- case TopAbs_SHAPE :
- s << "SHAPE";
- break;
- }
+ if (myShape.IsNull())
+ {
+ return;
+ }
- s << " ";
-
- switch (myShape.Orientation()) {
- case TopAbs_FORWARD :
- s << "FORWARD";
- break;
- case TopAbs_REVERSED :
- s << "REVERSED";
- break;
- case TopAbs_INTERNAL :
- s << "INTERNAL";
- break;
- case TopAbs_EXTERNAL :
- s << "EXTERNAL";
- break;
- }
+ s << "shape " << TopAbs::ShapeTypeToString (myShape.ShapeType())
+ << " " << TopAbs::ShapeOrientationToString(myShape.Orientation());
- if (myShape.Free()) s <<" Free";
- if (myShape.Modified()) s <<" Modified";
- if (myShape.Orientable()) s <<" Orientable";
- if (myShape.Closed()) s <<" Closed";
- if (myShape.Infinite()) s <<" Infinite";
- if (myShape.Convex()) s <<" Convex";
- }
+ if (myShape.Free()) s <<" Free";
+ if (myShape.Modified()) s <<" Modified";
+ if (myShape.Orientable()) s <<" Orientable";
+ if (myShape.Closed()) s <<" Closed";
+ if (myShape.Infinite()) s <<" Infinite";
+ if (myShape.Convex()) s <<" Convex";
}
-
//=======================================================================
//function : LastPick
//purpose :
}
return aResult;
}
-//=======================================================================
-//function : IntegerToShapeEnum
-//purpose :
-//=======================================================================
-static TCollection_AsciiString ShapeEnumToString (const TopAbs_ShapeEnum type)
-{
- switch(type)
- {
- case TopAbs_COMPOUND : return TCollection_AsciiString("COMPOUND");
- case TopAbs_COMPSOLID : return TCollection_AsciiString("COMPSOLID");
- case TopAbs_SOLID : return TCollection_AsciiString("SOLID");
- case TopAbs_SHELL : return TCollection_AsciiString("SHELL");
- case TopAbs_FACE : return TCollection_AsciiString("FACE");
- case TopAbs_WIRE : return TCollection_AsciiString("WIRE");
- case TopAbs_EDGE : return TCollection_AsciiString("EDGE");
- case TopAbs_VERTEX : return TCollection_AsciiString("VERTEX");
- case TopAbs_SHAPE : return TCollection_AsciiString("SHAPE");
- }
- return TCollection_AsciiString("SHAPE");
-}
//=======================================================================
//function : DNaming_TestSingle
//purpose : "TestSingleSelection Doc ObjectLabel [Orientation [Xselection [Geometry]]]"
aResult += " Selection at label = ";
aResult += entry;
aResult += " has UNKNOWN name type, shape type = ";
- aResult += ShapeEnumToString(aCurShape.ShapeType());
+ aResult += TopAbs::ShapeTypeToString (aCurShape.ShapeType());
}
}
aResult += " Selection at label = ";
aResult += entry;
aResult += " failed, shape type = ";
- aResult += ShapeEnumToString(aCurShape.ShapeType());
+ aResult += TopAbs::ShapeTypeToString (aCurShape.ShapeType());
aFailedList.Append(aCurShape);
}
if(aResult.Length()) {
aResult += " Selection at label = ";
aResult += entry;
aResult += " has UNKNOWN name type, shape type = ";
- aResult += ShapeEnumToString(aCurShape.ShapeType());
+ aResult += TopAbs::ShapeTypeToString (aCurShape.ShapeType());
}
}
aResult += " Selection at label = ";
aResult += entry;
aResult += " failed, shape type = ";
- aResult += ShapeEnumToString(aCurShape.ShapeType());
+ aResult += TopAbs::ShapeTypeToString (aCurShape.ShapeType());
aFailedList.Append(aCurShape);
}
if(aResult.Length())
if (HS.IsNull()) return ent->DynamicType()->Name();
TopoDS_Shape sh = HS->Shape();
if (sh.IsNull()) return "SHAPE";
- switch (sh.ShapeType()) {
- case TopAbs_VERTEX : return "VERTEX";
- case TopAbs_EDGE : return "EDGE";
- case TopAbs_WIRE : return "WIRE";
- case TopAbs_FACE : return "FACE";
- case TopAbs_SHELL : return "SHELL";
- case TopAbs_SOLID : return "SOLID";
- case TopAbs_COMPSOLID : return "COMPSOLID";
- case TopAbs_COMPOUND : return "COMPOUND";
- default : break;
- }
- return "SHAPE";
+ return TopAbs::ShapeTypeToString (sh.ShapeType());
}
#include <BRepAdaptor_Curve.hxx>
#include <GC_MakePlane.hxx>
-Standard_DISABLE_DEPRECATION_WARNINGS
-static Standard_Integer OCC328bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if(aContext.IsNull()) {
- di << argv[0] << "ERROR : use 'vinit' command before \n";
- return 1;
- }
-
- if ( argc != 3) {
- di << "ERROR : Usage : " << argv[0] << " shape mode\n";
- return 1;
- }
-
- Standard_Integer ChoosingMode = -1;
- if ( strcmp (argv [2], "VERTEX") == 0 ) {
- ChoosingMode = 1;
- }
- if ( strcmp (argv [2], "EDGE") == 0 ) {
- ChoosingMode = 2;
- }
- if ( strcmp (argv [2], "WIRE") == 0 ) {
- ChoosingMode = 3;
- }
- if ( strcmp (argv [2], "FACE") == 0 ) {
- ChoosingMode = 4;
- }
- if ( strcmp (argv [2], "SHELL") == 0 ) {
- ChoosingMode = 5;
- }
- if ( strcmp (argv [2], "SOLID") == 0 ) {
- ChoosingMode = 6;
- }
- if ( strcmp (argv [2], "COMPOUND") == 0 ) {
- ChoosingMode = 7;
- }
- if ( ChoosingMode == -1 ) {
- di << "ERROR : " << argv[1] << " : vrong value of a mode\n";
- return 1;
- }
-
- Standard_Boolean updateviewer = Standard_True;
-
- ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
-
- TCollection_AsciiString aName(argv[1]);
- Handle(AIS_InteractiveObject) AISObj;
-
- if(!aMap.IsBound2(aName)) {
- di << "Use 'vdisplay' before\n";
- return 1;
- } else {
- AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
- if(AISObj.IsNull()){
- di << argv[1] << " : No interactive object\n";
- return 1;
- }
-
- if (!aContext->HasOpenedContext()) {
- aContext->OpenLocalContext();
- }
-
- if(!theactivatedmodes.Contains(ChoosingMode)) {
- aContext->ActivateStandardMode(AIS_Shape::SelectionType(ChoosingMode));
- theactivatedmodes.Add(ChoosingMode);
- }
- aContext->Erase(AISObj, updateviewer);
- aContext->UpdateCurrentViewer();
-
- aContext->Display(AISObj, updateviewer);
- aContext->UpdateCurrentViewer();
-
- const TColStd_ListOfInteger& aList = aContext->ActivatedStandardModes();
- Standard_Integer SelectMode;
- TCollection_AsciiString SelectModeString;
- TColStd_ListIteratorOfListOfInteger itr(aList);
- for (; itr.More(); itr.Next()) {
- SelectMode = itr.Value();
- //cout << "SelectMode = " << SelectMode << endl;
-
- switch (SelectMode)
- {
- case 1:
- SelectModeString.Copy("VERTEX");
- break;
- case 2:
- SelectModeString.Copy("EDGE");
- break;
- case 3:
- SelectModeString.Copy("WIRE");
- break;
- case 4:
- SelectModeString.Copy("FACE");
- break;
- case 5:
- SelectModeString.Copy("SHELL");
- break;
- case 6:
- SelectModeString.Copy("SOLID");
- break;
- case 7:
- SelectModeString.Copy("COMPOUND");
- break;
- default:
- SelectModeString.Copy("UNKNOWN");
- }
- di << "SelectMode = " << SelectModeString.ToCString() << "\n";
-
- }
- }
-
- return 0;
-}
-Standard_ENABLE_DEPRECATION_WARNINGS
-
static Standard_Integer OCC159bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
{
if ( argc != 2) {
void QABugs::Commands_1(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
- theCommands.Add ("OCC328", "OCC328 shape mode", __FILE__, OCC328bug, group);
-
theCommands.Add ("OCC159", "OCC159 Doc", __FILE__, OCC159bug, group);
theCommands.Add ("OCC145", "OCC145 Shape MaxNbr", __FILE__, OCC145bug, group);
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-// Modified by model, Thu Jun 25 10:40:27 1992
-
#include <TopAbs.hxx>
+#include <TCollection_AsciiString.hxx>
+
+namespace
+{
+ static Standard_CString TopAbs_Table_PrintShapeEnum[9] =
+ {
+ "COMPOUND","COMPSOLID","SOLID","SHELL","FACE","WIRE","EDGE","VERTEX","SHAPE"
+ };
+
+ static Standard_CString TopAbs_Table_PrintOrientation[4] =
+ {
+ "FORWARD","REVERSED","INTERNAL","EXTERNAL"
+ };
+}
+
+//=======================================================================
+//function : ShapeTypeToString
+//purpose :
+//=======================================================================
+Standard_CString TopAbs::ShapeTypeToString (TopAbs_ShapeEnum theType)
+{
+ return TopAbs_Table_PrintShapeEnum[theType];
+}
+
+//=======================================================================
+//function : ShapeTypeFromString
+//purpose :
+//=======================================================================
+Standard_Boolean TopAbs::ShapeTypeFromString (Standard_CString theTypeString,
+ TopAbs_ShapeEnum& theType)
+{
+ TCollection_AsciiString aName (theTypeString);
+ aName.UpperCase();
+ for (Standard_Integer aTypeIter = 0; aTypeIter <= TopAbs_SHAPE; ++aTypeIter)
+ {
+ Standard_CString aTypeName = TopAbs_Table_PrintShapeEnum[aTypeIter];
+ if (aName == aTypeName)
+ {
+ theType = TopAbs_ShapeEnum(aTypeIter);
+ return Standard_True;
+ }
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : ShapeOrientationToString
+//purpose :
+//=======================================================================
+Standard_CString TopAbs::ShapeOrientationToString (TopAbs_Orientation theOrientation)
+{
+ return TopAbs_Table_PrintOrientation[theOrientation];
+}
+
//=======================================================================
//function : TopAbs_Compose
//purpose : Compose two orientations
return TopAbs_Table_Complement[(Standard_Integer)Ori];
}
-//=======================================================================
-//function : TopAbs_Print
-//purpose : print the name of a ShapeEnum on a stream.
-//=======================================================================
-
-Standard_OStream& TopAbs::Print(const TopAbs_ShapeEnum se,
- Standard_OStream& s)
-{
- static const Standard_CString TopAbs_Table_PrintShapeEnum[9] =
- {
- "COMPOUND","COMPSOLID","SOLID","SHELL","FACE","WIRE","EDGE","VERTEX","SHAPE"
- };
- return (s << TopAbs_Table_PrintShapeEnum[(Standard_Integer)se]);
-}
-
-//=======================================================================
-//function : TopAbs_Print
-//purpose : print the name of an Orientation on a stream
-//=======================================================================
-
-Standard_OStream& TopAbs::Print(const TopAbs_Orientation ori,
- Standard_OStream& s)
-{
- static const Standard_CString TopAbs_Table_PrintOrientation[4] =
- {
- "FORWARD","REVERSED","INTERNAL","EXTERNAL"
- };
- return (s << TopAbs_Table_PrintOrientation[(Standard_Integer)ori]);
-}
-
//=======================================================================
//function : TopAbs_Print
//purpose : print the name of a State on a stream.
//! becomes outside.
Standard_EXPORT static TopAbs_Orientation Complement (const TopAbs_Orientation Or);
- //! Prints the name of Shape <SEq> as a String on the
- //! Stream <S> and returns <S>.
- Standard_EXPORT static Standard_OStream& Print (const TopAbs_ShapeEnum SE, Standard_OStream& S);
+ //! Prints the name of Shape type as a String on the Stream.
+ static Standard_OStream& Print (const TopAbs_ShapeEnum theShapeType, Standard_OStream& theStream)
+ {
+ return (theStream << ShapeTypeToString (theShapeType));
+ }
- //! Prints the name of the Orientation <Or> as a String on
- //! the Stream <S> and returns <S>.
- Standard_EXPORT static Standard_OStream& Print (const TopAbs_Orientation Or, Standard_OStream& S);
+ //! Prints the name of the Orientation as a String on the Stream.
+ static Standard_OStream& Print (const TopAbs_Orientation theOrientation, Standard_OStream& theStream)
+ {
+ return (theStream << ShapeOrientationToString (theOrientation));
+ }
//! Prints the name of the State <St> as a String on
//! the Stream <S> and returns <S>.
Standard_EXPORT static Standard_OStream& Print (const TopAbs_State St, Standard_OStream& S);
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
+ //! Returns the string name for a given shape type.
+ //! @param theType shape type
+ //! @return string identifier from the list COMPOUND, COMPSOLID, SOLID, SHELL, FACE, WIRE, EDGE, VERTEX, SHAPE
+ Standard_EXPORT static Standard_CString ShapeTypeToString (TopAbs_ShapeEnum theType);
+
+ //! Returns the shape type from the given string identifier (using case-insensitive comparison).
+ //! @param theTypeString string identifier
+ //! @return shape type or TopAbs_SHAPE if string identifier is invalid
+ static TopAbs_ShapeEnum ShapeTypeFromString (Standard_CString theTypeString)
+ {
+ TopAbs_ShapeEnum aType = TopAbs_SHAPE;
+ ShapeTypeFromString (theTypeString, aType);
+ return aType;
+ }
+
+ //! Determines the shape type from the given string identifier (using case-insensitive comparison).
+ //! @param theTypeString string identifier
+ //! @param theType detected shape type
+ //! @return TRUE if string identifier is known
+ Standard_EXPORT static Standard_Boolean ShapeTypeFromString (Standard_CString theTypeString,
+ TopAbs_ShapeEnum& theType);
+
+ //! Returns the string name for a given shape orientation.
+ //! @param theOrientation shape orientation
+ //! @return string identifier from the list FORWARD, REVERSED, INTERNAL, EXTERNAL
+ Standard_EXPORT static Standard_CString ShapeOrientationToString (TopAbs_Orientation theOrientation);
};
-
-
-
-
-
-
#endif // _TopAbs_HeaderFile
else if (T == TopAbs_EDGE) N = "e";
else if (T == TopAbs_VERTEX) N = "v";
}
-
-static void OrientationToString(const TopAbs_Orientation o, TCollection_AsciiString& N)
-{
- switch (o) {
- case TopAbs_FORWARD : N = "FORWARD" ; break;
- case TopAbs_REVERSED : N = "REVERSED"; break;
- case TopAbs_INTERNAL : N = "INTERNAL"; break;
- case TopAbs_EXTERNAL : N = "EXTERNAL"; break;
- }
-}
-
#endif
#ifdef OCCT_DEBUG
{
TCollection_AsciiString str;
str=sb+SName(S);
- TopAbs_Orientation o = S.Orientation();
- TCollection_AsciiString sto;OrientationToString(o,sto);
+ TCollection_AsciiString sto = TopAbs::ShapeOrientationToString (S.Orientation());
str=str+sto.SubString(1,1);
str=str+sa;
return str;
#ifdef DRAW
#include <DBRep.hxx>
static TCollection_AsciiString PRODINS("dins ");
-
-static void OrientationToString(const TopAbs_Orientation o, TCollection_AsciiString& N)
-{
- switch (o) {
- case TopAbs_FORWARD : N = "FORWARD" ; break;
- case TopAbs_REVERSED : N = "REVERSED"; break;
- case TopAbs_INTERNAL : N = "INTERNAL"; break;
- case TopAbs_EXTERNAL : N = "EXTERNAL"; break;
- }
-}
-
#endif
-
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
TopAbs_Orientation oVE1,oVE2; Standard_Boolean conn = VertexConnectsEdges(V,E1,E2,oVE1,oVE2);
str=SName(VV)+" ";
str=str+SNameori(E1)+" V/E1 : ";
- TCollection_AsciiString so1;OrientationToString(oVE1,so1);so1.UpperCase();
+ TCollection_AsciiString so1 = TopAbs::ShapeOrientationToString (oVE1);
str=str+so1.SubString(1,1)+" ";
str=str+SNameori(E2)+" V/E2 : ";
- TCollection_AsciiString so2;OrientationToString(oVE2,so2);so2.UpperCase();
+ TCollection_AsciiString so2 = TopAbs::ShapeOrientationToString (oVE2);
str=str+so2.SubString(1,1)+" ";
return str;
}
//=======================================================================
TCollection_AsciiString TopOpeBRepDS::SPrint(const TopAbs_Orientation o)
{
- TCollection_AsciiString SS;
- switch (o) {
- case TopAbs_FORWARD : SS = "FORWARD" ; break;
- case TopAbs_REVERSED : SS = "REVERSED"; break;
- case TopAbs_INTERNAL : SS = "INTERNAL"; break;
- case TopAbs_EXTERNAL : SS = "EXTERNAL"; break;
- }
- return SS;
+ return TopAbs::ShapeOrientationToString (o);
}
//=======================================================================
}
}
- const char *cmode="???";
-
- switch (mode) {
- case 0: cmode = "Shape"; break;
- case 1: cmode = "Vertex"; break;
- case 2: cmode = "Edge"; break;
- case 3: cmode = "Wire"; break;
- case 4: cmode = "Face"; break;
- case 5: cmode = "Shell"; break;
- case 6: cmode = "Solid"; break;
- case 7: cmode = "Compsolid"; break;
- case 8: cmode = "Compound"; break;
- }
-
+ const TopAbs_ShapeEnum aShapeType = AIS_Shape::SelectionType (mode);
+ const char* cmode = mode >= 0 && mode <= 8
+ ? TopAbs::ShapeTypeToString (aShapeType)
+ : "???";
if(theactivatedmodes.Contains(mode))
{ // Desactivate
aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
// IL n'y a aps de nom de shape passe en argument
if (HaveToSet && !ThereIsName){
Standard_Integer aMode=Draw::Atoi(argv [1]);
-
- const char *cmode="???";
- switch (aMode) {
- case 0: cmode = "Shape"; break;
- case 1: cmode = "Vertex"; break;
- case 2: cmode = "Edge"; break;
- case 3: cmode = "Wire"; break;
- case 4: cmode = "Face"; break;
- case 5: cmode = "Shell"; break;
- case 6: cmode = "Solid"; break;
- case 7: cmode = "Compound"; break;
- }
-
+ const TopAbs_ShapeEnum aShapeType = AIS_Shape::SelectionType (aMode);
+ const char* cmode = aMode >= 0 && aMode <= 8
+ ? TopAbs::ShapeTypeToString (aShapeType)
+ : "???";
if( !TheAISContext()->HasOpenedContext() ) {
// il n'y a pas de Context local d'ouvert
// on en ouvre un et on charge toutes les shapes displayees
Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1]));
if (!aIO.IsNull()) {
- const char *cmode="???";
-
- switch (aMode) {
- case 0: cmode = "Shape"; break;
- case 1: cmode = "Vertex"; break;
- case 2: cmode = "Edge"; break;
- case 3: cmode = "Wire"; break;
- case 4: cmode = "Face"; break;
- case 5: cmode = "Shell"; break;
- case 6: cmode = "Solid"; break;
- case 7: cmode = "Compound"; break;
- }
-
+ const TopAbs_ShapeEnum aShapeType = AIS_Shape::SelectionType (aMode);
+ const char* cmode = aMode >= 0 && aMode <= 8
+ ? TopAbs::ShapeTypeToString (aShapeType)
+ : "???";
if( !TheAISContext()->HasOpenedContext() ) {
Standard_DISABLE_DEPRECATION_WARNINGS
TheAISContext()->OpenLocalContext(Standard_False);
}
//=======================================================================
-//function : VSetFilter
+//function : VSelFilter
//purpose :
//=======================================================================
-static int VSetFilter(Draw_Interpretor& theDi, Standard_Integer theArgc,
+static int VSelFilter(Draw_Interpretor& , Standard_Integer theArgc,
const char** theArgv)
{
- if (theArgc != 2)
- {
- theDi << theArgv[0] << " error : wrong number of parameters.\n";
- return 1;
- }
-
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if (aContext.IsNull())
{
return 1;
}
- TCollection_AsciiString anArg(theArgv[1]);
- if (anArg.IsEqual("-clear")) {
- aContext->RemoveFilters();
- }
- else {
- TCollection_AsciiString aPName, aPValue;
- if (!ViewerTest::SplitParameter (anArg, aPName, aPValue)) {
- std::cout << "Error: wrong command attribute name" << std::endl;
- return 1;
- }
-
- TopAbs_ShapeEnum aType = TopAbs_COMPOUND;
- if(aPValue.IsEqual("VERTEX")) aType = TopAbs_VERTEX;
- else if (aPValue.IsEqual("EDGE")) aType = TopAbs_EDGE;
- else if (aPValue.IsEqual("WIRE")) aType = TopAbs_WIRE;
- else if (aPValue.IsEqual("FACE")) aType = TopAbs_FACE;
- else if(aPValue.IsEqual("SHAPE")) aType = TopAbs_SHAPE;
- else if (aPValue.IsEqual("SHELL")) aType = TopAbs_SHELL;
- else if (aPValue.IsEqual("SOLID")) aType = TopAbs_SOLID;
- else {
- std::cout << "Error: wrong command attribute value" << std::endl;
- return 1;
+ for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter)
+ {
+ TCollection_AsciiString anArg (theArgv[anArgIter]);
+ anArg.LowerCase();
+ if (anArg == "-clear")
+ {
+ aContext->RemoveFilters();
}
+ else if (anArg == "-type"
+ && anArgIter + 1 < theArgc)
+ {
+ TCollection_AsciiString aVal (theArgv[++anArgIter]);
+ TopAbs_ShapeEnum aShapeType = TopAbs_COMPOUND;
+ if (!TopAbs::ShapeTypeFromString (aVal.ToCString(), aShapeType))
+ {
+ std::cout << "Syntax error: wrong command attribute value '" << aVal << "'\n";
+ return 1;
+ }
- if(aType==TopAbs_SHAPE){
- Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter(AIS_KOI_Shape);
- aContext->AddFilter(aFilter);
+ Handle(SelectMgr_Filter) aFilter;
+ if (aShapeType == TopAbs_SHAPE)
+ {
+ aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
+ }
+ else
+ {
+ aFilter = new StdSelect_ShapeTypeFilter (aShapeType);
+ }
+ aContext->AddFilter (aFilter);
}
- else{
- Handle(StdSelect_ShapeTypeFilter) aFilter = new StdSelect_ShapeTypeFilter(aType);
- aContext->AddFilter(aFilter);
+ else
+ {
+ std::cout << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'\n";
+ return 1;
}
}
return 0;
"\n\t\t: Reads shape from BREP-format file and displays it in the viewer. ",
__FILE__,vr, group);
- theCommands.Add("vsetfilter",
- "vsetfilter [-type={VERTEX|EDGE|WIRE|FACE|SHAPE|SHELL|SOLID}] [-clear]"
+ theCommands.Add("vselfilter",
+ "vselfilter [-type {VERTEX|EDGE|WIRE|FACE|SHAPE|SHELL|SOLID}] [-clear]"
"\nSets selection shape type filter in context or remove all filters."
"\n : Option -type set type of selection filter. Filters are applyed with Or combination."
"\n : Option -clear remove all filters in context",
- __FILE__,VSetFilter,group);
+ __FILE__,VSelFilter,group);
theCommands.Add("vpickselected", "vpickselected [name]: extract selected shape.",
__FILE__, VPickSelected, group);
}
}
- const Standard_Integer aSelectionMode = Draw::Atoi (anArgNb == 3 ? theArgv[1] : theArgv[2]);
- const Standard_Boolean toTurnOn = Draw::Atoi (anArgNb == 3 ? theArgv[2] : theArgv[3]) != 0;
+ Standard_Integer aSelectionMode = -1;
+ Standard_Boolean toTurnOn = Standard_True;
+ {
+ const TCollection_AsciiString aSelModeString (theArgv[anArgNb == 3 ? 1 : 2]);
+ TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
+ if (aSelModeString.IsIntegerValue())
+ {
+ aSelectionMode = aSelModeString.IntegerValue();
+ }
+ else if (TopAbs::ShapeTypeFromString (aSelModeString.ToCString(), aShapeType))
+ {
+ aSelectionMode = AIS_Shape::SelectionMode (aShapeType);
+ }
+ else
+ {
+ std::cout << "Syntax error: unknown selection mode '" << aSelModeString << "'\n";
+ return 1;
+ }
+ }
+ if (!ViewerTest::ParseOnOff (theArgv[anArgNb == 3 ? 2 : 3], toTurnOn))
+ {
+ std::cout << "Syntax error: on/off is expected by found '" << theArgv[anArgNb == 3 ? 2 : 3] << "'\n";
+ return 1;
+ }
+
Standard_DISABLE_DEPRECATION_WARNINGS
if (aSelectionMode == 0 && anAISContext->HasOpenedContext())
{
checkcolor ${x_solid_new} ${y_solid_new} ${R_check} ${G_check} ${B_check}
vselmode 6 0
-vselmode obj 1
+vselmode 0 1
vselect ${x_refresh} ${y_refresh}
##Resume
puts "==========="
-puts "OCC28365"
+puts "0028365: Visualization, AIS_InteractiveContext - apply selection filter in AddOrRemoveSelected at Neutral point"
puts "==========="
puts ""
-##########################################################################
-# Visualization, AIS_InteractiveContext - apply selection filter in
-# AddOrRemoveSelected at Neutral point
-##########################################################################
-pload ALL
-vinit
+pload MODELING VISUALIZATION
box b 10 10 10
+
+vclear
+vinit View1
vdisplay b
vfit
-vsetfilter -type=VERTEX
+vselfilter -type VERTEX
vchangeselected b
-set NbSelected1 [vnbselected]
-if { ${NbSelected1} != 0 } {
- puts "Error : Vertex filter was not applyed"
-}
+set aNbSelected [vnbselected]
+if { $aNbSelected != 0 } { puts "Error: Vertex filter was not applied" }
+++ /dev/null
-puts "========"
-puts "OCC328"
-puts "========"
-
-vinit
-set dx 10
-set dy 10
-set dz 10
-
-set x1 30
-set y1 307
-
-set x2 30
-set y2 107
-
-box b ${dx} ${dy} ${dz}
-vdisplay b
-vfit
-
-vselmode 2 1
-set info [OCC328 b VERTEX]
-if { [regexp "VERTEX" $info] != 1 } {
- puts "Faulty: Incorrect selection mode"
-}
-
-vselect ${x1} ${y1}
-vselect ${x2} ${y2} 1
-
-checkcolor ${x1} ${y1} 0.8 0.8 0.8
-checkcolor ${x2} ${y2} 0.8 0.8 0.8
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png
-
-
-
vclear
vinit View1
vviewparams -scale 404 -proj 0.8 -0.16 0.5 -up -0.4 0.4 0.8 -at 1.5 0.5 0.5
-vsetfilter -clear
+vselfilter -clear
vselprops -pickStrategy first
vdisplay -dispMode 1 -highMode 1 b1 b2
vfit
vmoveto 220 220
if { [vreadpixel 220 220 rgb name] != "TURQUOISE3" } { puts "Error: box b2 should be highlighted" }
-vsetfilter -type=FACE
+vselfilter -type FACE
vmoveto 0 0
vmoveto 220 220
if { [vreadpixel 150 150 rgb name] != "CYAN1" } { puts "Error: face of box b1 should be highlighted" }