From c7ba457824032134781cfec0069260b657dccb08 Mon Sep 17 00:00:00 2001 From: kgv Date: Sun, 10 Sep 2017 21:24:56 +0300 Subject: [PATCH] 0027869: Visualization - AIS_ConnectedInteractive does not support exact HLR mode AIS_ConnectedInteractive now shares HLR computation code with AIS_Shape. BRepTools_WireExplorer::Orientation() now returns TopAbs_FORWARD instead of throwing exception in case of infinite Edge without vertices. StdSelect_BRepSelectionTool::GetSensitiveForFace() now creates Select3D_SensitiveCurve from 2 points in case of infinite Edge instead of Select3D_SensitiveFace. --- src/AIS/AIS_ConnectedInteractive.cxx | 48 +--- src/AIS/AIS_Shape.cxx | 217 ++++++---------- src/AIS/AIS_Shape.hxx | 93 +++++-- src/BRepTools/BRepTools_WireExplorer.cxx | 7 + src/StdSelect/StdSelect_BRepSelectionTool.cxx | 232 +++++++++--------- tests/bugs/vis/bug129_1 | 47 ++-- tests/bugs/vis/bug27869 | 14 ++ 7 files changed, 299 insertions(+), 359 deletions(-) create mode 100644 tests/bugs/vis/bug27869 diff --git a/src/AIS/AIS_ConnectedInteractive.cxx b/src/AIS/AIS_ConnectedInteractive.cxx index 2919ddd2c7..5f3d4883e0 100644 --- a/src/AIS/AIS_ConnectedInteractive.cxx +++ b/src/AIS/AIS_ConnectedInteractive.cxx @@ -164,54 +164,10 @@ void AIS_ConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector //purpose : //======================================================================= void AIS_ConnectedInteractive::Compute (const Handle(Prs3d_Projector)& theProjector, - const Handle(Prs3d_Presentation)& thePresentation, + const Handle(Prs3d_Presentation)& thePrs, const TopoDS_Shape& theShape) { - if (myShape.IsNull()) - { - return; - } - - switch (theShape.ShapeType()) - { - case TopAbs_VERTEX: - case TopAbs_EDGE: - case TopAbs_WIRE: - { - thePresentation->SetDisplayPriority (4); - StdPrs_WFShape::Add (thePresentation, theShape, myDrawer); - break; - } - default: - { - Handle(Prs3d_Drawer) aDefaultDrawer = GetContext()->DefaultDrawer(); - if (aDefaultDrawer->DrawHiddenLine()) - { - myDrawer->EnableDrawHiddenLine(); - } - else - { - myDrawer->DisableDrawHiddenLine(); - } - - Aspect_TypeOfDeflection aPrevDeflection = aDefaultDrawer->TypeOfDeflection(); - aDefaultDrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE); - - // process HLRAngle and HLRDeviationCoefficient() - Standard_Real aPrevAngle = myDrawer->HLRAngle(); - Standard_Real aNewAngle = aDefaultDrawer->HLRAngle(); - if (myDrawer->IsAutoTriangulation() && - Abs (aNewAngle - aPrevAngle) > Precision::Angular()) - { - BRepTools::Clean (theShape); - } - - myDrawer->SetHLRAngle (aNewAngle); - myDrawer->SetHLRDeviationCoefficient (aDefaultDrawer->HLRDeviationCoefficient()); - StdPrs_HLRPolyShape::Add (thePresentation, theShape, myDrawer, theProjector); - aDefaultDrawer->SetTypeOfDeflection (aPrevDeflection); - } - } + AIS_Shape::computeHlrPresentation (theProjector, thePrs, theShape, myDrawer); } //======================================================================= diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 5b6bff4ccf..b5ead33d8d 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include #include @@ -157,14 +159,11 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat OCC_CATCH_SIGNALS StdPrs_WFShape::Add (aPrs, myshape, myDrawer); } - catch (Standard_Failure) + catch (Standard_Failure const& anException) { - #ifdef OCCT_DEBUG - cout << "AIS_Shape::Compute() failed" << endl; - cout << "a Shape should be incorrect : No Compute can be maked on it " << endl; - #endif - // presentation of the bounding box is calculated - // Compute(aPresentationManager,aPrs,2); + Message::DefaultMessenger()->Send (TCollection_AsciiString() + + "Error: AIS_Shape::Compute() wireframe presentation builder has failed (" + + anException.GetMessageString() + ")", Message_Fail); } break; } @@ -191,11 +190,11 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat && !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(), myUVOrigin, myUVRepeat, myUVScale); } - catch (Standard_Failure) + catch (Standard_Failure const& anException) { - #ifdef OCCT_DEBUG - cout << "AIS_Shape::Compute() in ShadingMode failed" << endl; - #endif + Message::DefaultMessenger()->Send (TCollection_AsciiString() + + "Error: AIS_Shape::Compute() shaded presentation builder has failed (" + + anException.GetMessageString() + ")", Message_Fail); StdPrs_WFShape::Add (aPrs, myshape, myDrawer); } } @@ -227,150 +226,88 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat } //======================================================================= -//function : Compute -//purpose : Hidden Line Removal +//function : computeHlrPresentation +//purpose : //======================================================================= -void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation) +void AIS_Shape::computeHlrPresentation (const Handle(Prs3d_Projector)& theProjector, + const Handle(Prs3d_Presentation)& thePrs, + const TopoDS_Shape& theShape, + const Handle(Prs3d_Drawer)& theDrawer) { - Compute(aProjector,aPresentation,myshape); -} - -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Geom_Transformation)& TheTrsf, - const Handle(Prs3d_Presentation)& aPresentation) -{ - const TopLoc_Location& loc = myshape.Location(); - TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc); - Compute(aProjector,aPresentation,shbis); -} - -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation, - const TopoDS_Shape& SH) -{ - if (SH.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator anExplor (SH); - - if (!anExplor.More()) // Shape vide -> Assemblage vide. - return; + if (theShape.IsNull()) + { + return; } - Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer(); - if (defdrawer->DrawHiddenLine()) - {myDrawer->EnableDrawHiddenLine();} - else {myDrawer->DisableDrawHiddenLine();} - - Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection(); - defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE); - - if (myDrawer->IsAutoTriangulation()) + switch (theShape.ShapeType()) { - // coefficients for calculation - Standard_Real aPrevAngle, aNewAngle, aPrevCoeff, aNewCoeff; - Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle (aNewAngle, aPrevAngle); - Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient (aNewCoeff, aPrevCoeff); - if (((Abs (aNewAngle - aPrevAngle) > Precision::Angular()) && isOwnHLRDeviationAngle) || - ((Abs (aNewCoeff - aPrevCoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient)) + case TopAbs_VERTEX: + case TopAbs_EDGE: + case TopAbs_WIRE: { - BRepTools::Clean(SH); + thePrs->SetDisplayPriority (4); + StdPrs_WFShape::Add (thePrs, theShape, theDrawer); + return; + } + case TopAbs_COMPOUND: + { + TopoDS_Iterator anExplor (theShape); + if (!anExplor.More()) + { + return; + } + break; + } + default: + { + break; } } - + + const Handle(Prs3d_Drawer)& aDefDrawer = theDrawer->Link(); + if (aDefDrawer->DrawHiddenLine()) { - try { + theDrawer->EnableDrawHiddenLine(); + } + else + { + theDrawer->DisableDrawHiddenLine(); + } + + const Aspect_TypeOfDeflection aPrevDef = aDefDrawer->TypeOfDeflection(); + aDefDrawer->SetTypeOfDeflection (Aspect_TOD_RELATIVE); + if (theDrawer->IsAutoTriangulation()) + { + StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (theShape, theDrawer, Standard_True); + } + + { + try + { OCC_CATCH_SIGNALS - switch (TypeOfHLR()) { + switch (theDrawer->TypeOfHLR()) + { case Prs3d_TOH_Algo: - StdPrs_HLRShape::Add (aPresentation, SH, myDrawer, aProjector); + StdPrs_HLRShape::Add (thePrs, theShape, theDrawer, theProjector); break; case Prs3d_TOH_PolyAlgo: default: - StdPrs_HLRPolyShape::Add (aPresentation, SH, myDrawer, aProjector); + StdPrs_HLRPolyShape::Add (thePrs, theShape, theDrawer, theProjector); break; } } - catch (Standard_Failure) { -#ifdef OCCT_DEBUG - cout <<"AIS_Shape::Compute(Proj) HLR Algorithm failed" << endl; -#endif - StdPrs_WFShape::Add(aPresentation,SH,myDrawer); + catch (Standard_Failure const& anException) + { + Message::DefaultMessenger()->Send (TCollection_AsciiString() + + "Error: AIS_Shape::Compute() HLR Algorithm has failed (" + + anException.GetMessageString() + ")", Message_Fail); + StdPrs_WFShape::Add (thePrs, theShape, theDrawer); } } - defdrawer->SetTypeOfDeflection (prevdef); + aDefDrawer->SetTypeOfDeflection (aPrevDef); } -//======================================================================= -//function : SelectionType -//purpose : gives the type according to the Index of Selection Mode -//======================================================================= - -TopAbs_ShapeEnum AIS_Shape::SelectionType(const Standard_Integer aMode) -{ - switch(aMode){ - case 1: - return TopAbs_VERTEX; - case 2: - return TopAbs_EDGE; - case 3: - return TopAbs_WIRE; - case 4: - return TopAbs_FACE; - case 5: - return TopAbs_SHELL; - case 6: - return TopAbs_SOLID; - case 7: - return TopAbs_COMPSOLID; - case 8: - return TopAbs_COMPOUND; - case 0: - default: - return TopAbs_SHAPE; - } - -} -//======================================================================= -//function : SelectionType -//purpose : gives the SelectionMode according to the Type od Decomposition... -//======================================================================= -Standard_Integer AIS_Shape::SelectionMode(const TopAbs_ShapeEnum aType) -{ - switch(aType){ - case TopAbs_VERTEX: - return 1; - case TopAbs_EDGE: - return 2; - case TopAbs_WIRE: - return 3; - case TopAbs_FACE: - return 4; - case TopAbs_SHELL: - return 5; - case TopAbs_SOLID: - return 6; - case TopAbs_COMPSOLID: - return 7; - case TopAbs_COMPOUND: - return 8; - case TopAbs_SHAPE: - default: - return 0; - } -} - - //======================================================================= //function : ComputeSelection //purpose : @@ -393,7 +330,8 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, // POP protection against crash in low layers Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer); - try { + try + { OCC_CATCH_SIGNALS StdSelect_BRepSelectionTool::Load(aSelection, this, @@ -402,9 +340,14 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, aDeflection, myDrawer->HLRAngle(), myDrawer->IsAutoTriangulation()); - } catch ( Standard_Failure ) { -// cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<Send (TCollection_AsciiString() + + "Error: AIS_Shape::ComputeSelection(" + aMode + ") has failed (" + + anException.GetMessageString() + ")", Message_Fail); + if (aMode == 0) + { aSelection->Clear(); Bnd_Box B = BoundingBox(); Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this); diff --git a/src/AIS/AIS_Shape.hxx b/src/AIS/AIS_Shape.hxx index 396a9e98f5..d9424ee9df 100644 --- a/src/AIS/AIS_Shape.hxx +++ b/src/AIS/AIS_Shape.hxx @@ -211,23 +211,42 @@ public: //! Returns the transparency attributes of the shape accordingly to //! the current facing model; Standard_EXPORT virtual Standard_Real Transparency() const Standard_OVERRIDE; - - //! Activates the same TopAbs shape enumerations as - //! those used by SelectionMode assigning a type to the mode aDecompositionMode. - Standard_EXPORT static TopAbs_ShapeEnum SelectionType (const Standard_Integer aDecompositionMode); - - //! Establishes an equivalence between a mode and the - //! type, aShapeType, of selection. The correspondences are as follows: - //! - mode 0 - Shape - //! - mode 1 - Vertex - //! - mode 2 - Edge - //! - mode 3 - Wire - //! - mode 4 - Face - //! - mode 5 - Shell - //! - mode 6 - Solid - //! - mode 7 - Compsolid - //! - mode 8 - Compound - Standard_EXPORT static Standard_Integer SelectionMode (const TopAbs_ShapeEnum aShapeType); + + //! Return shape type for specified selection mode. + static TopAbs_ShapeEnum SelectionType (const Standard_Integer theSelMode) + { + switch (theSelMode) + { + case 1: return TopAbs_VERTEX; + case 2: return TopAbs_EDGE; + case 3: return TopAbs_WIRE; + case 4: return TopAbs_FACE; + case 5: return TopAbs_SHELL; + case 6: return TopAbs_SOLID; + case 7: return TopAbs_COMPSOLID; + case 8: return TopAbs_COMPOUND; + case 0: return TopAbs_SHAPE; + } + return TopAbs_SHAPE; + } + + //! Return selection mode for specified shape type. + static Standard_Integer SelectionMode (const TopAbs_ShapeEnum theShapeType) + { + switch (theShapeType) + { + case TopAbs_VERTEX: return 1; + case TopAbs_EDGE: return 2; + case TopAbs_WIRE: return 3; + case TopAbs_FACE: return 4; + case TopAbs_SHELL: return 5; + case TopAbs_SOLID: return 6; + case TopAbs_COMPSOLID: return 7; + case TopAbs_COMPOUND: return 8; + case TopAbs_SHAPE: return 0; + } + return 0; + } public: //! @name methods to alter texture mapping properties @@ -256,13 +275,31 @@ public: //! @name methods to alter texture mapping properties protected: - Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE; - - Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE; - - Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE; - - Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE; + //! Compute normal presentation. + Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, + const Handle(Prs3d_Presentation)& thePrs, + const Standard_Integer theMode) Standard_OVERRIDE; + + //! Compute projected presentation. + virtual void Compute (const Handle(Prs3d_Projector)& theProjector, + const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE + { + computeHlrPresentation (theProjector, thePrs, myshape, myDrawer); + } + + //! Compute projected presentation with transformation. + virtual void Compute (const Handle(Prs3d_Projector)& theProjector, + const Handle(Geom_Transformation)& theTrsf, + const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE + { + const TopLoc_Location& aLoc = myshape.Location(); + const TopoDS_Shape aShape = myshape.Located (TopLoc_Location (theTrsf->Trsf()) * aLoc); + computeHlrPresentation (theProjector, thePrs, aShape, myDrawer); + } + + //! Compute selection. + Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode) Standard_OVERRIDE; Standard_EXPORT void LoadRecomputable (const Standard_Integer TheMode); @@ -274,9 +311,13 @@ protected: Standard_EXPORT void setMaterial (const Handle(Prs3d_Drawer)& theDrawer, const Graphic3d_MaterialAspect& theMaterial, const Standard_Boolean theToKeepColor, const Standard_Boolean theToKeepTransp) const; -private: +public: - Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation, const TopoDS_Shape& ashape); + //! Compute HLR presentation for specified shape. + Standard_EXPORT static void computeHlrPresentation (const Handle(Prs3d_Projector)& theProjector, + const Handle(Prs3d_Presentation)& thePrs, + const TopoDS_Shape& theShape, + const Handle(Prs3d_Drawer)& theDrawer); protected: diff --git a/src/BRepTools/BRepTools_WireExplorer.cxx b/src/BRepTools/BRepTools_WireExplorer.cxx index 49e4e4e6f0..9fa20bdeba 100644 --- a/src/BRepTools/BRepTools_WireExplorer.cxx +++ b/src/BRepTools/BRepTools_WireExplorer.cxx @@ -598,6 +598,13 @@ const TopoDS_Edge& BRepTools_WireExplorer::Current()const //======================================================================= TopAbs_Orientation BRepTools_WireExplorer::Orientation() const { + if (myVertex.IsNull() + && !myEdge.IsNull()) + { + // infinite edge + return TopAbs_FORWARD; + } + TopoDS_Iterator it(myEdge,Standard_False); while (it.More()) { if (myVertex.IsSame(it.Value())) diff --git a/src/StdSelect/StdSelect_BRepSelectionTool.cxx b/src/StdSelect/StdSelect_BRepSelectionTool.cxx index d4dee25c7d..5a69d1846e 100644 --- a/src/StdSelect/StdSelect_BRepSelectionTool.cxx +++ b/src/StdSelect/StdSelect_BRepSelectionTool.cxx @@ -565,11 +565,8 @@ Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_ const Standard_Real theMaxParam, const Standard_Boolean theInteriorFlag) { - // check if there is triangulation of the face... TopLoc_Location aLoc; - Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLoc); - - if (!aTriangulation.IsNull()) + if (Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLoc)) { Handle(Select3D_SensitiveTriangulation) STG = new Select3D_SensitiveTriangulation (theOwner, aTriangulation, aLoc, theInteriorFlag); theSensitiveList.Append (STG); @@ -578,184 +575,185 @@ Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_ // for faces with triangulation bugs or without autotriangulation .... // very ugly and should not even exist ... - BRepAdaptor_Surface BS; - BS.Initialize (theFace); - - Standard_Real FirstU = BS.FirstUParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstUParameter(); - Standard_Real LastU = BS.LastUParameter() >= Precision::Infinite() ? theMaxParam : BS.LastUParameter(); - Standard_Real FirstV = BS.FirstVParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstVParameter(); - Standard_Real LastV = BS.LastVParameter() >= Precision::Infinite() ? theMaxParam : BS.LastVParameter(); - + BRepAdaptor_Surface BS (theFace); if (BS.GetType() == GeomAbs_Plane) { - gp_Pnt pcur; - Handle(TColgp_HArray1OfPnt) P = new TColgp_HArray1OfPnt (1, 5); - BS.D0 (FirstU, FirstV, pcur); - P->SetValue (1, pcur); - BS.D0 (LastU, FirstV, pcur); - P->SetValue (2, pcur); - BS.D0 (LastU, LastV, pcur); - P->SetValue (3, pcur); - BS.D0 (FirstU, LastV, pcur); - P->SetValue (4, pcur); - P->SetValue (5, P->Value (1)); + const Standard_Real aFirstU = BS.FirstUParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstUParameter(); + const Standard_Real aLastU = BS.LastUParameter() >= Precision::Infinite() ? theMaxParam : BS.LastUParameter(); + const Standard_Real aFirstV = BS.FirstVParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstVParameter(); + const Standard_Real aLastV = BS.LastVParameter() >= Precision::Infinite() ? theMaxParam : BS.LastVParameter(); + Handle(TColgp_HArray1OfPnt) aPlanePnts = new TColgp_HArray1OfPnt (1, 5); + BS.D0 (aFirstU, aFirstV, aPlanePnts->ChangeValue (1)); + BS.D0 (aLastU, aFirstV, aPlanePnts->ChangeValue (2)); + BS.D0 (aLastU, aLastV, aPlanePnts->ChangeValue (3)); + BS.D0 (aFirstU, aLastV, aPlanePnts->ChangeValue (4)); + aPlanePnts->SetValue (5, aPlanePnts->Value (1)); + // if the plane is "infinite", it is sensitive only on the border limited by MaxParam - if (FirstU == -theMaxParam && LastU == theMaxParam && FirstV == -theMaxParam && LastV == theMaxParam) - { - theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, P, Select3D_TOS_BOUNDARY)); - } - else - { - Select3D_TypeOfSensitivity TS = theInteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY; - theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, P, TS)); - } + const bool isInfinite = aFirstU == -theMaxParam + && aLastU == theMaxParam + && aFirstV == -theMaxParam + && aLastV == theMaxParam; + theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, aPlanePnts, + theInteriorFlag && !isInfinite + ? Select3D_TOS_INTERIOR + : Select3D_TOS_BOUNDARY)); return Standard_True; } - // This is construction of a sevsitive polygon from the exterior contour of the face... + // This is construction of a sensitive polygon from the exterior contour of the face... // It is not good at all, but... TopoDS_Wire aWire; - TopExp_Explorer anExpWiresInFace (theFace, TopAbs_WIRE); - if (anExpWiresInFace.More()) { - // believing that this is the first... to be seen - aWire = TopoDS::Wire (anExpWiresInFace.Current()); + TopExp_Explorer anExpWiresInFace (theFace, TopAbs_WIRE); + if (anExpWiresInFace.More()) + { + // believing that this is the first... to be seen + aWire = TopoDS::Wire (anExpWiresInFace.Current()); + } } if (aWire.IsNull()) { return Standard_False; } - TColgp_SequenceOfPnt WirePoints; - Standard_Boolean FirstExp = Standard_True; - Standard_Real wf, wl; + TColgp_SequenceOfPnt aWirePoints; + Standard_Boolean isFirstExp = Standard_True; BRepAdaptor_Curve cu3d; - for (BRepTools_WireExplorer aWireExplorer (aWire); - aWireExplorer.More(); aWireExplorer.Next()) + for (BRepTools_WireExplorer aWireExplorer (aWire); aWireExplorer.More(); aWireExplorer.Next()) { cu3d.Initialize (aWireExplorer.Current()); + Standard_Real wf = 0.0, wl = 0.0; BRep_Tool::Range (aWireExplorer.Current(), wf, wl); if (Abs (wf - wl) <= Precision::Confusion()) { #ifdef OCCT_DEBUG cout<<" StdSelect_BRepSelectionTool : Curve where ufirst = ulast ...."<= ff; wc -= dw) - { - WirePoints.Append (cu3d.Value (wc)); - } - } - } - else - { - if (cu3d.Circle().Radius() <= Precision::Confusion()) - { - theSensitiveList.Append (new Select3D_SensitivePoint (theOwner, cu3d.Circle().Location())); - } - else - { - theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, new Geom_Circle (cu3d.Circle()), theInteriorFlag, 16)); - } - } - } - else - { - Standard_Real ff = wf, ll = wl; - Standard_Real dw = (Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1); + Standard_Real ff = wf ,ll = wl; + Standard_Real dw =(Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1); if (aWireExplorer.Orientation() == TopAbs_FORWARD) { for (Standard_Real wc = wf + dw; wc <= wl; wc += dw) { - WirePoints.Append (cu3d.Value (wc)); + aWirePoints.Append (cu3d.Value (wc)); } } else if (aWireExplorer.Orientation() == TopAbs_REVERSED) { for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw) { - WirePoints.Append (cu3d.Value (wc)); + aWirePoints.Append (cu3d.Value (wc)); } } } - break; + else + { + if (cu3d.Circle().Radius() <= Precision::Confusion()) + { + theSensitiveList.Append (new Select3D_SensitivePoint (theOwner, cu3d.Circle().Location())); + } + else + { + theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, new Geom_Circle (cu3d.Circle()), theInteriorFlag, 16)); + } + } } - default: + else { Standard_Real ff = wf, ll = wl; Standard_Real dw = (Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1); - if (aWireExplorer.Orientation()==TopAbs_FORWARD) + if (aWireExplorer.Orientation() == TopAbs_FORWARD) { for (Standard_Real wc = wf + dw; wc <= wl; wc += dw) { - WirePoints.Append (cu3d.Value (wc)); + aWirePoints.Append (cu3d.Value (wc)); } } else if (aWireExplorer.Orientation() == TopAbs_REVERSED) { for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw) { - WirePoints.Append (cu3d.Value (wc)); + aWirePoints.Append (cu3d.Value (wc)); } } } + break; + } + default: + { + Standard_Real ff = wf, ll = wl; + Standard_Real dw = (Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1); + if (aWireExplorer.Orientation()==TopAbs_FORWARD) + { + for (Standard_Real wc = wf + dw; wc <= wl; wc += dw) + { + aWirePoints.Append (cu3d.Value (wc)); + } + } + else if (aWireExplorer.Orientation() == TopAbs_REVERSED) + { + for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw) + { + aWirePoints.Append (cu3d.Value (wc)); + } + } } } } - Standard_Integer ArrayPosition = WirePoints.Length(); - Handle(TColgp_HArray1OfPnt) facepoints = new TColgp_HArray1OfPnt (1, ArrayPosition); - for (Standard_Integer I = 1; I <= ArrayPosition; ++I) + Handle(TColgp_HArray1OfPnt) aFacePoints = new TColgp_HArray1OfPnt (1, aWirePoints.Length()); { - facepoints->SetValue (I, WirePoints.Value(I)); + Standard_Integer aPntIndex = 1; + for (TColgp_SequenceOfPnt::Iterator aPntIter (aWirePoints); aPntIter.More(); aPntIter.Next()) + { + aFacePoints->SetValue (aPntIndex++, aPntIter.Value()); + } } - if ((facepoints->Array1()).Length() > 1) - { //1 if only one circular edge - Select3D_TypeOfSensitivity TS = theInteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY; - theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, facepoints, TS)); + // 1 if only one circular edge + if (aFacePoints->Array1().Length() == 2) + { + theSensitiveList.Append (new Select3D_SensitiveCurve (theOwner, aFacePoints)); + } + else if (aFacePoints->Array1().Length() > 2) + { + theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, aFacePoints, + theInteriorFlag + ? Select3D_TOS_INTERIOR + : Select3D_TOS_BOUNDARY)); } return Standard_True; } diff --git a/tests/bugs/vis/bug129_1 b/tests/bugs/vis/bug129_1 index 30ad0ad983..b3f9bd87ae 100755 --- a/tests/bugs/vis/bug129_1 +++ b/tests/bugs/vis/bug129_1 @@ -1,41 +1,22 @@ puts "================" -puts "OCC129" +puts "OCC129 - infinite cylinder is not selectable in 3D Viewer" puts "================" puts "" -####################################################################################### -# Object is not selectable in the Cascade Viewer -###################################################################################### - -set BugNumber OCC22129 cylinder c 0 0 1 10 mkface f c -vinit -vdisplay f - -set x1 207 -set y1 184 -set x2 222 -set y2 175 - -set UNSELECT_R 1 -set UNSELECT_G 1 -set UNSELECT_B 0 - -set MOVESELECT_R 0 -set MOVESELECT_G 1 -set MOVESELECT_B 1 - - -vmoveto ${x1} ${y1} -checkcolor ${x1} ${y1} 0 1 1 - -vselect ${x1} ${y1} -checkcolor ${x1} ${y1} 0.8 0.8 0.8 - -vselect ${x2} ${y2} -checkcolor ${x1} ${y1} 1 1 0 - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png +vclear +vinit View1 +vdisplay -dispMode 0 f +# check dynamic highlighting +vmoveto 207 184 +checkcolor 207 184 0 1 1 +# check selected highlighting +vselect 207 184 +checkcolor 207 184 0.8 0.8 0.8 +# check unselected +vselect 222 175 +checkcolor 207 184 1 1 0 +vdump ${imagedir}/${casename}.png diff --git a/tests/bugs/vis/bug27869 b/tests/bugs/vis/bug27869 new file mode 100644 index 0000000000..df557764de --- /dev/null +++ b/tests/bugs/vis/bug27869 @@ -0,0 +1,14 @@ +puts "================" +puts "0027869: Visualization - AIS_ConnectedInteractive does not support exact HLR mode" +puts "================" +puts "" + +restore [locate_data_file CrankArm.brep] obj +vclear +vinit View1 +vdisplay obj +vconnect new 50 50 50 obj +vfit +vhlr on -algoType algo + +vdump ${imagedir}/${casename}.png