From 005caf39cf8d506525a6ffa02f4d69d0cc4f714d Mon Sep 17 00:00:00 2001 From: kgv Date: Tue, 19 Oct 2021 21:34:18 +0300 Subject: [PATCH] 0032633: Draw Harness - extend command incmesh to apply default visualization parameters incmesh - added -prs option to use StdPrs_ToolTriangulatedShape::GetDeflection() as meshing parameters. vdisplay, XDisplay - added -autoTriangulation option to manage meshing behavior before displaying a shape. trinfo - added output of meshing parameters. Fixed broken incmesh syntax usage in several test cases. --- src/DrawResources/CheckCommands.tcl | 2 +- src/MeshTest/MeshTest.cxx | 331 +++++++++++---------- src/ViewerTest/ViewerTest.cxx | 25 +- src/XDEDRAW/XDEDRAW.cxx | 43 ++- tests/bugs/mesh/bug25281 | 2 +- tests/hlr/poly_hlr/bug23625_1 | 2 +- tests/mesh/advanced_incmesh/begin | 2 +- tests/mesh/advanced_incmesh_parallel/begin | 2 +- tests/mesh/end | 10 +- tests/mesh/standard_incmesh/begin | 2 +- tests/mesh/standard_incmesh_parallel/begin | 2 +- tests/perf/mesh/bug26889_1 | 2 +- tests/perf/mesh/bug26889_2 | 2 +- tests/perf/mesh/bug26889_3 | 2 +- tests/v3d/bugs/bug23200_1 | 4 +- 15 files changed, 243 insertions(+), 190 deletions(-) diff --git a/src/DrawResources/CheckCommands.tcl b/src/DrawResources/CheckCommands.tcl index e0b5c33f46..e39a130e23 100644 --- a/src/DrawResources/CheckCommands.tcl +++ b/src/DrawResources/CheckCommands.tcl @@ -999,7 +999,7 @@ proc checktrinfo {shape args} { # get current number of faces, triangles and nodes, value of max deflection set tri_info [trinfo ${shape}] - set triinfo_pattern "(\[0-9\]+) +faces(.*\[^0-9]\(\[0-9\]+) +empty faces)?.*\[^0-9]\(\[0-9\]+) +triangles.*\[^0-9]\(\[0-9\]+) +nodes.*deflection +(\[-0-9.+eE\]+)" + set triinfo_pattern "(\[0-9\]+) +faces(.*\[^0-9]\(\[0-9\]+) +empty faces)?.*\[^0-9]\(\[0-9\]+) +triangles.*\[^0-9]\(\[0-9\]+) +nodes.*Maximal deflection +(\[-0-9.+eE\]+)" if {![regexp "${triinfo_pattern}" ${tri_info} dump cur_nb_faces tmp cur_nb_empty_faces cur_nb_triangles cur_nb_nodes cur_deflection]} { puts "Error: command trinfo prints empty info" } diff --git a/src/MeshTest/MeshTest.cxx b/src/MeshTest/MeshTest.cxx index 234081dad9..83da94bd47 100644 --- a/src/MeshTest/MeshTest.cxx +++ b/src/MeshTest/MeshTest.cxx @@ -42,6 +42,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -80,83 +83,71 @@ OSD_Chronometer chIsos, chPointsOnIsos; //function : incrementalmesh //purpose : //======================================================================= -static Standard_Integer incrementalmesh(Draw_Interpretor& di, Standard_Integer nbarg, const char** argv) +static Standard_Integer incrementalmesh (Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) { - if (nbarg < 3) + if (theNbArgs < 3) { - di << "\ -Builds triangular mesh for the shape\n\ -usage: incmesh Shape LinearDeflection [options]\n\ -options:\n\ - -a val angular deflection for edges in deg\n\ - (default ~28.64 deg = 0.5 rad)\n\n\ - -ai val angular deflection inside of faces in deg\n\ - (default ~57.29 deg = 1 rad)\n\n\ - -di val Linear deflection used to tessellate the face interior.\n\ - -min minimum size parameter limiting size of triangle's\n\ - edges to prevent sinking into amplification in case\n\ - of distorted curves and surfaces\n\n\ - -relative notifies that relative deflection is used\n\ - (switched off by default)\n\n\ - -int_vert_off disables insertion of internal vertices into mesh\n\ - (enabled by default)\n\ - -surf_def_off disables control of deflection of mesh from real\n\ - surface (enabled by default)\n\ - -parallel enables parallel execution (switched off by default)\n\ - -adjust_min enables local adjustment of min size depending on edge size (switched off by default)\n\ - -force_face_def disables usage of shape tolerances for computing face deflection (switched off by default)\n\ - -decrease enforces the meshing of the shape even if current mesh satisfies the new criteria\ - (switched off by default).\n\ - -algo {watson|delabella} changes core triangulation algorithm to one with specified id (watson is used by default)\n"; - return 0; + theDI << "Syntax error: wrong number of arguments"; + return 1; } + TopoDS_ListOfShape aListOfShapes; IMeshTools_Parameters aMeshParams; - Standard_Boolean isDeflectionInitialized = Standard_False; + bool hasDefl = false, hasAngDefl = false, isPrsDefl = false; - Handle (IMeshTools_Context) aContext = new BRepMesh_Context; - for (Standard_Integer anArgIter = 1; anArgIter < nbarg; ++anArgIter) + Handle(IMeshTools_Context) aContext = new BRepMesh_Context(); + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) { - TCollection_AsciiString aName = argv[anArgIter]; - TCollection_AsciiString aNameCase = aName; + TCollection_AsciiString aNameCase (theArgVec[anArgIter]); aNameCase.LowerCase(); - - if (aNameCase == "") - continue; - else if (aNameCase == "-relative") - aMeshParams.Relative = Standard_True; - else if (aNameCase == "-parallel") - aMeshParams.InParallel = Standard_True; - else if (aNameCase == "-int_vert_off") - aMeshParams.InternalVerticesMode = Standard_False; - else if (aNameCase == "-surf_def_off") - aMeshParams.ControlSurfaceDeflection = Standard_False; - else if (aNameCase == "-adjust_min") - aMeshParams.AdjustMinSize = Standard_True; - else if (aNameCase == "-force_face_def") - aMeshParams.ForceFaceDeflection = Standard_True; - else if (aNameCase == "-decrease") - aMeshParams.AllowQualityDecrease = Standard_True; - else if (aNameCase == "-algo") + if (aNameCase == "-relative" + || aNameCase == "-norelative") { - if (++anArgIter >= nbarg) - { - di << "Error: wrong syntax at " << aNameCase; - return 1; - } - TCollection_AsciiString anAlgoStr (argv[anArgIter]); + aMeshParams.Relative = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter); + } + else if (aNameCase == "-parallel" + || aNameCase == "-noparallel") + { + aMeshParams.InParallel = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter); + } + else if (aNameCase == "-int_vert_off") + { + aMeshParams.InternalVerticesMode = !Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter); + } + else if (aNameCase == "-surf_def_off") + { + aMeshParams.ControlSurfaceDeflection = !Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter); + } + else if (aNameCase == "-adjust_min") + { + aMeshParams.AdjustMinSize = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter); + } + else if (aNameCase == "-force_face_def") + { + aMeshParams.ForceFaceDeflection = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter); + } + else if (aNameCase == "-decrease") + { + aMeshParams.AllowQualityDecrease = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter); + } + else if (aNameCase == "-algo" + && anArgIter + 1 < theNbArgs) + { + TCollection_AsciiString anAlgoStr (theArgVec[++anArgIter]); anAlgoStr.LowerCase(); if (anAlgoStr == "watson" || anAlgoStr == "0") { aMeshParams.MeshAlgo = IMeshTools_MeshAlgoType_Watson; - aContext->SetFaceDiscret (new BRepMesh_FaceDiscret (new BRepMesh_MeshAlgoFactory)); + aContext->SetFaceDiscret (new BRepMesh_FaceDiscret (new BRepMesh_MeshAlgoFactory())); } else if (anAlgoStr == "delabella" || anAlgoStr == "1") { aMeshParams.MeshAlgo = IMeshTools_MeshAlgoType_Delabella; - aContext->SetFaceDiscret (new BRepMesh_FaceDiscret (new BRepMesh_DelabellaMeshAlgoFactory)); + aContext->SetFaceDiscret (new BRepMesh_FaceDiscret (new BRepMesh_DelabellaMeshAlgoFactory())); } else if (anAlgoStr == "-1" || anAlgoStr == "default") @@ -166,89 +157,82 @@ options:\n\ } else { - di << "Syntax error at " << anAlgoStr; + theDI << "Syntax error at '" << anAlgoStr << "'"; return 1; } } - else if (aNameCase == "-a") + else if ((aNameCase == "-prs" + || aNameCase == "-presentation" + || aNameCase == "-vis" + || aNameCase == "-visualization") + && !isPrsDefl) { - if (++anArgIter >= nbarg) - { - di << "Error: wrong syntax at " << aNameCase; - return 1; - } - Standard_Real aVal = Draw::Atof (argv[anArgIter]) * M_PI / 180.; + isPrsDefl = true; + } + else if ((aNameCase == "-angular" + || aNameCase == "-angdefl" + || aNameCase == "-angulardeflection" + || aNameCase == "-a") + && anArgIter + 1 < theNbArgs) + { + Standard_Real aVal = Draw::Atof (theArgVec[++anArgIter]) * M_PI / 180.; if (aVal <= Precision::Angular()) { - di << "Syntax error: invalid input parameter '" << argv[anArgIter] << "'"; + theDI << "Syntax error: invalid input parameter '" << theArgVec[anArgIter] << "'"; return 1; } aMeshParams.Angle = aVal; + hasAngDefl = true; } - else if (aNameCase == "-ai") + else if (aNameCase == "-ai" + && anArgIter + 1 < theNbArgs) { - if (++anArgIter >= nbarg) - { - di << "Error: wrong syntax at " << aNameCase; - return 1; - } - Standard_Real aVal = Draw::Atof (argv[anArgIter]) * M_PI / 180.; + Standard_Real aVal = Draw::Atof (theArgVec[++anArgIter]) * M_PI / 180.; if (aVal <= Precision::Angular()) { - di << "Syntax error: invalid input parameter '" << argv[anArgIter] << "'"; + theDI << "Syntax error: invalid input parameter '" << theArgVec[anArgIter] << "'"; return 1; } aMeshParams.AngleInterior = aVal; } - else if (aNameCase == "-min") + else if (aNameCase == "-min" + && anArgIter + 1 < theNbArgs) { - if (++anArgIter >= nbarg) - { - di << "Error: wrong syntax at " << aNameCase; - return 1; - } - Standard_Real aVal = Draw::Atof (argv[anArgIter]); + Standard_Real aVal = Draw::Atof (theArgVec[++anArgIter]); if (aVal <= Precision::Confusion()) { - di << "Syntax error: invalid input parameter '" << argv[anArgIter] << "'"; + theDI << "Syntax error: invalid input parameter '" << theArgVec[anArgIter] << "'"; return 1; } aMeshParams.MinSize = aVal; } - else if (aNameCase == "-di") + else if (aNameCase == "-di" + && anArgIter + 1 < theNbArgs) { - if (++anArgIter >= nbarg) - { - di << "Error: wrong syntax at " << aNameCase; - return 1; - } - Standard_Real aVal = Draw::Atof (argv[anArgIter]); + Standard_Real aVal = Draw::Atof (theArgVec[++anArgIter]); if (aVal <= Precision::Confusion()) { - di << "Syntax error: invalid input parameter '" << argv[anArgIter] << "'"; + theDI << "Syntax error: invalid input parameter '" << theArgVec[anArgIter] << "'"; return 1; } aMeshParams.DeflectionInterior = aVal; } - else if (aNameCase.IsRealValue (Standard_True)) + else if (aNameCase.IsRealValue (true) + && !hasDefl) { - if (isDeflectionInitialized) - { - continue; - } - aMeshParams.Deflection = Max (Draw::Atof (argv[anArgIter]), Precision::Confusion()); + aMeshParams.Deflection = Max (Draw::Atof (theArgVec[anArgIter]), Precision::Confusion()); if (aMeshParams.DeflectionInterior < Precision::Confusion()) { aMeshParams.DeflectionInterior = aMeshParams.Deflection; } - isDeflectionInitialized = Standard_True; + hasDefl = true; } else { - TopoDS_Shape aShape = DBRep::Get (aName); + TopoDS_Shape aShape = DBRep::Get (theArgVec[anArgIter]); if (aShape.IsNull()) { - di << "Syntax error: null shapes are not allowed here - " << aName <<"\n"; + theDI << "Syntax error: null shapes are not allowed here '" << theArgVec[anArgIter] << "'\n"; return 1; } aListOfShapes.Append (aShape); @@ -261,8 +245,8 @@ options:\n\ return 1; } - di << "Incremental Mesh, multi-threading " - << (aMeshParams.InParallel ? "ON" : "OFF") << "\n"; + theDI << "Incremental Mesh, multi-threading " + << (aMeshParams.InParallel ? "ON" : "OFF") << "\n"; TopoDS_Shape aShape; if (aListOfShapes.Size() == 1) @@ -279,64 +263,55 @@ options:\n\ } aShape = aCompound; } - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1); - BRepMesh_IncrementalMesh aMesher; - aMesher.SetShape (aShape); - aMesher.ChangeParameters() = aMeshParams; - aMesher.Perform (aContext, aProgress->Start()); - - di << "Meshing statuses: "; - const Standard_Integer aStatus = aMesher.GetStatusFlags(); - if (!aStatus) + if (isPrsDefl) { - di << "NoError"; - } - else - { - Standard_Integer i; - for (i = 0; i < 9; i++) + Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer(); + if (hasDefl) { - Standard_Integer aFlag = aStatus & (1 << i); - if (aFlag) - { - switch ((IMeshData_Status) aFlag) - { - case IMeshData_OpenWire: - di << "OpenWire "; - break; - case IMeshData_SelfIntersectingWire: - di << "SelfIntersectingWire "; - break; - case IMeshData_Failure: - di << "Failure "; - break; - case IMeshData_ReMesh: - di << "ReMesh "; - break; - case IMeshData_UnorientedWire: - di << "UnorientedWire "; - break; - case IMeshData_TooFewPoints: - di << "TooFewPoints "; - break; - case IMeshData_Outdated: - di << "Outdated "; - break; - case IMeshData_Reused: - di << "Reused "; - break; - case IMeshData_UserBreak: - di << "User break"; - break; - case IMeshData_NoError: - default: - break; - } - } + aDrawer->SetDeviationCoefficient (aMeshParams.Deflection); + } + aMeshParams.Deflection = StdPrs_ToolTriangulatedShape::GetDeflection (aShape, aDrawer); + if (!hasAngDefl) + { + aMeshParams.Angle = aDrawer->DeviationAngle(); } } + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1); + BRepMesh_IncrementalMesh aMesher; + aMesher.SetShape (aShape); + aMesher.ChangeParameters() = aMeshParams; + aMesher.Perform (aContext, aProgress->Start()); + + theDI << "Meshing statuses: "; + const Standard_Integer aStatus = aMesher.GetStatusFlags(); + if (aStatus == 0) + { + theDI << "NoError"; + return 0; + } + + for (Standard_Integer i = 0; i < 9; i++) + { + Standard_Integer aFlag = aStatus & (1 << i); + if (aFlag) + { + switch ((IMeshData_Status) aFlag) + { + case IMeshData_OpenWire: theDI << "OpenWire "; break; + case IMeshData_SelfIntersectingWire: theDI << "SelfIntersectingWire "; break; + case IMeshData_Failure: theDI << "Failure "; break; + case IMeshData_ReMesh: theDI << "ReMesh "; break; + case IMeshData_UnorientedWire: theDI << "UnorientedWire "; break; + case IMeshData_TooFewPoints: theDI << "TooFewPoints "; break; + case IMeshData_Outdated: theDI << "Outdated "; break; + case IMeshData_Reused: theDI << "Reused "; break; + case IMeshData_UserBreak: theDI << "UserBreak "; break; + case IMeshData_NoError: break; + } + } + } return 0; } @@ -757,7 +732,7 @@ static Standard_Integer trianglesinfo (Draw_Interpretor& theDI, Standard_Integer TopExp_Explorer anExp; Handle(Poly_Triangulation) aTriangulation; TopLoc_Location aLoc; - Standard_Real aMaxDeflection = 0.0; + Standard_Real aMaxDeflection = 0.0, aMeshingDefl = -1.0, aMeshingAngDefl = -1.0, aMeshingMinSize = -1.0; Standard_Integer aNbFaces = 0, aNbEmptyFaces = 0, aNbTriangles = 0, aNbNodes = 0, aNbRepresentations = 0; NCollection_IndexedDataMap aLODsStat; NCollection_Vector aNbLODs; @@ -770,9 +745,12 @@ static Standard_Integer trianglesinfo (Draw_Interpretor& theDI, Standard_Integer { aNbTriangles += aTriangulation->NbTriangles(); aNbNodes += aTriangulation->NbNodes(); - if (aTriangulation->Deflection() > aMaxDeflection) + aMaxDeflection = Max (aMaxDeflection, aTriangulation->Deflection()); + if (!aTriangulation->Parameters().IsNull()) { - aMaxDeflection = aTriangulation->Deflection(); + aMeshingDefl = Max (aMeshingDefl, aTriangulation->Parameters()->Deflection()); + aMeshingAngDefl = Max (aMeshingAngDefl, aTriangulation->Parameters()->Angle()); + aMeshingMinSize = Max (aMeshingMinSize, aTriangulation->Parameters()->MinSize()); } } else @@ -868,6 +846,18 @@ static Standard_Integer trianglesinfo (Draw_Interpretor& theDI, Standard_Integer theDI << " " << aNbNodes << " nodes.\n"; theDI << " " << aNbRepresentations << " polygons on triangulation.\n"; theDI << "Maximal deflection " << aMaxDeflection << "\n"; + if (aMeshingDefl > 0.0) + { + theDI << "Meshing deflection " << aMeshingDefl << "\n"; + } + if (aMeshingAngDefl > 0.0) + { + theDI << "Meshing angular deflection " << (aMeshingAngDefl * 180.0 / M_PI) << "\n"; + } + if (aMeshingMinSize > 0.0) + { + theDI << "Meshing min size " << aMeshingMinSize << "\n"; + } if (aNbLODs.Size() > 0) { @@ -1613,7 +1603,32 @@ void MeshTest::Commands(Draw_Interpretor& theCommands) g = "Mesh Commands"; - theCommands.Add("incmesh","Builds triangular mesh for the shape, run w/o args for help",__FILE__, incrementalmesh, g); + theCommands.Add("incmesh", + "incmesh Shape LinDefl [-angular Angle]=28.64 [-prs]" + "\n\t\t: [-relative {0|1}]=0 [-parallel {0|1}]=0 [-min Size]" + "\n\t\t: [-algo {watson|delabella}]=watson" + "\n\t\t: [-di Value] [-ai Angle]=57.29" + "\n\t\t: [-int_vert_off {0|1}]=0 [-surf_def_off {0|1}]=0 [-adjust_min {0|1}]=0" + "\n\t\t: [-force_face_def {0|1}]=0 [-decrease {0|1}]=0" + "\n\t\t: Builds triangular mesh for the shape." + "\n\t\t: LinDefl linear deflection to control mesh quality;" + "\n\t\t: -angular angular deflection for edges in deg (~28.64 deg = 0.5 rad by default);" + "\n\t\t: -prs apply default meshing parameters for visualization purposes" + "\n\t\t: (20 deg angular deflection, 0.001 of bounding box linear deflection);" + "\n\t\t: -relative notifies that relative deflection is used (FALSE by default);" + "\n\t\t: -parallel enables parallel execution (FALSE by default);" + "\n\t\t: -algo changes core triangulation algorithm to one with specified id (watson by default);" + "\n\t\t: -min minimum size parameter limiting size of triangle's edges to prevent sinking" + "\n\t\t: into amplification in case of distorted curves and surfaces;" + "\n\t\t: -di linear deflection used to tessellate the face interior;" + "\n\t\t: -ai angular deflection inside of faces in deg (~57.29 deg = 1 rad by default);" + "\n\t\t: -int_vert_off disables insertion of internal vertices into mesh (enabled by default);" + "\n\t\t: -surf_def_off disables control of deflection of mesh from real surface (enabled by default);" + "\n\t\t: -adjust_min enables local adjustment of min size depending on edge size (FALSE by default);" + "\n\t\t: -force_face_def disables usage of shape tolerances for computing face deflection (FALSE by default);" + "\n\t\t: -decrease enforces the meshing of the shape even if current mesh satisfies the new criteria" + "\n\t\t: (FALSE by default).", + __FILE__, incrementalmesh, g); theCommands.Add("tessellate","Builds triangular mesh for the surface, run w/o args for help",__FILE__, tessellate, g); theCommands.Add("MemLeakTest","MemLeakTest",__FILE__, MemLeakTest, g); diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 523c99b903..7ea98430f3 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -4847,6 +4847,7 @@ static int VDisplay2 (Draw_Interpretor& theDI, Standard_Integer anObjHighMode = -2; Standard_Boolean toSetTrsfPers = Standard_False; Standard_Boolean toEcho = Standard_True; + Standard_Integer isAutoTriang = -1; Handle(Graphic3d_TransformPers) aTrsfPers; TColStd_SequenceOfAsciiString aNamesOfDisplayIO; AIS_DisplayStatus aDispStatus = AIS_DS_None; @@ -5048,6 +5049,17 @@ static int VDisplay2 (Draw_Interpretor& theDI, { toReDisplay = Standard_True; } + else if (aNameCase == "-autotr" + || aNameCase == "-autotrian" + || aNameCase == "-autotriang" + || aNameCase == "-autotriangulation" + || aNameCase == "-noautotr" + || aNameCase == "-noautotrian" + || aNameCase == "-noautotriang" + || aNameCase == "-noautotriangulation") + { + isAutoTriang = Draw::ParseOnOffNoIterator (theArgNb, theArgVec, anArgIter) ? 1 : 0; + } else if (aNameCase == "-erased" || aNameCase == "-load") { @@ -5089,6 +5101,10 @@ static int VDisplay2 (Draw_Interpretor& theDI, { aShape->SetZLayer (aZLayer); } + if (isAutoTriang != -1) + { + aShape->Attributes()->SetAutoTriangulation (isAutoTriang == 1); + } if (toSetTrsfPers) { aCtx->SetTransformPersistence (aShape, aTrsfPers); @@ -5157,6 +5173,10 @@ static int VDisplay2 (Draw_Interpretor& theDI, { aShape->SetZLayer (aZLayer); } + if (isAutoTriang != -1) + { + aShape->Attributes()->SetAutoTriangulation (isAutoTriang == 1); + } if (toSetTrsfPers) { aCtx->SetTransformPersistence (aShape, aTrsfPers); @@ -6554,7 +6574,7 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) "\n\t\t: [-dispMode mode] [-highMode mode]" "\n\t\t: [-layer index] [-top|-topmost|-overlay|-underlay]" "\n\t\t: [-redisplay] [-erased]" - "\n\t\t: [-noecho]" + "\n\t\t: [-noecho] [-autoTriangulation {0|1}]" "\n\t\t: name1 [name2] ... [name n]" "\n\t\t: Displays named objects." "\n\t\t: Option -local enables displaying of objects in local" @@ -6583,7 +6603,8 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) "\n\t\t: -dispmode Sets display mode for objects." "\n\t\t: -highmode Sets hilight mode for objects." "\n\t\t: -redisplay Recomputes presentation of objects." - "\n\t\t: -noecho Avoid printing of command results.", + "\n\t\t: -noecho Avoid printing of command results." + "\n\t\t: -autoTriang Enable/disable auto-triangulation for displayed shape." __FILE__, VDisplay2, group); theCommands.Add ("vnbdisplayed", diff --git a/src/XDEDRAW/XDEDRAW.cxx b/src/XDEDRAW/XDEDRAW.cxx index a10b762eee..270b07483b 100644 --- a/src/XDEDRAW/XDEDRAW.cxx +++ b/src/XDEDRAW/XDEDRAW.cxx @@ -644,12 +644,14 @@ private: XDEDRAW_XDisplayTool() : myDispMode(-2), myHiMode (-2), + myIsAutoTriang (-1), myToPrefixDocName (Standard_True), myToGetNames (Standard_True), myToExplore (Standard_False) {} //! Display single label. - Standard_Integer displayLabel (const TDF_Label& theLabel, + Standard_Integer displayLabel (Draw_Interpretor& theDI, + const TDF_Label& theLabel, const TCollection_AsciiString& theNamePrefix, const TopLoc_Location& theLoc, TCollection_AsciiString& theOutDispList) @@ -701,7 +703,7 @@ private: const TopLoc_Location aLoc = theLoc * XCAFDoc_ShapeTool::GetLocation (theLabel); for (TDF_ChildIterator aChildIter (aRefLabel); aChildIter.More(); aChildIter.Next()) { - if (displayLabel (aChildIter.Value(), aName, aLoc, theOutDispList) == 1) + if (displayLabel (theDI, aChildIter.Value(), aName, aLoc, theOutDispList) == 1) { return 1; } @@ -723,7 +725,7 @@ private: } if (!aPrs->AcceptDisplayMode (myDispMode)) { - std::cout << "Syntax error: " << aPrs->DynamicType()->Name() << " rejects " << myDispMode << " display mode\n"; + theDI << "Syntax error: " << aPrs->DynamicType()->Name() << " rejects " << myDispMode << " display mode"; return 1; } else @@ -736,11 +738,15 @@ private: if (myHiMode != -1 && !aPrs->AcceptDisplayMode (myHiMode)) { - std::cout << "Syntax error: " << aPrs->DynamicType()->Name() << " rejects " << myHiMode << " display mode\n"; + theDI << "Syntax error: " << aPrs->DynamicType()->Name() << " rejects " << myHiMode << " display mode"; return 1; } aPrs->SetHilightMode (myHiMode); } + if (myIsAutoTriang != -1) + { + aPrs->Attributes()->SetAutoTriangulation (myIsAutoTriang == 1); + } ViewerTest::Display (aName, aPrs, false); theOutDispList += aName + " "; @@ -755,7 +761,7 @@ private: Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) { - std::cout << "Error: no active view!\n"; + theDI << "Error: no active viewer"; return 1; } @@ -785,6 +791,17 @@ private: { myHiMode = TCollection_AsciiString (theArgVec[++anArgIter]).IntegerValue(); } + else if (anArgCase == "-autotr" + || anArgCase == "-autotrian" + || anArgCase == "-autotriang" + || anArgCase == "-autotriangulation" + || anArgCase == "-noautotr" + || anArgCase == "-noautotrian" + || anArgCase == "-noautotriang" + || anArgCase == "-noautotriangulation") + { + myIsAutoTriang = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter) ? 1 : 0; + } else if (anArgCase == "-docprefix" || anArgCase == "-nodocprefix") { @@ -857,7 +874,7 @@ private: if (!myDoc.IsNull() && myDoc != aDoc) { - std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; + theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; return 1; } myDoc = aDoc; @@ -866,7 +883,7 @@ private: } if (myDoc.IsNull()) { - std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; + theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; return 1; } @@ -875,7 +892,7 @@ private: if (aLabel.IsNull() || !XCAFDoc_ShapeTool::IsShape (aLabel)) { - std::cout << "Syntax error: " << aValue << " is not a valid shape label\n"; + theDI << "Syntax error: " << aValue << " is not a valid shape label"; return 1; } myLabels.Append (aLabel); @@ -883,7 +900,7 @@ private: } if (myDoc.IsNull()) { - std::cout << "Syntax error: not enough arguments\n"; + theDI << "Syntax error: not enough arguments"; return 1; } if (myLabels.IsEmpty()) @@ -894,7 +911,7 @@ private: for (TDF_LabelSequence::Iterator aLabIter (myLabels); aLabIter.More(); aLabIter.Next()) { const TDF_Label& aLabel = aLabIter.Value(); - if (displayLabel (aLabel, myToPrefixDocName ? myDocName + ":" : "", TopLoc_Location(), myOutDispList) == 1) + if (displayLabel (theDI, aLabel, myToPrefixDocName ? myDocName + ":" : "", TopLoc_Location(), myOutDispList) == 1) { return 1; } @@ -920,6 +937,7 @@ private: TDF_LabelSequence myLabels; //!< labels to display Standard_Integer myDispMode; //!< shape display mode Standard_Integer myHiMode; //!< shape highlight mode + Standard_Integer myIsAutoTriang; //!< auto-triangulation mode Standard_Boolean myToPrefixDocName; //!< flag to prefix objects with document name Standard_Boolean myToGetNames; //!< flag to use label names or tags Standard_Boolean myToExplore; //!< flag to explore assembles @@ -1394,7 +1412,7 @@ void XDEDRAW::Init(Draw_Interpretor& di) di.Add ("XDisplay", "XDisplay Doc [label1 [label2 [...]]] [-explore {on|off}] [-docPrefix {on|off}] [-names {on|off}]" - "\n\t\t: [-noupdate] [-dispMode Mode] [-highMode Mode]" + "\n\t\t: [-noupdate] [-dispMode Mode] [-highMode Mode] [-autoTriangulation {0|1}]" "\n\t\t: Displays document (parts) in 3D Viewer." "\n\t\t: -dispMode Presentation display mode." "\n\t\t: -highMode Presentation highlight mode." @@ -1402,7 +1420,8 @@ void XDEDRAW::Init(Draw_Interpretor& di) "\n\t\t: -names Use object names instead of label tag; TRUE by default." "\n\t\t: -explore Explode labels to leaves; FALSE by default." "\n\t\t: -outDispList Set the TCL variable to the list of displayed object names." - "\n\t\t: (instead of printing them to draw interpreter)", + "\n\t\t: (instead of printing them to draw interpreter)" + "\n\t\t: -autoTriang Enable/disable auto-triangulation for displayed shapes.", __FILE__, XDEDRAW_XDisplayTool::XDisplay, g); di.Add ("XWdump","Doc filename.{gif|xwd|bmp} \t: Dump contents of viewer window to XWD, GIF or BMP file", diff --git a/tests/bugs/mesh/bug25281 b/tests/bugs/mesh/bug25281 index 6a02314ed3..1ae651b465 100644 --- a/tests/bugs/mesh/bug25281 +++ b/tests/bugs/mesh/bug25281 @@ -10,7 +10,7 @@ pload XDE param xstep.cascade.unit M stepread [locate_data_file bug25281_tess_infloop_extract.step] a * -incmesh a_1 0.0002 1 +incmesh a_1 0.0002 -parallel checktrinfo a_1 -tri -nod diff --git a/tests/hlr/poly_hlr/bug23625_1 b/tests/hlr/poly_hlr/bug23625_1 index 27ea8b6e14..9484d87381 100644 --- a/tests/hlr/poly_hlr/bug23625_1 +++ b/tests/hlr/poly_hlr/bug23625_1 @@ -13,6 +13,6 @@ restore [locate_data_file bug23625_a1.brep] a # workaround bug 0031426 until fix vinit View1 vdefaults -autoTriang 0 -incmesh a 7.6 12 +incmesh a 7.6 COMPUTE_HLR $viewname $algotype diff --git a/tests/mesh/advanced_incmesh/begin b/tests/mesh/advanced_incmesh/begin index 807dcb2a59..8ed3003753 100644 --- a/tests/mesh/advanced_incmesh/begin +++ b/tests/mesh/advanced_incmesh/begin @@ -1,3 +1,3 @@ set command incmesh set group advanced -set parallel "" +set parallel 0 diff --git a/tests/mesh/advanced_incmesh_parallel/begin b/tests/mesh/advanced_incmesh_parallel/begin index 579f49fcc7..cdd1e76439 100644 --- a/tests/mesh/advanced_incmesh_parallel/begin +++ b/tests/mesh/advanced_incmesh_parallel/begin @@ -1,3 +1,3 @@ set command incmesh set group advanced -set parallel -parallel +set parallel 1 diff --git a/tests/mesh/end b/tests/mesh/end index 5a69d8b266..fbcc8b3c97 100644 --- a/tests/mesh/end +++ b/tests/mesh/end @@ -31,13 +31,13 @@ if { [string compare $command "shading"] == 0 } { } if { [string compare $command "incmesh"] == 0 } { - if { [string compare $parallel "-parallel"] != 0 || [info exists count_parallel] == 0 } { - set count_parallel 1 + if { [string compare $parallel "1"] != 0 || [info exists count_parallel] == 0 } { + set count_parallel 1 } for {set i 1} {$i <= $count_parallel} {incr i} { - tclean res - puts "i = $i" - incmesh res ${Deflection} ${parallel} + tclean res + puts "i = $i" + incmesh res ${Deflection} -parallel ${parallel} } } diff --git a/tests/mesh/standard_incmesh/begin b/tests/mesh/standard_incmesh/begin index 007b5372cb..be09a2056c 100644 --- a/tests/mesh/standard_incmesh/begin +++ b/tests/mesh/standard_incmesh/begin @@ -1,3 +1,3 @@ set command incmesh set group standard -set parallel "" +set parallel 0 diff --git a/tests/mesh/standard_incmesh_parallel/begin b/tests/mesh/standard_incmesh_parallel/begin index 378b383444..aefc3e6a8b 100644 --- a/tests/mesh/standard_incmesh_parallel/begin +++ b/tests/mesh/standard_incmesh_parallel/begin @@ -1,3 +1,3 @@ set command incmesh set group standard -set parallel -parallel +set parallel 1 diff --git a/tests/perf/mesh/bug26889_1 b/tests/perf/mesh/bug26889_1 index 6d358fdb49..f8f0192a3b 100644 --- a/tests/perf/mesh/bug26889_1 +++ b/tests/perf/mesh/bug26889_1 @@ -8,7 +8,7 @@ pload XDE stepread [locate_data_file bug26889_export.step] a * dchrono t restart -incmesh a_1 0.01 1 +incmesh a_1 0.01 -parallel dchrono t stop counter incmesh checktrinfo a_1 -tri 525271 -nod 263456 -defl 0.069482224632795617 -tol_abs_defl 1e-6 diff --git a/tests/perf/mesh/bug26889_2 b/tests/perf/mesh/bug26889_2 index d1ae16a345..893cd4f563 100644 --- a/tests/perf/mesh/bug26889_2 +++ b/tests/perf/mesh/bug26889_2 @@ -8,7 +8,7 @@ pload XDE stepread [locate_data_file bug26889_export.step] a * dchrono t restart -incmesh a_1 0.1 1 +incmesh a_1 0.1 -parallel dchrono t stop counter incmesh checktrinfo a_1 -tri 68779 -nod 34737 -defl 0.24900556935704937 -tol_abs_defl 1e-6 diff --git a/tests/perf/mesh/bug26889_3 b/tests/perf/mesh/bug26889_3 index e87d2483e9..c5e3a94f6b 100644 --- a/tests/perf/mesh/bug26889_3 +++ b/tests/perf/mesh/bug26889_3 @@ -8,7 +8,7 @@ pload XDE stepread [locate_data_file bug26889_export.step] a * dchrono t restart -incmesh a_1 1.0 1 +incmesh a_1 1.0 -parallel dchrono t stop counter incmesh checktrinfo a_1 -tri 12469 -nod 6503 -defl 1.2783003174746328 -tol_abs_defl 1e-6 diff --git a/tests/v3d/bugs/bug23200_1 b/tests/v3d/bugs/bug23200_1 index 45e593a483..62677d3f4c 100644 --- a/tests/v3d/bugs/bug23200_1 +++ b/tests/v3d/bugs/bug23200_1 @@ -10,10 +10,8 @@ pload MODELING VISUALIZATION vinit View1 vclear vaxo -vsetdispmode 1 -vdefaults -autoTriang off pcone c 0 5 10 -vdisplay c +vdisplay c -dispMode 1 -autoTriang off vfit set aColor [vreadpixel 200 77 rgb name]