diff --git a/src/BOPDS/BOPDS_ShapeInfo.cxx b/src/BOPDS/BOPDS_ShapeInfo.cxx index 1ce444c03e..dd6a0c6854 100644 --- a/src/BOPDS/BOPDS_ShapeInfo.cxx +++ b/src/BOPDS/BOPDS_ShapeInfo.cxx @@ -19,8 +19,6 @@ #include #include -static - void DumpType(const TopAbs_ShapeEnum aTS); //======================================================================= //function : Dump @@ -28,37 +26,12 @@ static //======================================================================= 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]); -} diff --git a/src/BRepCheck/BRepCheck_Shell.cxx b/src/BRepCheck/BRepCheck_Shell.cxx index ec63eae087..35028cd0ac 100644 --- a/src/BRepCheck/BRepCheck_Shell.cxx +++ b/src/BRepCheck/BRepCheck_Shell.cxx @@ -89,52 +89,8 @@ Standard_EXPORT Standard_Integer BRepCheck_Trace(const Standard_Integer phase) { 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; } } diff --git a/src/DBRep/DBRep_DrawableShape.cxx b/src/DBRep/DBRep_DrawableShape.cxx index 9165396c32..6833036f8c 100644 --- a/src/DBRep/DBRep_DrawableShape.cxx +++ b/src/DBRep/DBRep_DrawableShape.cxx @@ -1019,65 +1019,22 @@ void DBRep_DrawableShape::Dump(Standard_OStream& S)const 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 << " "; + s << "shape " << TopAbs::ShapeTypeToString (myShape.ShapeType()) + << " " << TopAbs::ShapeOrientationToString(myShape.Orientation()); - 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; - } - - 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 : diff --git a/src/DNaming/DNaming_ModelingCommands.cxx b/src/DNaming/DNaming_ModelingCommands.cxx index 487be22611..4c9a9769ce 100644 --- a/src/DNaming/DNaming_ModelingCommands.cxx +++ b/src/DNaming/DNaming_ModelingCommands.cxx @@ -1860,27 +1860,7 @@ inline static TCollection_ExtendedString compareShapes(const TopoDS_Shape& theSh } 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]]]" @@ -1972,7 +1952,7 @@ static Standard_Integer DNaming_TestSingle (Draw_Interpretor& theDI, aResult += " Selection at label = "; aResult += entry; aResult += " has UNKNOWN name type, shape type = "; - aResult += ShapeEnumToString(aCurShape.ShapeType()); + aResult += TopAbs::ShapeTypeToString (aCurShape.ShapeType()); } } @@ -1982,7 +1962,7 @@ static Standard_Integer DNaming_TestSingle (Draw_Interpretor& theDI, 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()) { @@ -2106,7 +2086,7 @@ static Standard_Integer DNaming_Multiple (Draw_Interpretor& theDI, aResult += " Selection at label = "; aResult += entry; aResult += " has UNKNOWN name type, shape type = "; - aResult += ShapeEnumToString(aCurShape.ShapeType()); + aResult += TopAbs::ShapeTypeToString (aCurShape.ShapeType()); } } @@ -2116,7 +2096,7 @@ static Standard_Integer DNaming_Multiple (Draw_Interpretor& theDI, 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()) diff --git a/src/MoniTool/MoniTool_SignShape.cxx b/src/MoniTool/MoniTool_SignShape.cxx index 6c9afd8f9a..ef497d9318 100644 --- a/src/MoniTool/MoniTool_SignShape.cxx +++ b/src/MoniTool/MoniTool_SignShape.cxx @@ -35,16 +35,5 @@ MoniTool_SignShape::MoniTool_SignShape () { } 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()); } diff --git a/src/QABugs/QABugs_1.cxx b/src/QABugs/QABugs_1.cxx index 29f9fab0d1..f3b7446a35 100644 --- a/src/QABugs/QABugs_1.cxx +++ b/src/QABugs/QABugs_1.cxx @@ -66,121 +66,6 @@ static TColStd_MapOfInteger theactivatedmodes(8); #include #include -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) { @@ -512,8 +397,6 @@ static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, co 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); diff --git a/src/TopAbs/TopAbs.cxx b/src/TopAbs/TopAbs.cxx index f5fecedcb4..d9a43d0378 100644 --- a/src/TopAbs/TopAbs.cxx +++ b/src/TopAbs/TopAbs.cxx @@ -14,10 +14,62 @@ // 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 +#include + +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 @@ -64,36 +116,6 @@ TopAbs_Orientation TopAbs::Complement(const TopAbs_Orientation Ori) 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. diff --git a/src/TopAbs/TopAbs.hxx b/src/TopAbs/TopAbs.hxx index 1f218ae6b5..1efbf00d17 100644 --- a/src/TopAbs/TopAbs.hxx +++ b/src/TopAbs/TopAbs.hxx @@ -98,39 +98,49 @@ public: //! becomes outside. Standard_EXPORT static TopAbs_Orientation Complement (const TopAbs_Orientation Or); - //! Prints the name of Shape as a String on the - //! Stream and returns . - 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 as a String on - //! the Stream and returns . - 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 as a String on //! the Stream and returns . Standard_EXPORT static Standard_OStream& Print (const TopAbs_State St, Standard_OStream& S); + //! 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); -protected: - - - - - -private: - - - - + //! 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 diff --git a/src/TopOpeBRepBuild/TopOpeBRepBuild_ShapeSet.cxx b/src/TopOpeBRepBuild/TopOpeBRepBuild_ShapeSet.cxx index 187fc964f2..1b7f195a93 100644 --- a/src/TopOpeBRepBuild/TopOpeBRepBuild_ShapeSet.cxx +++ b/src/TopOpeBRepBuild/TopOpeBRepBuild_ShapeSet.cxx @@ -42,17 +42,6 @@ static void ShapeEnumToString(const TopAbs_ShapeEnum T, TCollection_AsciiString& 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 @@ -684,8 +673,7 @@ TCollection_AsciiString TopOpeBRepBuild_ShapeSet::SNameori(const TopoDS_Shape& S { 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; diff --git a/src/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeSet.cxx b/src/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeSet.cxx index 24de5e50fa..96a391c821 100644 --- a/src/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeSet.cxx +++ b/src/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeSet.cxx @@ -17,20 +17,8 @@ #ifdef DRAW #include 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 #include #include @@ -586,10 +574,10 @@ TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameVEE(const TopoDS_Shape 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; } diff --git a/src/TopOpeBRepDS/TopOpeBRepDS.cxx b/src/TopOpeBRepDS/TopOpeBRepDS.cxx index 5557d6745c..d4b6a7d0c0 100644 --- a/src/TopOpeBRepDS/TopOpeBRepDS.cxx +++ b/src/TopOpeBRepDS/TopOpeBRepDS.cxx @@ -89,14 +89,7 @@ Standard_OStream& TopOpeBRepDS::Print(const TopAbs_ShapeEnum t,const Standard_In //======================================================================= 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); } //======================================================================= diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 51777f2ffb..2896cdd89a 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -686,20 +686,10 @@ void ViewerTest::StandardModeActivation(const Standard_Integer mode ) } } - 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)); @@ -4353,19 +4343,10 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch // 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 @@ -4471,19 +4452,10 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch 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); @@ -5163,18 +5135,12 @@ static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char** } //======================================================================= -//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()) { @@ -5182,38 +5148,41 @@ static int VSetFilter(Draw_Interpretor& theDi, Standard_Integer theArgc, 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; + 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; + } - 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; + 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 + { + std::cout << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'\n"; return 1; } - - if(aType==TopAbs_SHAPE){ - Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter(AIS_KOI_Shape); - aContext->AddFilter(aFilter); - } - else{ - Handle(StdSelect_ShapeTypeFilter) aFilter = new StdSelect_ShapeTypeFilter(aType); - aContext->AddFilter(aFilter); - } } return 0; } @@ -6177,12 +6146,12 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) "\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); diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 78d6aa939f..0ce0dc122b 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -4364,8 +4364,31 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, } } - 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()) { diff --git a/tests/bugs/vis/bug12121 b/tests/bugs/vis/bug12121 index 55ee4f1a3b..3751b9e1c9 100755 --- a/tests/bugs/vis/bug12121 +++ b/tests/bugs/vis/bug12121 @@ -117,7 +117,7 @@ vmoveto ${x_solid_new} ${y_solid_new} 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 diff --git a/tests/bugs/vis/bug28365 b/tests/bugs/vis/bug28365 index b9cc399030..e343db202a 100644 --- a/tests/bugs/vis/bug28365 +++ b/tests/bugs/vis/bug28365 @@ -1,21 +1,17 @@ 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" } diff --git a/tests/bugs/vis/bug328 b/tests/bugs/vis/bug328 deleted file mode 100644 index be242081de..0000000000 --- a/tests/bugs/vis/bug328 +++ /dev/null @@ -1,34 +0,0 @@ -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 - - - diff --git a/tests/v3d/face/F3 b/tests/v3d/face/F3 index da5796176e..655c076021 100644 --- a/tests/v3d/face/F3 +++ b/tests/v3d/face/F3 @@ -3,7 +3,7 @@ box b2 2 0 0 1 1 1 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 @@ -12,7 +12,7 @@ vselmode b1 4 1 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" }