diff --git a/samples/tcl/snowflake.tcl b/samples/tcl/snowflake.tcl index b9e4bafee4..2819d7ec0f 100644 --- a/samples/tcl/snowflake.tcl +++ b/samples/tcl/snowflake.tcl @@ -121,21 +121,21 @@ eval compound [explode mass w] mass compound sample occ name material sheets scale mass text compound snowflake lines text drawing +bounding snowflake -save x1 y1 z1 x2 y2 z2 # display in 3d view vinit Driver1/Viewer1/View1 w=1024 h=768 vdisplay snowflake lines text vrenderparams -msaa 8 -vsetcolor snowflake 0 0 0 -vsetcolor lines 0 0 0 -vsetcolor text 0 0 0 +vsetcolor snowflake BLACK +vsetcolor lines BLACK +vsetcolor text BLACK vbackground -color WHITE vtop vfit # add dimension: # detect vertices extremal in X direction -bounding snowflake -save x1 y1 z1 x2 y2 z2 plane f1 x1 0 0 1 0 0 plane f2 x2 0 0 1 0 0 mkface f1 f1 @@ -159,7 +159,3 @@ for {set i 1} {$i <= 2} {incr i} { } } vdimension length -length -shapes $v1 $v2 -plane xoy -value 0.001 -dispunits mm -showunits -flyout 70 -label above -color black -text 5 3d sh - -if { [regexp HAVE_GL2PS [dversion]] } { - puts "You can use command vexport to generate PDF: vexport your_file_path.pdf" -} diff --git a/src/BRepTools/BRepTools.cxx b/src/BRepTools/BRepTools.cxx index f626673fff..327fa12a60 100644 --- a/src/BRepTools/BRepTools.cxx +++ b/src/BRepTools/BRepTools.cxx @@ -903,25 +903,61 @@ void BRepTools::RemoveUnusedPCurves(const TopoDS_Shape& S) //purpose : //======================================================================= -Standard_Boolean BRepTools::Triangulation(const TopoDS_Shape& S, - const Standard_Real deflec) +Standard_Boolean BRepTools::Triangulation(const TopoDS_Shape& theShape, + const Standard_Real theLinDefl, + const Standard_Boolean theToCheckFreeEdges) { - TopExp_Explorer exf, exe; - TopLoc_Location l; - Handle(Poly_Triangulation) T; - Handle(Poly_PolygonOnTriangulation) Poly; - - for (exf.Init(S, TopAbs_FACE); exf.More(); exf.Next()) { - const TopoDS_Face& F = TopoDS::Face(exf.Current()); - T = BRep_Tool::Triangulation(F, l); - if (T.IsNull() || (T->Deflection() > deflec)) + TopExp_Explorer anEdgeIter; + TopLoc_Location aDummyLoc; + for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next()) + { + const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current()); + const Handle(Poly_Triangulation)& aTri = BRep_Tool::Triangulation (aFace, aDummyLoc); + if (aTri.IsNull() + || aTri->Deflection() > theLinDefl) + { return Standard_False; - for (exe.Init(F, TopAbs_EDGE); exe.More(); exe.Next()) { - const TopoDS_Edge& E = TopoDS::Edge(exe.Current()); - Poly = BRep_Tool::PolygonOnTriangulation(E, T, l); - if (Poly.IsNull()) return Standard_False; + } + + for (anEdgeIter.Init (aFace, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Current()); + const Handle(Poly_PolygonOnTriangulation)& aPoly = BRep_Tool::PolygonOnTriangulation (anEdge, aTri, aDummyLoc); + if (aPoly.IsNull()) + { + return Standard_False; + } } } + if (!theToCheckFreeEdges) + { + return Standard_True; + } + + Handle(Poly_Triangulation) anEdgeTri; + for (anEdgeIter.Init (theShape, TopAbs_EDGE, TopAbs_FACE); anEdgeIter.More(); anEdgeIter.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Current()); + const Handle(Poly_Polygon3D)& aPolygon = BRep_Tool::Polygon3D (anEdge, aDummyLoc); + if (!aPolygon.IsNull()) + { + if (aPolygon->Deflection() > theLinDefl) + { + return Standard_False; + } + } + else + { + const Handle(Poly_PolygonOnTriangulation)& aPoly = BRep_Tool::PolygonOnTriangulation (anEdge, anEdgeTri, aDummyLoc); + if (aPoly.IsNull() + || anEdgeTri.IsNull() + || anEdgeTri->Deflection() > theLinDefl) + { + return Standard_False; + } + } + } + return Standard_True; } diff --git a/src/BRepTools/BRepTools.hxx b/src/BRepTools/BRepTools.hxx index e1b180128b..5cfc5f7259 100644 --- a/src/BRepTools/BRepTools.hxx +++ b/src/BRepTools/BRepTools.hxx @@ -162,10 +162,18 @@ public: //! refer to surfaces not belonging to any face of Standard_EXPORT static void RemoveUnusedPCurves (const TopoDS_Shape& S); - //! verifies that each face from the shape has got - //! a triangulation with a deflection <= deflec and - //! the edges a discretisation on this triangulation. - Standard_EXPORT static Standard_Boolean Triangulation (const TopoDS_Shape& S, const Standard_Real deflec); + //! Verifies that each Face from the shape has got a triangulation with a deflection smaller or equal to specified one + //! and the Edges a discretization on this triangulation. + //! @param theShape [in] shape to verify + //! @param theLinDefl [in] maximum allowed linear deflection + //! @param theToCheckFreeEdges [in] if TRUE, then free Edges are required to have 3D polygon + //! @return FALSE if input Shape contains Faces without triangulation, + //! or that triangulation has worse (greater) deflection than specified one, + //! or Edges in Shape lack polygons on triangulation + //! or free Edges in Shape lack 3D polygons + Standard_EXPORT static Standard_Boolean Triangulation (const TopoDS_Shape& theShape, + const Standard_Real theLinDefl, + const Standard_Boolean theToCheckFreeEdges = Standard_False); //! Returns True if the distance between the two //! vertices is lower than their tolerance. diff --git a/src/Select3D/Select3D_SensitiveSegment.cxx b/src/Select3D/Select3D_SensitiveSegment.cxx index 8a0051ded0..520741138b 100644 --- a/src/Select3D/Select3D_SensitiveSegment.cxx +++ b/src/Select3D/Select3D_SensitiveSegment.cxx @@ -31,6 +31,7 @@ Select3D_SensitiveSegment::Select3D_SensitiveSegment (const Handle(SelectMgr_Ent const gp_Pnt& theLastPnt) : Select3D_SensitiveEntity (theOwnerId) { + mySFactor = 3; myStart = theFirstPnt; myEnd = theLastPnt; } diff --git a/src/StdPrs/StdPrs_ShadedShape.cxx b/src/StdPrs/StdPrs_ShadedShape.cxx index 996c3840c8..69bf604cc3 100644 --- a/src/StdPrs/StdPrs_ShadedShape.cxx +++ b/src/StdPrs/StdPrs_ShadedShape.cxx @@ -542,9 +542,6 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs, return; } - // add wireframe presentation for isolated edges and vertices - wireframeFromShape (thePrs, theShape, theDrawer); - // Use automatic re-triangulation with deflection-check logic only if this feature is enable if (theDrawer->IsAutoTriangulation()) { @@ -552,6 +549,9 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs, StdPrs_ToolTriangulatedShape::Tessellate (theShape, theDrawer); } + // add wireframe presentation for isolated edges and vertices + wireframeFromShape (thePrs, theShape, theDrawer); + // add special wireframe presentation for faces without triangulation wireframeNoTriangFacesFromShape (thePrs, theShape, theDrawer); diff --git a/src/StdPrs/StdPrs_ToolTriangulatedShape.cxx b/src/StdPrs/StdPrs_ToolTriangulatedShape.cxx index 743bc9774f..07db4abeaf 100644 --- a/src/StdPrs/StdPrs_ToolTriangulatedShape.cxx +++ b/src/StdPrs/StdPrs_ToolTriangulatedShape.cxx @@ -240,7 +240,7 @@ void StdPrs_ToolTriangulatedShape::Normal (const TopoDS_Face& theFace, Standard_Boolean StdPrs_ToolTriangulatedShape::IsTessellated (const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer) { - return BRepTools::Triangulation (theShape, Prs3d::GetDeflection (theShape, theDrawer)); + return BRepTools::Triangulation (theShape, Prs3d::GetDeflection (theShape, theDrawer), true); } // ======================================================================= diff --git a/src/StdPrs/StdPrs_WFShape.cxx b/src/StdPrs/StdPrs_WFShape.cxx index f9d5ea929b..c6aeea6c7f 100644 --- a/src/StdPrs/StdPrs_WFShape.cxx +++ b/src/StdPrs/StdPrs_WFShape.cxx @@ -100,6 +100,11 @@ void StdPrs_WFShape::Add (const Handle(Prs3d_Presentation)& thePresentation, return; } + if (theDrawer->IsAutoTriangulation()) + { + StdPrs_ToolTriangulatedShape::Tessellate (theShape, theDrawer); + } + // draw triangulation-only edges if (Handle(Graphic3d_ArrayOfPrimitives) aTriFreeEdges = AddEdgesOnTriangulation (theShape, Standard_True)) { diff --git a/src/StdSelect/StdSelect_BRepSelectionTool.cxx b/src/StdSelect/StdSelect_BRepSelectionTool.cxx index 6c74978253..284e2c0f0a 100644 --- a/src/StdSelect/StdSelect_BRepSelectionTool.cxx +++ b/src/StdSelect/StdSelect_BRepSelectionTool.cxx @@ -113,8 +113,8 @@ void StdSelect_BRepSelectionTool::Load (const Handle(SelectMgr_Selection)& theSe const Standard_Real theMaxParam) { Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority; - - if( isAutoTriangulation && !BRepTools::Triangulation (theShape, Precision::Infinite()) ) + if (isAutoTriangulation + && !BRepTools::Triangulation (theShape, Precision::Infinite(), true)) { BRepMesh_IncrementalMesh aMesher(theShape, theDeflection, Standard_False, theDeviationAngle); } @@ -448,7 +448,15 @@ void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape if (!aPoints.IsNull() && !aPoints->IsEmpty()) { - theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints); + if (aPoints->Length() == 2) + { + // don't waste memory, create a segment + theSensitive = new Select3D_SensitiveSegment (theOwner, aPoints->First(), aPoints->Last()); + } + else + { + theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints); + } return; } diff --git a/tests/bugs/vis/bug25098 b/tests/bugs/vis/bug25098 index dec8510ac4..c434bc741d 100644 --- a/tests/bugs/vis/bug25098 +++ b/tests/bugs/vis/bug25098 @@ -1,10 +1,7 @@ puts "============" -puts "OCC25098" +puts "0025098: Visualization - Calculation of depth on selection of a wire is not accurate" puts "============" puts "" -#################################################################################### -# Visualization - Calculation of depth on selection of a wire is not accurate -#################################################################################### proc ParseEntityInfo {theInfoString} { set aStringArr [split $theInfoString " "] @@ -34,7 +31,7 @@ proc ParseEntityInfo {theInfoString} { } pload VISUALIZATION MODELING -vinit +vinit View1 box b 10 10 10 vdisplay b @@ -130,9 +127,9 @@ if {[string equal $aWireType "Detected Shape: TopoDS_TWire"] == 0} { } set aWireChildSensitiveType [string trim [lindex $aOut [expr $aWireTypeStringNb + 1]]] -if {[string equal $aWireChildSensitiveType "Detected Child: Select3D_SensitiveCurve"] == 0} { +if {[string equal $aWireChildSensitiveType "Detected Child: Select3D_SensitiveSegment"] == 0} { puts "Wrong type of wire's inner sensitive! Value is: " puts $aWireChildSensitiveType - puts "Must be: Detected Child: Select3D_SensitiveCurve" + puts "Must be: Detected Child: Select3D_SensitiveSegment" puts "ERROR" } diff --git a/tests/bugs/vis/bug31425 b/tests/bugs/vis/bug31425 new file mode 100644 index 0000000000..341d9b3c6b --- /dev/null +++ b/tests/bugs/vis/bug31425 @@ -0,0 +1,17 @@ +puts "=============" +puts "0031425: Visualization - free Edge has selection sensitivity inconsistent to presentation" +puts "=============" + +pload MODELING VISUALIZATION +circle circ 150 0 200 1 0 0 100 +mkedge e circ +wire w e +vclear +vinit View1 +vdisplay e +vaspects e -setLineWidth 2 +vfit +vviewparams -scale 25.38 -proj 0.5 -0.5 0.5 -up -0.4 0.4 0.8 -at 125.128 46.4744 271.346 +checkpoint pick [vmoveto 275 175] {150 31 294} 1.0 + +vdump $::imagedir/${::casename}.png diff --git a/tests/hlr/begin b/tests/hlr/begin index c06d28ab84..5eb81b45c2 100644 --- a/tests/hlr/begin +++ b/tests/hlr/begin @@ -11,7 +11,7 @@ set depsilon 1.e-7 proc COMPUTE_HLR {viewname algotype} { uplevel #0 top uplevel #0 clear - uplevel #0 vinit + uplevel #0 vinit View1 uplevel #0 vdisplay a uplevel #0 $viewname uplevel #0 vcomputehlr a result -algoType $algotype diff --git a/tests/hlr/poly_hlr/bug23625_1 b/tests/hlr/poly_hlr/bug23625_1 index 79d0e80de2..27ea8b6e14 100644 --- a/tests/hlr/poly_hlr/bug23625_1 +++ b/tests/hlr/poly_hlr/bug23625_1 @@ -3,8 +3,16 @@ puts "OCC23625" puts "============" puts "" +puts "REQUIRED All: Meshing statuses: SelfIntersectingWire Failure" + set viewname "vfront" -set length 28096.2 +set length 28388 restore [locate_data_file bug23625_a1.brep] a + +# workaround bug 0031426 until fix +vinit View1 +vdefaults -autoTriang 0 +incmesh a 7.6 12 + COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/bug23625_2 b/tests/hlr/poly_hlr/bug23625_2 index bf6139d390..568c972e7a 100644 --- a/tests/hlr/poly_hlr/bug23625_2 +++ b/tests/hlr/poly_hlr/bug23625_2 @@ -4,7 +4,7 @@ puts "============" puts "" set viewname "vfront" -set length 28990.3 +set length 28991.6 restore [locate_data_file bug23625_a2.brep] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/bug25813_3 b/tests/hlr/poly_hlr/bug25813_3 index 9f874b1c1c..9cddd23203 100644 --- a/tests/hlr/poly_hlr/bug25813_3 +++ b/tests/hlr/poly_hlr/bug25813_3 @@ -1,4 +1,4 @@ -puts "TODO OCC30286 Linux: Error : The length of result shape is 302.441, expected 301.998" +puts "TODO OCC30286 Linux: Error : The length of result shape is 302.443, expected 301.999" puts "===========================================" puts "OCC25813: regression in Hidden Line Removal" @@ -6,7 +6,7 @@ puts "===========================================" puts "" set viewname "" -set length 301.998 +set length 301.999 ptorus a 30 10