From a716c3ec2a9eb0f452564b08cdcf8dd9cb9428c4 Mon Sep 17 00:00:00 2001 From: ika Date: Mon, 29 Jun 2015 15:45:53 +0300 Subject: [PATCH] HOMAG patch for OCCT 6.7.0 --- src/AIS/AIS.cdl | 3 +- src/AIS/AIS_AngleDimension.cxx | 342 +++- src/AIS/AIS_AngleDimension.hxx | 21 +- src/AIS/AIS_DiameterDimension.cxx | 41 +- src/AIS/AIS_DiameterDimension.hxx | 12 +- src/AIS/AIS_Dimension.cxx | 356 +++- src/AIS/AIS_Dimension.hxx | 137 +- src/AIS/AIS_DimensionLayoutMode.hxx | 24 + src/AIS/AIS_InteractiveContext.cdl | 4 +- src/AIS/AIS_InteractiveContext.cxx | 12 +- src/AIS/AIS_InteractiveContext_1.cxx | 17 +- src/AIS/AIS_LengthDimension.cxx | 30 + src/AIS/AIS_LengthDimension.hxx | 6 +- src/AIS/AIS_LocalContext.cdl | 4 +- src/AIS/AIS_LocalContext.cxx | 5 +- src/AIS/AIS_LocalContext_1.cxx | 23 +- src/AIS/AIS_RadiusDimension.cxx | 30 + src/AIS/AIS_RadiusDimension.hxx | 8 +- src/AIS/AIS_Shape.cxx | 2 +- src/AIS/FILES | 1 + src/BRep/BRep_Builder.cxx | 80 +- .../BRepBuilderAPI_VertexInspector.hxx | 20 +- src/BRepFill/BRepFill_OffsetWire.cdl | 30 +- src/BRepFill/BRepFill_OffsetWire.cxx | 510 +++-- src/BRepFill/BRepFill_PipeShell.cxx | 3 +- src/BRepFill/BRepFill_SectionLaw.cxx | 2 + src/BRepFill/BRepFill_Sweep.cxx | 8 +- src/BRepMAT2d/BRepMAT2d.cdl | 24 +- src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl | 166 ++ src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx | 348 ++++ src/BRepMAT2d/BRepMAT2d_LinkTopoBilo.cxx | 4 +- .../BRepOffsetAPI_MakeOffset.cdl | 13 +- .../BRepOffsetAPI_MakeOffset.cxx | 56 +- .../BRepOffsetAPI_ThruSections.cxx | 448 ++--- src/BRepToIGES/BRepToIGES_BRShell.cxx | 97 +- src/BRepToIGES/BRepToIGES_BRWire.cxx | 22 + .../BRepTools_NurbsConvertModification.cxx | 40 +- src/DsgPrs/DsgPrs_DiameterPresentation.cxx | 2 + src/GeomConvert/GeomConvert_1.cxx | 31 +- src/GeomFill/GeomFill_Sweep.cxx | 37 +- src/GeomToIGES/GeomToIGES_GeomSurface.cxx | 109 +- src/MAT2d/MAT2d.cdl | 31 +- src/MAT2d/MAT2d_Circuit.cdl | 22 +- src/MAT2d/MAT2d_Circuit.cxx | 312 ++-- src/MAT2d/MAT2d_Mat2d.cdl | 114 ++ src/MAT2d/MAT2d_Mat2d.cxx | 1662 +++++++++++++++++ src/MAT2d/MAT2d_Tool2d.cdl | 26 +- src/MAT2d/MAT2d_Tool2d.cxx | 48 +- .../NCollection_AlignedAllocator.cxx | 51 + .../NCollection_AlignedAllocator.hxx | 56 + src/NCollection/NCollection_Buffer.hxx | 139 ++ src/NCollection/NCollection_UBTree.hxx | 25 +- .../NCollection_WinHeapAllocator.cxx | 87 + .../NCollection_WinHeapAllocator.hxx | 55 + src/NIS/FILES | 19 + src/NIS/NIS_Allocator.hxx | 1 + src/NIS/NIS_DrawList.cxx | 14 +- src/NIS/NIS_DrawList.hxx | 14 +- src/NIS/NIS_Drawer.cxx | 184 +- src/NIS/NIS_Drawer.hxx | 167 +- src/NIS/NIS_IndexLists.cxx | 289 +++ src/NIS/NIS_IndexLists.hxx | 160 ++ src/NIS/NIS_InteractiveContext.cxx | 357 +++- src/NIS/NIS_InteractiveContext.hxx | 70 +- src/NIS/NIS_InteractiveObject.cxx | 63 +- src/NIS/NIS_InteractiveObject.hxx | 62 +- src/NIS/NIS_Line.cxx | 281 +++ src/NIS/NIS_Line.hxx | 213 +++ src/NIS/NIS_LineDrawer.cxx | 176 ++ src/NIS/NIS_LineDrawer.hxx | 85 + src/NIS/NIS_ObjectsIterator.hxx | 1 + src/NIS/NIS_Point.cxx | 278 +++ src/NIS/NIS_Point.hxx | 240 +++ src/NIS/NIS_PointDrawer.cxx | 1621 ++++++++++++++++ src/NIS/NIS_PointDrawer.hxx | 98 + src/NIS/NIS_PolygonSelector.cxx | 407 ++++ src/NIS/NIS_PolygonSelector.hxx | 141 ++ src/NIS/NIS_SelectFilter.cxx | 18 +- src/NIS/NIS_SelectFilter.hxx | 49 +- src/NIS/NIS_Surface.cxx | 637 +++++-- src/NIS/NIS_Surface.hxx | 184 +- src/NIS/NIS_SurfaceDrawer.cxx | 265 ++- src/NIS/NIS_SurfaceDrawer.hxx | 32 +- src/NIS/NIS_Text.cxx | 210 +++ src/NIS/NIS_Text.hxx | 177 ++ src/NIS/NIS_TextDrawer.cxx | 297 +++ src/NIS/NIS_TextDrawer.hxx | 104 ++ src/NIS/NIS_Tools.cxx | 110 ++ src/NIS/NIS_Tools.hxx | 77 + src/NIS/NIS_Triangulated.cxx | 937 +++++----- src/NIS/NIS_Triangulated.hxx | 171 +- src/NIS/NIS_TriangulatedDrawer.cxx | 94 +- src/NIS/NIS_TriangulatedDrawer.hxx | 3 +- src/NIS/NIS_View.cxx | 451 ++++- src/NIS/NIS_View.hxx | 200 +- src/NIS/NIS_ViewData.hxx | 57 + src/OSD/OSD_MPData.cxx | 114 ++ src/OSD/OSD_MPData.hxx | 96 + src/OSD/OSD_MProcess.cxx | 434 +++++ src/OSD/OSD_MProcess.hxx | 181 ++ src/OSD/OSD_PerfMeter.cxx | 64 +- src/OSD/OSD_PerfMeter.h | 6 + src/OpenGl/OpenGl_Context.hxx | 8 + src/OpenGl/OpenGl_Workspace_3.cxx | 13 + src/Poly/Poly_IBuffer.cxx | 547 ++++++ src/Poly/Poly_IBuffer.hxx | 254 +++ src/Poly/Poly_IBuffer.lxx | 87 + src/Prs3d/Prs3d_DimensionAspect.cdl | 11 +- src/Prs3d/Prs3d_DimensionAspect.cxx | 25 +- src/PrsMgr/PrsMgr_Presentation3d.cdl | 8 +- src/PrsMgr/PrsMgr_Presentation3d.cxx | 49 +- src/PrsMgr/PrsMgr_PresentationManager3d.cxx | 2 +- src/RWStl/RWStl.cxx | 52 +- src/Select3D/Select3D_SensitiveCurve.cdl | 18 +- src/Select3D/Select3D_SensitiveCurve.cxx | 74 +- .../Select3D_SensitiveTriangulation.cxx | 3 + .../Select3D_SensitiveTriangulation.lxx | 5 + .../ShapeAnalysis_CheckSmallFace.cxx | 2 + src/ShapeAnalysis/ShapeAnalysis_Edge.cxx | 16 +- src/ShapeAnalysis/ShapeAnalysis_Wire.cxx | 4 + src/ShapeFix/ShapeFix_Wire.cxx | 3 +- src/Standard/Standard.cdl | 10 + src/Standard/Standard.cxx | 42 + src/Standard/Standard_CString.cxx | 18 + src/Standard/Standard_CString.hxx | 2 + src/Standard/Standard_GUID.cxx | 20 +- src/Standard/Standard_Macro.hxx | 10 + src/StdSelect/StdSelect.cxx | 17 +- src/StdSelect/StdSelect_BRepOwner.cdl | 7 + src/StdSelect/StdSelect_BRepOwner.cxx | 19 +- src/StdSelect/StdSelect_Shape.cdl | 6 +- src/StdSelect/StdSelect_Shape.cxx | 45 +- src/StlMesh/StlMesh_MeshDomain.cxx | 6 - src/TDF/TDF_Tool.cxx | 18 +- src/TDataStd/TDataStd_ChildNodeIterator.cdl | 1 + src/TDataStd/TDataStd_ChildNodeIterator.lxx | 2 +- src/TDataStd/TDataStd_TreeNode.cxx | 13 +- src/TKNIS/EXTERNLIB | 2 + src/TNaming/TNaming_Name.cxx | 5 +- src/TNaming/TNaming_NamedShape.cxx | 14 +- src/V3d/V3d_Viewer_2.cxx | 3 +- src/Visual3d/Visual3d_View.cxx | 2 +- src/VrmlData/VrmlData_IndexedFaceSet.cxx | 2 +- src/VrmlData/VrmlData_ShapeConvert.cxx | 4 +- 144 files changed, 14907 insertions(+), 2207 deletions(-) create mode 100644 src/AIS/AIS_DimensionLayoutMode.hxx create mode 100644 src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl create mode 100644 src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx create mode 100644 src/MAT2d/MAT2d_Mat2d.cdl create mode 100644 src/MAT2d/MAT2d_Mat2d.cxx create mode 100644 src/NCollection/NCollection_AlignedAllocator.cxx create mode 100644 src/NCollection/NCollection_AlignedAllocator.hxx create mode 100644 src/NCollection/NCollection_Buffer.hxx create mode 100644 src/NCollection/NCollection_WinHeapAllocator.cxx create mode 100644 src/NCollection/NCollection_WinHeapAllocator.hxx create mode 100644 src/NIS/NIS_IndexLists.cxx create mode 100644 src/NIS/NIS_IndexLists.hxx create mode 100644 src/NIS/NIS_Line.cxx create mode 100644 src/NIS/NIS_Line.hxx create mode 100644 src/NIS/NIS_LineDrawer.cxx create mode 100644 src/NIS/NIS_LineDrawer.hxx create mode 100644 src/NIS/NIS_Point.cxx create mode 100644 src/NIS/NIS_Point.hxx create mode 100644 src/NIS/NIS_PointDrawer.cxx create mode 100644 src/NIS/NIS_PointDrawer.hxx create mode 100644 src/NIS/NIS_PolygonSelector.cxx create mode 100644 src/NIS/NIS_PolygonSelector.hxx create mode 100644 src/NIS/NIS_Text.cxx create mode 100644 src/NIS/NIS_Text.hxx create mode 100644 src/NIS/NIS_TextDrawer.cxx create mode 100644 src/NIS/NIS_TextDrawer.hxx create mode 100644 src/NIS/NIS_Tools.cxx create mode 100644 src/NIS/NIS_Tools.hxx create mode 100644 src/NIS/NIS_ViewData.hxx create mode 100644 src/OSD/OSD_MPData.cxx create mode 100644 src/OSD/OSD_MPData.hxx create mode 100644 src/OSD/OSD_MProcess.cxx create mode 100644 src/OSD/OSD_MProcess.hxx create mode 100644 src/Poly/Poly_IBuffer.cxx create mode 100644 src/Poly/Poly_IBuffer.hxx create mode 100644 src/Poly/Poly_IBuffer.lxx diff --git a/src/AIS/AIS.cdl b/src/AIS/AIS.cdl index f1f9c76ba9..8d814eaf81 100644 --- a/src/AIS/AIS.cdl +++ b/src/AIS/AIS.cdl @@ -241,7 +241,8 @@ is KOI_Datum, KOI_Shape, KOI_Object, - KOI_Relation; + KOI_Relation, + KOI_Dimension; --- Purpose: Declares the type of Interactive Object. -- This is one of the following: -- - the Datum diff --git a/src/AIS/AIS_AngleDimension.cxx b/src/AIS/AIS_AngleDimension.cxx index 6b841c8932..57a62f2ef2 100644 --- a/src/AIS/AIS_AngleDimension.cxx +++ b/src/AIS/AIS_AngleDimension.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include IMPLEMENT_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension) @@ -300,7 +301,7 @@ void AIS_AngleDimension::Init() //======================================================================= gp_Pnt AIS_AngleDimension::GetCenterOnArc (const gp_Pnt& theFirstAttach, const gp_Pnt& theSecondAttach, - const gp_Pnt& theCenter) + const gp_Pnt& theCenter) const { // construct plane where the circle and the arc are located gce_MakePln aConstructPlane (theFirstAttach, theSecondAttach, theCenter); @@ -623,30 +624,15 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout()); // Handle user-defined and automatic arrow placement - bool isArrowsExternal = false; - switch (aDimensionAspect->ArrowOrientation()) - { - case Prs3d_DAO_External: isArrowsExternal = true; break; - case Prs3d_DAO_Internal: isArrowsExternal = false; break; - case Prs3d_DAO_Fit: - { - gp_Vec anAttachVector (aFirstAttach, aSecondAttach); - Standard_Real aDimensionWidth = anAttachVector.Magnitude(); - - // add margin to ensure a small tail between text and arrow - Standard_Real anArrowMargin = aDimensionAspect->IsText3d() - ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN - : 0.0; - - Standard_Real anArrowsWidth = (anArrowLength + anArrowMargin) * 2.0; - - isArrowsExternal = aDimensionWidth < aLabelWidth + anArrowsWidth; - break; - } - } - + Standard_Boolean isArrowsExternal = Standard_False; + Standard_Integer aLabelPosition = LabelPosition_None; + + FitTextAlignment (aLabelPosition, isArrowsExternal); + //Arrows positions and directions - gp_Vec aWPDir = gp_Vec (GetPlane().Axis().Direction()); + // Get normal to plane for extension directions computing. + // Stored in the working plane normal is not suitable if flyout is negative. + gp_Vec aWPDir = gp_Vec (aFirstAttach, aSecondAttach) ^ gp_Vec (myCenterPoint, aFirstAttach); gp_Dir aFirstExtensionDir = aWPDir ^ gp_Vec (myCenterPoint, aFirstAttach); gp_Dir aSecondExtensionDir = aWPDir.Reversed() ^ gp_Vec (myCenterPoint, aSecondAttach); @@ -670,33 +656,6 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* aFirstArrowEnd = aFirstAttach.Translated (-aFirstArrowVec); aSecondArrowEnd = aSecondAttach.Translated (-aSecondArrowVec); - Standard_Integer aLabelPosition = LabelPosition_None; - - // Handle user-defined and automatic text placement - switch (aDimensionAspect->TextHorizontalPosition()) - { - case Prs3d_DTHP_Left : aLabelPosition |= LabelPosition_Left; break; - case Prs3d_DTHP_Right : aLabelPosition |= LabelPosition_Right; break; - case Prs3d_DTHP_Center: aLabelPosition |= LabelPosition_HCenter; break; - case Prs3d_DTHP_Fit: - { - gp_Vec anAttachVector (aFirstAttach, aSecondAttach); - Standard_Real aDimensionWidth = anAttachVector.Magnitude(); - Standard_Real anArrowsWidth = anArrowLength * 2.0; - Standard_Real aContentWidth = isArrowsExternal ? aLabelWidth : aLabelWidth + anArrowsWidth; - - aLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter; - break; - } - } - - switch (aDimensionAspect->TextVerticalPosition()) - { - case Prs3d_DTVP_Above : aLabelPosition |= LabelPosition_Above; break; - case Prs3d_DTVP_Below : aLabelPosition |= LabelPosition_Below; break; - case Prs3d_DTVP_Center : aLabelPosition |= LabelPosition_VCenter; break; - } - // Group1: stenciling text and the angle dimension arc Prs3d_Root::NewGroup (thePresentation); @@ -729,7 +688,8 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* if (theMode == ComputeMode_All || theMode == ComputeMode_Text) { gp_Vec aDimensionDir (aFirstAttach, aSecondAttach); - gp_Pnt aTextPos = GetCenterOnArc (aFirstAttach, aSecondAttach, myCenterPoint); + gp_Pnt aTextPos = myIsTextPositionFixed ? myFixedTextPosition + : GetCenterOnArc (aFirstAttach, aSecondAttach, myCenterPoint); gp_Dir aTextDir = aDimensionDir; DrawText (thePresentation, @@ -807,7 +767,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* if (aHPosition != LabelPosition_Left) { DrawExtension (thePresentation, - anExtensionSize, + aDimensionAspect->ShortExtensionSize(), aFirstArrowEnd, aFirstExtensionDir, THE_EMPTY_LABEL_STRING, @@ -819,7 +779,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* if (aHPosition != LabelPosition_Right) { DrawExtension (thePresentation, - anExtensionSize, + aDimensionAspect->ShortExtensionSize(), aSecondArrowEnd, aSecondExtensionDir, THE_EMPTY_LABEL_STRING, @@ -891,6 +851,11 @@ Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane Standard_Boolean isParallelLines = Abs (aFirstLin.Angle (aSecondLin) - M_PI) <= Precision::Angular(); gp_Pnt aPoint = aFirstLine->Value (0.0); + if (isParallelLines && aFirstLin.Distance(aPoint) < Precision::Confusion()) + { + // If two lines are parallel and distance between them is 0, we can't find a plane. + return Standard_False; + } gp_Dir aNormal = isParallelLines ? gp_Vec (aSecondLin.Normal (aPoint).Direction()) ^ gp_Vec (aSecondLin.Direction()) : gp_Vec (aFirstLin.Direction()) ^ gp_Vec (aSecondLin.Direction()); @@ -1184,3 +1149,272 @@ Standard_Boolean AIS_AngleDimension::IsValidPoints (const gp_Pnt& theFirstPoint, && gp_Vec (theCenterPoint, theFirstPoint).Angle ( gp_Vec (theCenterPoint, theSecondPoint)) > Precision::Angular(); } + +//======================================================================= +//function : GetTextPosition +//purpose : +//======================================================================= +const gp_Pnt AIS_AngleDimension::GetTextPosition() const +{ + if (!IsValid()) + { + return gp::Origin(); + } + + if (myIsTextPositionFixed) + { + return myFixedTextPosition; + } + + // Counts text position according to the dimension parameters + gp_Pnt aTextPosition (gp::Origin()); + + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + + // Prepare label string and compute its geometrical width + Standard_Real aLabelWidth; + TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth); + + gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * GetFlyout()); + gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout()); + + // Handle user-defined and automatic arrow placement + Standard_Boolean isArrowsExternal = Standard_False; + Standard_Integer aLabelPosition = LabelPosition_None; + FitTextAlignment (aLabelPosition, isArrowsExternal); + + // Get text position + switch (aLabelPosition & LabelPosition_HMask) + { + case LabelPosition_HCenter: + { + aTextPosition = GetCenterOnArc (aFirstAttach, aSecondAttach, myCenterPoint); + } + break; + case LabelPosition_Left: + { + gp_Dir aPlaneNormal = gp_Vec (aFirstAttach, aSecondAttach) ^ gp_Vec (myCenterPoint, aFirstAttach); + gp_Dir anExtensionDir = aPlaneNormal ^ gp_Vec (myCenterPoint, aFirstAttach); + Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize(); + Standard_Real anOffset = isArrowsExternal + ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length() + : anExtensionSize; + gp_Vec anExtensionVec = gp_Vec(anExtensionDir)*(-anOffset); + aTextPosition = aFirstAttach.Translated (anExtensionVec); + } + break; + case LabelPosition_Right: + { + gp_Dir aPlaneNormal = gp_Vec (aFirstAttach, aSecondAttach) ^ gp_Vec (myCenterPoint, aFirstAttach); + gp_Dir anExtensionDir = aPlaneNormal ^ gp_Vec (myCenterPoint, aSecondAttach); + Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize(); + Standard_Real anOffset = isArrowsExternal + ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length() + : anExtensionSize; + gp_Vec anExtensionVec = gp_Vec(anExtensionDir)*(anOffset); + aTextPosition = aSecondAttach.Translated (anExtensionVec); + } + break; + } + + return aTextPosition; +} + +//======================================================================= +//function : SetTextPosition +//purpose : +//======================================================================= +void AIS_AngleDimension::SetTextPosition (const gp_Pnt& theTextPos) +{ + if (!IsValid()) + { + return; + } + + // The text position point for angle dimension should belong to the working plane. + if (!GetPlane().Contains (theTextPos, Precision::Confusion())) + { + Standard_ProgramError::Raise ("The text position point for angle dimension doesn't belong to the working plane."); + } + + myIsTextPositionFixed = Standard_True; + myFixedTextPosition = theTextPos; + + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + + // Compute flyout direction vector. + gp_Dir aPlaneNormal = GetPlane().Axis().Direction(); + gp_Dir aTargetPointsDir = gce_MakeDir (myFirstPoint, mySecondPoint); + + // Build circle with radius that is equal to distance from text position to the center point. + Standard_Real aRadius = gp_Vec (myCenterPoint, theTextPos).Magnitude(); + + // Set attach points in positive direction of the flyout. + gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * aRadius); + gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * aRadius); + + gce_MakeCirc aConstructCircle (myCenterPoint, GetPlane(), aRadius); + if (!aConstructCircle.IsDone()) + { + return; + } + gp_Circ aCircle = aConstructCircle.Value(); + + // Default values + aDimensionAspect->SetExtensionSize (aDimensionAspect->ArrowAspect()->Length()); + aDimensionAspect->SetTextHorizontalPosition (Prs3d_DTHP_Center); + + Standard_Real aParamBeg = ElCLib::Parameter (aCircle, aFirstAttach); + Standard_Real aParamEnd = ElCLib::Parameter (aCircle, aSecondAttach); + ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd); + Standard_Real aTextPar = ElCLib::Parameter (aCircle , theTextPos); + + // Horizontal center + if (aTextPar > aParamBeg && aTextPar < aParamEnd) + { + myFlyout = aRadius; + + if (LayoutMode() == AIS_DLM_Automatic) + { + // Adjust text position so that text was aligned. + myFixedTextPosition = GetCenterOnArc (aFirstAttach, aSecondAttach, myCenterPoint); + } + SetToUpdate(); + return; + } + + aParamBeg += M_PI; + aParamEnd += M_PI; + ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd); + + if (aTextPar > aParamBeg && aTextPar < aParamEnd) + { + myFlyout = -aRadius; + + if (LayoutMode() == AIS_DLM_Automatic) + { + // Adjust text position so that text was aligned. + aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * GetFlyout()); + aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout()); + myFixedTextPosition = GetCenterOnArc (aFirstAttach, aSecondAttach, myCenterPoint); + } + SetToUpdate(); + return; + } + + // Text on the extensions + gp_Lin aFirstLine = gce_MakeLin (myCenterPoint, myFirstPoint); + gp_Lin aSecondLine = gce_MakeLin (myCenterPoint, mySecondPoint); + gp_Pnt aFirstTextProj = AIS::Nearest (aFirstLine, theTextPos); + gp_Pnt aSecondTextProj = AIS::Nearest (aSecondLine, theTextPos); + Standard_Real aFirstDist = aFirstTextProj.Distance (theTextPos); + Standard_Real aSecondDist = aSecondTextProj.Distance (theTextPos); + + if (aFirstDist <= aSecondDist) + { + aRadius = myCenterPoint.Distance (aFirstTextProj); + aDimensionAspect->SetExtensionSize (aFirstDist); + aDimensionAspect->SetTextHorizontalPosition (Prs3d_DTHP_Left); + + gp_Vec aPosFlyoutDir = gp_Vec (myCenterPoint, myFirstPoint).Normalized().Scaled (aRadius); + + if (aFirstTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()) + { + myFlyout = -aRadius; + } + else + { + myFlyout = aRadius; + } + } + else + { + aRadius = myCenterPoint.Distance (aSecondTextProj); + aDimensionAspect->SetExtensionSize (aSecondDist); + aDimensionAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right); + + gp_Vec aPosFlyoutDir = gp_Vec (myCenterPoint, mySecondPoint).Normalized().Scaled (aRadius); + + if (aSecondTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()) + { + myFlyout = -aRadius; + } + else + { + myFlyout = aRadius; + } + } +} + +//======================================================================= +//function : FitTextAlignment +//purpose : +//======================================================================= +void AIS_AngleDimension::FitTextAlignment (Standard_Integer& theLabelPosition, + Standard_Boolean& theIsArrowsExternal) const +{ + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + + Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length(); + + // Prepare label string and compute its geometrical width + Standard_Real aLabelWidth; + TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth); + + // add margins to label width + if (aDimensionAspect->IsText3d()) + { + aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0; + } + + gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * GetFlyout()); + gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout()); + + // Handle user-defined and automatic arrow placement + switch (aDimensionAspect->ArrowOrientation()) + { + case Prs3d_DAO_External: theIsArrowsExternal = true; break; + case Prs3d_DAO_Internal: theIsArrowsExternal = false; break; + case Prs3d_DAO_Fit: + { + gp_Vec anAttachVector (aFirstAttach, aSecondAttach); + Standard_Real aDimensionWidth = anAttachVector.Magnitude(); + + // Add margin to ensure a small tail between text and arrow + Standard_Real anArrowMargin = aDimensionAspect->IsText3d() + ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN + : 0.0; + + Standard_Real anArrowsWidth = (anArrowLength + anArrowMargin) * 2.0; + + theIsArrowsExternal = aDimensionWidth < aLabelWidth + anArrowsWidth; + break; + } + } + + // Handle user-defined and automatic text placement + switch (aDimensionAspect->TextHorizontalPosition()) + { + case Prs3d_DTHP_Left : theLabelPosition |= LabelPosition_Left; break; + case Prs3d_DTHP_Right : theLabelPosition |= LabelPosition_Right; break; + case Prs3d_DTHP_Center: theLabelPosition |= LabelPosition_HCenter; break; + case Prs3d_DTHP_Fit: + { + gp_Vec anAttachVector (aFirstAttach, aSecondAttach); + Standard_Real aDimensionWidth = anAttachVector.Magnitude(); + Standard_Real anArrowsWidth = anArrowLength * 2.0; + Standard_Real aContentWidth = theIsArrowsExternal ? aLabelWidth : aLabelWidth + anArrowsWidth; + + theLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter; + break; + } + } + + switch (aDimensionAspect->TextVerticalPosition()) + { + case Prs3d_DTVP_Above : theLabelPosition |= LabelPosition_Above; break; + case Prs3d_DTVP_Below : theLabelPosition |= LabelPosition_Below; break; + case Prs3d_DTVP_Center : theLabelPosition |= LabelPosition_VCenter; break; + } + +} diff --git a/src/AIS/AIS_AngleDimension.hxx b/src/AIS/AIS_AngleDimension.hxx index 31548dd8b8..b48fb81a58 100755 --- a/src/AIS/AIS_AngleDimension.hxx +++ b/src/AIS/AIS_AngleDimension.hxx @@ -197,6 +197,16 @@ public: Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits); + //! Principle of horizontal text alignment settings: + //! - divide circle into two halfs according to attachment points + //! - if aTextPos is between attach points -> Center + positive flyout + //! - if aTextPos is not between attach points but in this half -> Left or Right + positive flyout + //! - if aTextPos is between reflections of attach points -> Center + negative flyout + //! - if aTextPos is not between reflections of attach points -> Left or Right + negative flyout + Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos); + + Standard_EXPORT virtual const gp_Pnt GetTextPosition () const; + public: DEFINE_STANDARD_RTTI (AIS_AngleDimension) @@ -212,7 +222,7 @@ protected: //! @return the center of the dimension arc (the main dimension line in case of angle). Standard_EXPORT gp_Pnt GetCenterOnArc (const gp_Pnt& theFirstAttach, const gp_Pnt& theSecondAttach, - const gp_Pnt& theCenter); + const gp_Pnt& theCenter) const; //! Draws main dimension line (arc). //! @param thePresentation [in] the dimension presentation. @@ -247,6 +257,15 @@ protected: const Standard_Integer theMode, const Standard_Integer theLabelPosition); + //! Fits text alignment relatively to the dimension line. + //! @param theLabelPosition [out] the label position, contains bits that defines + //! vertical and horizontal alignment. (for internal usage in count text position) + //! @param theIsArrowExternal [out] is the arrows external, + //! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow + //! orientation automatically. + Standard_EXPORT void FitTextAlignment (Standard_Integer& theLabelPosition, + Standard_Boolean& theIsArrowsExternal) const; + protected: Standard_EXPORT virtual void ComputePlane(); diff --git a/src/AIS/AIS_DiameterDimension.cxx b/src/AIS/AIS_DiameterDimension.cxx index 761f701e72..f93938b139 100644 --- a/src/AIS/AIS_DiameterDimension.cxx +++ b/src/AIS/AIS_DiameterDimension.cxx @@ -296,7 +296,7 @@ void AIS_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& gp_Pnt aFirstPnt (gp::Origin()); gp_Pnt aSecondPnt (gp::Origin()); - ComputeSidePoints (myCircle, GetPlane(), aFirstPnt, aSecondPnt); + ComputeSidePoints (myCircle, aFirstPnt, aSecondPnt); DrawLinearDimension (thePresentation, theMode, aFirstPnt, aSecondPnt); } @@ -315,7 +315,7 @@ void AIS_DiameterDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selec gp_Pnt aFirstPnt (gp::Origin()); gp_Pnt aSecondPnt (gp::Origin()); - ComputeSidePoints (myCircle, GetPlane(), aFirstPnt, aSecondPnt); + ComputeSidePoints (myCircle, aFirstPnt, aSecondPnt); ComputeLinearFlyouts (theSelection, theEntityOwner, aFirstPnt, aSecondPnt); } @@ -324,15 +324,14 @@ void AIS_DiameterDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selec //function : ComputeSidePoints //purpose : //======================================================================= -void AIS_DiameterDimension::ComputeSidePoints (const gp_Circ& /*theCircle*/, - const gp_Pln& /*thePlane*/, +void AIS_DiameterDimension::ComputeSidePoints (const gp_Circ& theCircle, gp_Pnt& theFirstPnt, gp_Pnt& theSecondPnt) { theFirstPnt = AnchorPoint(); - gp_Vec aRadiusVector (myCircle.Location(), theFirstPnt); - theSecondPnt = myCircle.Location().Translated (-aRadiusVector); + gp_Vec aRadiusVector (theCircle.Location(), theFirstPnt); + theSecondPnt = theCircle.Location().Translated (-aRadiusVector); } //======================================================================= @@ -358,3 +357,33 @@ Standard_Boolean AIS_DiameterDimension::IsValidAnchor (const gp_Circ& theCircle, return Abs (anAnchorDist - aRadius) > Precision::Confusion() && aCirclePlane.Contains (theAnchor, Precision::Confusion()); } + +//======================================================================= +//function : GetTextPosition +//purpose : +//======================================================================= +const gp_Pnt AIS_DiameterDimension::GetTextPosition () const +{ + if (myIsTextPositionFixed) + { + return myFixedTextPosition; + } + + // Counts text position according to the dimension parameters + return GetTextPositionForLinear (myAnchorPoint, myCircle.Location()); +} + +//======================================================================= +//function : GetTextPosition +//purpose : +//======================================================================= +void AIS_DiameterDimension::SetTextPosition (const gp_Pnt& theTextPos) +{ + if (!myIsValid) + { + return; + } + + SetTextPositionForLinear (myAnchorPoint, myCircle.Location(), theTextPos); + SetToUpdate(); +} diff --git a/src/AIS/AIS_DiameterDimension.hxx b/src/AIS/AIS_DiameterDimension.hxx index 7783f8c54c..508b15c0cb 100644 --- a/src/AIS/AIS_DiameterDimension.hxx +++ b/src/AIS/AIS_DiameterDimension.hxx @@ -114,15 +114,19 @@ public: Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape); //! @return the display units string. - Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits () const; + Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const; //! @return the model units string. - Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits () const; + Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const; Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits); Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits); + Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos); + + Standard_EXPORT virtual const gp_Pnt GetTextPosition() const; + public: DEFINE_STANDARD_RTTI(AIS_DiameterDimension) @@ -154,16 +158,14 @@ protected: protected: - //! Compute points on the circle sides for the specified dimension plane. + //! Compute points on the circle sides for the dimension plane. //! Program error exception is raised if the dimension plane "x" direction //! is orthogonal to plane (the "impossible" case). The passed dimension plane //! is the one specially computed to locate dimension presentation in circle. //! @param theCircle [in] the circle. - //! @param thePlane [in] the dimension presentation plane computed. //! @param theFirstPnt [out] the first point. //! @param theSecondPnt [out] the second point. Standard_EXPORT void ComputeSidePoints (const gp_Circ& theCircle, - const gp_Pln& thePlane, gp_Pnt& theFirstPnt, gp_Pnt& theSecondPnt); diff --git a/src/AIS/AIS_Dimension.cxx b/src/AIS/AIS_Dimension.cxx index e1c72fdeb8..4fb03f59d4 100755 --- a/src/AIS/AIS_Dimension.cxx +++ b/src/AIS/AIS_Dimension.cxx @@ -25,11 +25,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -57,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -68,7 +71,6 @@ #include #include #include -#include IMPLEMENT_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_Dimension, AIS_InteractiveObject) @@ -97,6 +99,7 @@ AIS_Dimension::AIS_Dimension (const AIS_KindOfDimension theType) : AIS_InteractiveObject(), myCustomValue (0.0), myIsValueCustom (Standard_False), + myLayoutMode (AIS_DLM_Automatic), mySpecialSymbol (' '), myDisplaySpecialSymbol (AIS_DSS_No), myGeometryType (GeometryType_UndefShapes), @@ -235,6 +238,15 @@ void AIS_Dimension::SetFlyout (const Standard_Real theFlyout) SetToUpdate(); } +//======================================================================= +//function : SetLayoutMode +//purpose : +//======================================================================= + void AIS_Dimension::SetLayoutMode (const AIS_DimensionLayoutMode theLayoutMode) + { + myLayoutMode = theLayoutMode; + } + //======================================================================= //function : GetDisplayUnits //purpose : @@ -651,27 +663,11 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr } // handle user-defined and automatic arrow placement - bool isArrowsExternal = false; - switch (aDimensionAspect->ArrowOrientation()) - { - case Prs3d_DAO_External: isArrowsExternal = true; break; - case Prs3d_DAO_Internal: isArrowsExternal = false; break; - case Prs3d_DAO_Fit: - { - // add margin to ensure a small tail between text and arrow - Standard_Real anArrowMargin = aDimensionAspect->IsText3d() - ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN - : 0.0; - - Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint); - Standard_Real anArrowsWidth = theIsOneSide - ? anArrowLength + anArrowMargin - : (anArrowLength + anArrowMargin) * 2.0; + Standard_Boolean isArrowsExternal = Standard_False; + Standard_Integer aLabelPosition = LabelPosition_None; - isArrowsExternal = aDimensionWidth < aLabelWidth + anArrowsWidth; - break; - } - } + FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, + aLabelPosition, isArrowsExternal); // compute arrows positions and directions gp_Dir aFirstArrowDir = aDimensionLine.Direction().Reversed(); @@ -701,32 +697,6 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr gp_Pnt aCenterLineEnd = isArrowsExternal || theIsOneSide ? aLineEndPoint : aSecondArrowEnd; - Standard_Integer aLabelPosition = LabelPosition_None; - - // handle user-defined and automatic text placement - switch (aDimensionAspect->TextHorizontalPosition()) - { - case Prs3d_DTHP_Left : aLabelPosition |= LabelPosition_Left; break; - case Prs3d_DTHP_Right : aLabelPosition |= LabelPosition_Right; break; - case Prs3d_DTHP_Center: aLabelPosition |= LabelPosition_HCenter; break; - case Prs3d_DTHP_Fit: - { - Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint); - Standard_Real anArrowsWidth = theIsOneSide ? anArrowLength : 2.0 * anArrowLength; - Standard_Real aContentWidth = isArrowsExternal ? aLabelWidth : aLabelWidth + anArrowsWidth; - - aLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter; - break; - } - } - - // handle vertical text placement options - switch (aDimensionAspect->TextVerticalPosition()) - { - case Prs3d_DTVP_Above : aLabelPosition |= LabelPosition_Above; break; - case Prs3d_DTVP_Below : aLabelPosition |= LabelPosition_Below; break; - case Prs3d_DTVP_Center : aLabelPosition |= LabelPosition_VCenter; break; - } switch (aLabelPosition & LabelPosition_HMask) { @@ -738,7 +708,8 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr // add label on dimension or extension line to presentation Prs3d_Root::NewGroup (thePresentation); - gp_Pnt aTextPos = (aCenterLineBegin.XYZ() + aCenterLineEnd.XYZ()) * 0.5; + gp_Pnt aTextPos = myIsTextPositionFixed ? myFixedTextPosition + : (aCenterLineBegin.XYZ() + aCenterLineEnd.XYZ()) * 0.5; gp_Dir aTextDir = aDimensionLine.Direction(); // add text primitives @@ -829,12 +800,12 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr // add arrow extension lines to presentation Prs3d_Root::NewGroup (thePresentation); - DrawExtension (thePresentation, anExtensionSize, + DrawExtension (thePresentation, aDimensionAspect->ShortExtensionSize(), aFirstArrowEnd, aFirstExtensionDir, THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None); if (!theIsOneSide) { - DrawExtension (thePresentation, anExtensionSize, + DrawExtension (thePresentation, aDimensionAspect->ShortExtensionSize(), aSecondArrowEnd, aSecondExtensionDir, THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None); } @@ -898,7 +869,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr // add extension lines for external arrows Prs3d_Root::NewGroup (thePresentation); - DrawExtension (thePresentation, anExtensionSize, + DrawExtension (thePresentation, aDimensionAspect->ShortExtensionSize(), aSecondArrowEnd, aSecondExtensionDir, THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None); } @@ -958,7 +929,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr // add extension lines for external arrows Prs3d_Root::NewGroup (thePresentation); - DrawExtension (thePresentation, anExtensionSize, + DrawExtension (thePresentation, aDimensionAspect->ShortExtensionSize(), aFirstArrowEnd, aFirstExtensionDir, THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None); } @@ -1142,7 +1113,6 @@ Standard_Boolean AIS_Dimension::InitCircularDimension (const TopoDS_Shape& theSh theCircle = aMkCirc.Value()->Circ(); } - gp_Vec aVec = gp_Vec (theCircle.Location(), aCurPos).Normalized(); aFirstPoint = ElCLib::Value (aFirstU, theCircle); aLastPoint = ElCLib::Value (aLastU, theCircle); } @@ -1357,3 +1327,283 @@ void AIS_Dimension::PointsForArrow (const gp_Pnt& thePeakPnt, theSidePnt1 = ElCLib::Value ( anEdgeLength, anEdgeLin); theSidePnt2 = ElCLib::Value (-anEdgeLength, anEdgeLin); } + +//======================================================================= +//function : GetTextPositionForLinear +//purpose : +//======================================================================= +Standard_Boolean AIS_Dimension::SetTextPositionForLinear (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pnt& theTextPos) +{ + if (!IsValid()) + { + return Standard_False; + } + + myIsTextPositionFixed = Standard_True; + myFixedTextPosition = theTextPos; + +#if 1 //HOMAG + + //Don't set new plane if the text position lies on the attachment points line. + gp_Dir aTargetPointsDir = gce_MakeDir (theFirstPoint, theSecondPoint); + gp_Lin aTargetPointsLin (theFirstPoint, aTargetPointsDir); + if (!aTargetPointsLin.Contains (theTextPos, Precision::Confusion())) + { + myPlane = gce_MakePln (theTextPos, theFirstPoint, theSecondPoint); + myIsPlaneCustom = Standard_False; + } + + // Compute dimension line points. + gp_Dir aPlaneNormal = GetPlane().Axis().Direction(); + gp_Vec aTargetPointsVec (theFirstPoint, theSecondPoint); + + //check if the target and plane dir not parallel. Else the cross + //product fails. + if (aPlaneNormal.IsParallel(aTargetPointsDir, Precision::Angular())) + return Standard_False; +#else + + //Set new automatic plane. + myPlane = gce_MakePln (theTextPos, theFirstPoint, theSecondPoint); + myIsPlaneCustom = Standard_False; + + // Compute dimension line points. + gp_Dir aPlaneNormal = GetPlane().Axis().Direction(); + gp_Dir aTargetPointsDir = gce_MakeDir (theFirstPoint, theSecondPoint); + gp_Vec aTargetPointsVec (theFirstPoint, theSecondPoint); +#endif + + // Compute flyout direction vector. + gp_Dir aPositiveFlyout = aPlaneNormal ^ aTargetPointsDir; + + // Set flyout. + gp_Vec aFirstToTextVec (theFirstPoint, theTextPos); + + Standard_Real aCos = aFirstToTextVec.Normalized() * gp_Vec (aTargetPointsDir); + + gp_Pnt aTextPosProj = theFirstPoint.Translated + (gp_Vec (aTargetPointsDir)*aFirstToTextVec.Magnitude()*aCos); + + + // Compute flyout value and direction. + gp_Vec aFlyoutVector = gp_Vec (aTextPosProj, theTextPos); +#if 1 //HOMAG + //Check if the vectors magnitude is not 0! Else + //it does generate an exception for IsOpposite. + myFlyout = 0.0; + if (aFlyoutVector.Magnitude() > Precision::Confusion()) + { + myFlyout = (gp_Dir (aFlyoutVector).IsOpposite (aPositiveFlyout, Precision::Angular())) + ? -aFlyoutVector.Magnitude() + : (aFlyoutVector.Magnitude()); + } + +#else + + myFlyout = (gp_Dir (aFlyoutVector).IsOpposite (aPositiveFlyout, Precision::Angular())) + ? -aFlyoutVector.Magnitude() + : (aFlyoutVector.Magnitude()); + +#endif + // Set horisontal text alignment. + if (aCos < 0.0) + { + myDrawer->DimensionAspect()->SetTextHorizontalPosition (Prs3d_DTHP_Left); + myDrawer->DimensionAspect()->SetExtensionSize (theTextPos.Distance (theFirstPoint.Translated (aFlyoutVector))); + } + else if (aTextPosProj.Distance (theFirstPoint) > theFirstPoint.Distance (theSecondPoint)) + { + myDrawer->DimensionAspect()->SetTextHorizontalPosition (Prs3d_DTHP_Right); + myDrawer->DimensionAspect()->SetExtensionSize (theTextPos.Distance (theSecondPoint.Translated (aFlyoutVector))); + } + else + { + myDrawer->DimensionAspect()->SetTextHorizontalPosition (Prs3d_DTHP_Center); + + if (LayoutMode() == AIS_DLM_Automatic) + { + // Adjust text position so that text was aligned. + myFixedTextPosition = theFirstPoint.Translated (aTargetPointsVec * 0.5 + aFlyoutVector); + } + } + return Standard_True; +} + +//======================================================================= +//function : GetTextPositionForLinear +//purpose : +//======================================================================= +gp_Pnt AIS_Dimension::GetTextPositionForLinear (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const Standard_Boolean theIsOneSide) const +{ + if (!myIsValid) + { + return gp::Origin(); + } + + gp_Pnt aTextPosition (gp::Origin()); + + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + + // Get label alignment and arrow orientation. + Standard_Integer aLabelPosition = 0; + Standard_Boolean isArrowsExternal = Standard_False; + FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, + aLabelPosition, isArrowsExternal); + + // Compute dimension line points. + gp_Dir aPlaneNormal = GetPlane().Axis().Direction(); + gp_Vec aTargetPointsVec (theFirstPoint, theSecondPoint); + + // Compute flyout direction vector + gp_Dir aFlyoutVector = aPlaneNormal ^ gp_Dir(aTargetPointsVec); + + // create lines for layouts + gp_Lin aLine1 (theFirstPoint, aFlyoutVector); + gp_Lin aLine2 (theSecondPoint, aFlyoutVector); + // Get flyout end points + gp_Pnt aLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1); + gp_Pnt aLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2); + + + // Get text position. + switch (aLabelPosition & LabelPosition_HMask) + { + case LabelPosition_Left: + { + gp_Dir aTargetPointsDir = gce_MakeDir (theFirstPoint, theSecondPoint); + Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize(); + Standard_Real anOffset = isArrowsExternal + ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length() + : anExtensionSize; + gp_Vec anExtensionVec = gp_Vec(aTargetPointsDir)*(-anOffset); + aTextPosition = aLineEndPoint.Translated (anExtensionVec); + } + break; + case LabelPosition_Right: + { + gp_Dir aTargetPointsDir = gce_MakeDir (theFirstPoint, theSecondPoint); + Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize(); + Standard_Real anOffset = isArrowsExternal + ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length() + : anExtensionSize; + gp_Vec anExtensionVec = gp_Vec(aTargetPointsDir)*(anOffset); + aTextPosition = aLineBegPoint.Translated (anExtensionVec); + } + break; + case LabelPosition_HCenter: + { + aTextPosition = (aLineBegPoint.XYZ() + aLineEndPoint.XYZ()) * 0.5; + } + break; + } + + return aTextPosition; +} + +//======================================================================= +//function : FitTextAlignment +//purpose : +//======================================================================= +void AIS_Dimension::FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const Standard_Boolean theIsOneSide, + Standard_Integer& theLabelPosition, + Standard_Boolean& theIsArrowsExternal) const +{ + theLabelPosition = LabelPosition_None; + theIsArrowsExternal = Standard_False; + + // Compute dimension line points + gp_Ax1 aPlaneNormal = GetPlane().Axis(); + gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint); + + // compute flyout direction vector + gp_Dir aFlyoutVector = aPlaneNormal.Direction() ^ aTargetPointsVector; + + // create lines for layouts + gp_Lin aLine1 (theFirstPoint, aFlyoutVector); + gp_Lin aLine2 (theSecondPoint, aFlyoutVector); + + // Get flyout end points + gp_Pnt aLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1); + gp_Pnt aLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2); + + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + + gp_Lin aDimensionLine = gce_MakeLin (aLineBegPoint, aLineEndPoint); + + // For extensions we need to know arrow size, text size and extension size: get it from aspect + Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length(); + // prepare label string and compute its geometrical width + Standard_Real aLabelWidth; + TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth); + + // Add margins to cut dimension lines for 3d text + if (aDimensionAspect->IsText3d()) + { + aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0; + } + + // Handle user-defined and automatic arrow placement + switch (aDimensionAspect->ArrowOrientation()) + { + case Prs3d_DAO_External: theIsArrowsExternal = true; break; + case Prs3d_DAO_Internal: theIsArrowsExternal = false; break; + case Prs3d_DAO_Fit: + { + // Add margin to ensure a small tail between text and arrow + Standard_Real anArrowMargin = aDimensionAspect->IsText3d() + ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN + : 0.0; + + Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint); + Standard_Real anArrowsWidth = theIsOneSide + ? anArrowLength + anArrowMargin + : (anArrowLength + anArrowMargin) * 2.0; + + theIsArrowsExternal = aDimensionWidth < aLabelWidth + anArrowsWidth; + break; + } + } + + // Compute arrows positions and directions + gp_Dir aFirstArrowDir = aDimensionLine.Direction().Reversed(); + gp_Dir aSecondArrowDir = aDimensionLine.Direction(); + gp_Dir aFirstExtensionDir = aDimensionLine.Direction().Reversed(); + gp_Dir aSecondExtensionDir = aDimensionLine.Direction(); + + if (theIsArrowsExternal) + { + aFirstArrowDir.Reverse(); + aSecondArrowDir.Reverse(); + } + + // Handle user-defined and automatic text placement + switch (aDimensionAspect->TextHorizontalPosition()) + { + case Prs3d_DTHP_Left : theLabelPosition |= LabelPosition_Left; break; + case Prs3d_DTHP_Right : theLabelPosition |= LabelPosition_Right; break; + case Prs3d_DTHP_Center: theLabelPosition |= LabelPosition_HCenter; break; + case Prs3d_DTHP_Fit: + { + Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint); + Standard_Real anArrowsWidth = theIsOneSide ? anArrowLength : 2.0 * anArrowLength; + Standard_Real aContentWidth = theIsArrowsExternal ? aLabelWidth : aLabelWidth + anArrowsWidth; + + theLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter; + break; + } + } + + // Handle vertical text placement options + switch (aDimensionAspect->TextVerticalPosition()) + { + case Prs3d_DTVP_Above : theLabelPosition |= LabelPosition_Above; break; + case Prs3d_DTVP_Below : theLabelPosition |= LabelPosition_Below; break; + case Prs3d_DTVP_Center : theLabelPosition |= LabelPosition_VCenter; break; + } +} diff --git a/src/AIS/AIS_Dimension.hxx b/src/AIS/AIS_Dimension.hxx index 39e28dc4ec..3a50257b53 100755 --- a/src/AIS/AIS_Dimension.hxx +++ b/src/AIS/AIS_Dimension.hxx @@ -16,6 +16,7 @@ #ifndef _AIS_Dimension_HeaderFile #define _AIS_Dimension_HeaderFile +#include #include #include #include @@ -56,11 +57,11 @@ DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject) //! The specified by user units are stored in the dimension's drawer. //! //! As a drawing, the dimension is composed from the following components: -//! - Attachement (binding) points. The points where the dimension lines attaches to, for +//! - Attachment (binding) points. The points where the dimension lines attaches to, for //! length dimensions the distances are measured between these points. -//! - Main dimension line. The which extends from the attachement points in "up" direction, +//! - Main dimension line. The which extends from the attachment points in "up" direction, //! and which contains text label on it with value string. -//! - Flyouts. The lines connecting the attachement points with main dimension line. +//! - Flyouts. The lines connecting the attachment points with main dimension line. //! - Extension. The lines used to extend the main dimension line in the cases when text //! or arrows do not fit into the main dimension line due to their size. //! - Arrows. @@ -75,7 +76,7 @@ DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject) //! |flyout flyout| //! | | //! +-----------------------------------+ -//! attachement attachement +//! attachment attachment //! point point //! //! Angular dimensions: @@ -130,19 +131,46 @@ DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject) //! //! The dimension support two local selection modes: main dimension line selection and text label //! selection. These modes can be used to develop interactive modification of dimension presentations. -//! The component hilighting in these selection modes is provided by AIS_DimensionOwner class. +//! The component highlighting in these selection modes is provided by AIS_DimensionOwner class. //! Please note that selection is unavailable until the presentation is computed. //! //! The specific drawing attributes are controlled through Prs3d_DimensionAspect. The one can change //! color, arrows, text and arrow style and specify positioning of value label by setting corresponding //! values to the aspect. //! +//! Such set of parameters that consists of: +//! - flyout size and direction, +//! - user-defined dimension plane, +//! - horizontal and vertical text alignment +//! can be uniquely replaced with text position in 3d space. Therefore, there are methods to convert +//! this set of parameters to the text position and vice versa: +//! +//! - If the fixed text position is defined by user, called SetTextPosition (theTextPos) method converts +//! this 3d point to the set of parameters including adjusting of the dimension plane (this plane will be +//! automatic plane, NOT user-defined one). +//! If the fixed text position is set, the flag myIsFixedTextPosition is set to TRUE. +//! ATTENSION! myIsFixedTextPosition fixes all parameters of the set from recomputing inside +//! SetMeasureGeometry() methods. Parameters from the set can be changed only directly by user with +//! calls of setters. In this case changing of some parameter from the set leads to disabling the of +//! fixed text position (myIsFixedTextPosition is set to FALSE). +//! If the fixed text position is set and geometry is changed by user (SetMeasureGeometry() method +//! is called) and the geometry doesn't satisfy computed dimension plane, the dimension is not valid. +//! +//! - If the set of parameters was set by user (may be without the user-defined plane or with it), +//! it can be converted to the text position by calling the method GetTextPosition(). In this case +//! the text position is NOT fixed, and SetMeasureGeometry() without user-defined plane adjusts +//! the automatic plane according input geometry (if it is possible). +//! +//! ATTENSION! By default after SetTextPosition() call the text label is automatically aligned. +//! This means that if text was placed not on the extensions (between attachment points), it will +//! centered. If you want to uncentered text use SetLayoutMode (DLM_Manual), otherwise dimension +//! layout mode will be set as automatic and text will be aligned and centered. class AIS_Dimension : public AIS_InteractiveObject { protected: //! Geometry type defines type of shapes on which the dimension is to be built. - //! Some type of geometry allows automatical plane computing and + //! Some type of geometry allows automatic plane computing and //! can be built without user-defined plane //! Another types can't be built without user-defined plane. enum GeometryType @@ -212,8 +240,8 @@ public: //! By default, if plane is not defined by user, it is computed automatically //! after dimension geometry is computed. //! If computed dimension geometry (points) can't be placed on the user-defined - //! plane, dimension geometry was set as unvalid (validity flag is set to false) - //! and dimension presentation wil not be computed. + //! plane, dimension geometry was set as invalid (validity flag is set to false) + //! and dimension presentation will not be computed. //! If user-defined plane allow geometry placement on it, it will be used for //! computing of the dimension presentation. //! @return dimension plane used for presentation computing. @@ -233,6 +261,22 @@ public: //! computed automatically. Standard_EXPORT void UnsetCustomPlane() { myIsPlaneCustom = Standard_False; } + //! @return TRUE if text position is set by user with method SetTextPosition(). + Standard_Boolean IsTextPositionCustom () const + { + return myIsTextPositionFixed; + } + + //! Fixes the absolute text position and adjusts flyout, plane and text alignment + //! according to it. Updates presentation if the text position is valid. + //! ATTENTION! It does not change vertical text alignment. + //! @param theTextPos [in] the point of text position. + virtual void SetTextPosition (const gp_Pnt& /*theTextPos*/) { } + + //! Computes absolute text position from dimension parameters + //! (flyout, plane and text alignment). + virtual const gp_Pnt GetTextPosition () const { return gp_Pnt(); } + public: //! Gets the dimension aspect from AIS object drawer. @@ -256,7 +300,7 @@ public: //! @return the kind of interactive. virtual AIS_KindOfInteractive Type() const { - return AIS_KOI_Relation; + return AIS_KOI_Dimension; } //! Returns true if the class of objects accepts the display mode theMode. @@ -321,13 +365,24 @@ public: Standard_EXPORT void SetFlyout (const Standard_Real theFlyout); //! Check that the input geometry for dimension is valid and the - //! presentation can be succesfully computed. + //! presentation can be successfully computed. //! @return TRUE if dimension geometry is ok. Standard_Boolean IsValid() const { return myIsValid; } + //! @return layout mode - how the label will be placed + //! relative to the dimension line. + AIS_DimensionLayoutMode LayoutMode() const + { + return myLayoutMode; + } + + //! Sets layout mode. + //! @param theLayoutMode [in] the layout mode. + Standard_EXPORT void SetLayoutMode (const AIS_DimensionLayoutMode theLayoutMode); + public: DEFINE_STANDARD_RTTI(AIS_Dimension) @@ -426,6 +481,42 @@ protected: gp_Circ& theCircle, gp_Pnt& theMiddleArcPoint, Standard_Boolean& theIsClosed); + + //! Produce points for triangular arrow face. + //! @param thePeakPnt [in] the arrow peak position. + //! @param theDirection [in] the arrow direction. + //! @param thePlane [in] the face plane. + //! @param theArrowLength [in] the length of arrow. + //! @param theArrowAngle [in] the angle of arrow. + //! @param thePeakPnt [in] the arrow peak point. + //! @param theSidePnt1 [in] the first side point. + //! @param theSidePnt2 [in] the second side point. + Standard_EXPORT void PointsForArrow (const gp_Pnt& thePeakPnt, + const gp_Dir& theDirection, + const gp_Dir& thePlane, + const Standard_Real theArrowLength, + const Standard_Real theArrowAngle, + gp_Pnt& theSidePnt1, + gp_Pnt& theSidePnt2); + + //! Compute point of text position for dimension parameters + //! for linear kinds of dimensions (length, radius, diameter). + Standard_EXPORT gp_Pnt GetTextPositionForLinear (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const Standard_Boolean theIsOneSide = Standard_False) const; + + //! Adjust dimension parameters for the given point of new text position + //! for linear kinds of dimensions (length, radius, diameter). + Standard_EXPORT Standard_Boolean SetTextPositionForLinear (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pnt& theTextPos); + + //! Fits text alignment relatively to the dimension line. + void FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const Standard_Boolean theIsOneSide, + Standard_Integer& theLabelPosition, + Standard_Boolean& theIsArrowsExternal) const; protected: //! @name Behavior to implement @@ -455,22 +546,6 @@ protected: //! @name Behavior to implement virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)&, const Handle(SelectMgr_EntityOwner)&) {} - //! Produce points for triangular arrow face. - //! @param thePeakPnt [in] the arrow peak position. - //! @param theDirection [in] the arrow direction. - //! @param thePlane [in] the face plane. - //! @param theArrowLength [in] the length of arrow. - //! @param theArrowAngle [in] the angle of arrow. - //! @param thePeakPnt [in] the arrow peak point. - //! @param theSidePnt1 [in] the first side point. - //! @param theSidePnt2 [in] the second side point. - Standard_EXPORT void PointsForArrow (const gp_Pnt& thePeakPnt, - const gp_Dir& theDirection, - const gp_Dir& thePlane, - const Standard_Real theArrowLength, - const Standard_Real theArrowAngle, - gp_Pnt& theSidePnt1, - gp_Pnt& theSidePnt2); //! Base procedure of computing selection (based on selection geometry data). //! @param theSelection [in] the selection structure to will with primitives. @@ -525,7 +600,7 @@ protected: //! @name Selection geometry } } - //! Add new curve entry and return the referenece to populate it. + //! Add new curve entry and return the reference to populate it. Curve& NewCurve() { DimensionLine.Append( new Curve ); @@ -533,7 +608,7 @@ protected: //! @name Selection geometry return *aLastCurve; } - //! Add new arrow entry and return the referenece to populate it. + //! Add new arrow entry and return the reference to populate it. Arrow& NewArrow() { Arrows.Append( new Arrow ); @@ -550,6 +625,12 @@ protected: //! @name Value properties Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined). Standard_Boolean myIsValueCustom; //!< Is user-defined value. +protected: //! @name Fixed text position properties + + AIS_DimensionLayoutMode myLayoutMode; //!< controls how label will be placed relatively to the line. + gp_Pnt myFixedTextPosition; //!< Stores text position fixed by user. + Standard_Boolean myIsTextPositionFixed; //!< Is the text label position fixed by user. + protected: //! @name Units properties Standard_ExtCharacter mySpecialSymbol; //!< Special symbol. diff --git a/src/AIS/AIS_DimensionLayoutMode.hxx b/src/AIS/AIS_DimensionLayoutMode.hxx new file mode 100644 index 0000000000..f5cb702f07 --- /dev/null +++ b/src/AIS/AIS_DimensionLayoutMode.hxx @@ -0,0 +1,24 @@ +// This file is generated by WOK (CPPExt). +// Please do not edit this file; modify original file instead. +// The copyright and license terms as defined for the original file apply to +// this header file considered to be the "object code" form of the original source. + +#ifndef _AIS_DimensionLayoutMode_HeaderFile +#define _AIS_DimensionLayoutMode_HeaderFile + +//! Specifies dimension layout mode: how text and dimension line
+//! will be placed.
+//! If DLM_Automatic mode is chosen text will be aligned automatically
+//! and centered if it is placed not on the extensions.
+//! If DLM_Manual mode is chosen text position will not been centered
+//! and is placed just where its position is set by user.
+enum AIS_DimensionLayoutMode { +AIS_DLM_Automatic, +AIS_DLM_Manual +}; + +#ifndef _Standard_PrimitiveTypes_HeaderFile +#include +#endif + +#endif diff --git a/src/AIS/AIS_InteractiveContext.cdl b/src/AIS/AIS_InteractiveContext.cdl index 3eb225e01f..a80a04456b 100644 --- a/src/AIS/AIS_InteractiveContext.cdl +++ b/src/AIS/AIS_InteractiveContext.cdl @@ -138,7 +138,8 @@ uses EntityOwner from SelectMgr, TypeOfFacingModel from Aspect, Array1OfPnt2d from TColgp, - Transformation from Geom + Transformation from Geom, + SequenceOfShape from TopTools is @@ -2104,6 +2105,7 @@ fields -- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject(). myZDetectionFlag: Boolean from Standard; -- This variables is used by SetZDetection() and ZDetection() methods + myAISDetectedShapes : SequenceOfShape from TopTools; -- abd: myIsAutoActivateSelMode : Boolean from Standard; diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 75d82a3d7c..56e490d017 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -238,15 +238,14 @@ void AIS_InteractiveContext::DisplayedObjects(AIS_ListOfInteractive& aListOfIO, #endif //parse all local contexts... +#ifdef DEBUG Standard_Integer NbDisp; for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){ const Handle(AIS_LocalContext)& LC = it1.Value(); NbDisp = LC->DisplayedObjects(theMap); -#ifdef DEBUG cout<<"\tIn Local Context "<Remove(anIObj); + myLocalContexts(myCurLocalIndex)->Remove(anIObj); AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts); for (;It.More() ;It.Next()){ if(It.Value()->AcceptErase()) - WasInCtx = It.Value()->Remove(anIObj); + It.Value()->Remove(anIObj); } // if(!WasInCtx) @@ -2417,7 +2416,10 @@ void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& an { Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject(); if( !anObj.IsNull() && anObj != anIObj ) + { myAISDetectedSeq.Remove( i ); + myAISDetectedShapes.Remove(i); + } } if(myLastinMain == anIObj) diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index b5094e5171..01c19aed9d 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #ifdef IMP150501 #include @@ -146,6 +147,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix //Nullify class members storing information about detected AIS objects. myAISCurDetected = 0; myAISDetectedSeq.Clear(); + myAISDetectedShapes.Clear(); #endif // OCC11904 - local variables made non-static - it looks and works better like this @@ -183,7 +185,16 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(anEntityOwner->Selectable()); if(!Handle(AIS_Shape)::DownCast(anObj).IsNull()) + { myAISDetectedSeq.Append(anObj); + + // Memorize detected shape. + TopoDS_Shape detectedShape; + Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(anEntityOwner); + if (!aBRepOwner.IsNull() && aBRepOwner->HasShape()) + detectedShape = aBRepOwner->Shape(); + myAISDetectedShapes.Append(detectedShape); + } } } #endif @@ -1418,7 +1429,11 @@ const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const static TopoDS_Shape bidsh; if(myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length()) - return Handle(AIS_Shape)::DownCast(myAISDetectedSeq(myAISCurDetected))->Shape(); + { + if (myAISDetectedShapes(myAISCurDetected).IsNull()) + return Handle(AIS_Shape)::DownCast(myAISDetectedSeq(myAISCurDetected))->Shape(); + return myAISDetectedShapes(myAISCurDetected); + } return bidsh; } diff --git a/src/AIS/AIS_LengthDimension.cxx b/src/AIS/AIS_LengthDimension.cxx index 86b0ff47b8..b9226520fc 100755 --- a/src/AIS/AIS_LengthDimension.cxx +++ b/src/AIS/AIS_LengthDimension.cxx @@ -708,3 +708,33 @@ Standard_Boolean AIS_LengthDimension::InitOneShapePoints (const TopoDS_Shape& th return IsValidPoints (myFirstPoint, mySecondPoint); } + +//======================================================================= +//function : GetTextPosition +//purpose : +//======================================================================= +const gp_Pnt AIS_LengthDimension::GetTextPosition () const +{ + if (myIsTextPositionFixed) + { + return myFixedTextPosition; + } + + // Counts text position according to the dimension parameters + return GetTextPositionForLinear (myFirstPoint, mySecondPoint); +} + +//======================================================================= +//function : SetTextPosition +//purpose : +//======================================================================= +void AIS_LengthDimension::SetTextPosition (const gp_Pnt& theTextPos) +{ + if (!myIsValid) + { + return; + } + + SetTextPositionForLinear (myFirstPoint, mySecondPoint, theTextPos); + SetToUpdate(); +} diff --git a/src/AIS/AIS_LengthDimension.hxx b/src/AIS/AIS_LengthDimension.hxx index cd23349ab0..41b519e3ea 100755 --- a/src/AIS/AIS_LengthDimension.hxx +++ b/src/AIS/AIS_LengthDimension.hxx @@ -188,7 +188,7 @@ public: //! @return the display units string. Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits () const; - + //! @return the model units string. Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits () const; @@ -196,6 +196,10 @@ public: Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits); + Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos); + + Standard_EXPORT virtual const gp_Pnt GetTextPosition () const; + public: DEFINE_STANDARD_RTTI(AIS_LengthDimension) diff --git a/src/AIS/AIS_LocalContext.cdl b/src/AIS/AIS_LocalContext.cdl index 11341c07c0..15557c6c4d 100644 --- a/src/AIS/AIS_LocalContext.cdl +++ b/src/AIS/AIS_LocalContext.cdl @@ -77,7 +77,8 @@ uses LocalStatus from AIS, StatusOfPick from AIS, StatusOfDetection from AIS, - SequenceOfInteractive from AIS + SequenceOfInteractive from AIS, + SequenceOfShape from TopTools is @@ -629,6 +630,7 @@ fields myAISCurDetected : Integer from Standard; -- This variables is used by following functions: -- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject(). + myAISDetectedShapes : SequenceOfShape from TopTools; friends diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index 631edf9b25..7707e1b3cf 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -445,7 +445,6 @@ Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& a const Handle(AIS_LocalStatus)& Att = myActiveObjects(aSelectable); TColStd_ListIteratorOfListOfInteger It; - Standard_Boolean jobdone(Standard_False); // it is checked which were the temporary attributes // and they are set to 0 @@ -468,7 +467,6 @@ Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& a if(myMainPM->IsDisplayed(aSelectable,Att->HilightMode())) myMainPM->Erase(aSelectable,Att->HilightMode()); // myMainPM->Clear(aSelectable,Att->HilightMode()); - jobdone = Standard_True; } // if below intensity else @@ -505,7 +503,10 @@ Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& a { Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject(); if( !anObj.IsNull() && anObj != aSelectable ) + { myAISDetectedSeq.Remove( i ); + myAISDetectedShapes.Remove( i ); + } } Standard_Integer aHM = aSelectable->HasHilightMode() ? aSelectable->HilightMode() : 0; diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index 6ba62da5ff..2bac66b863 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -127,6 +127,7 @@ AIS_StatusOfDetection AIS_LocalContext::MoveTo(const Standard_Integer Xpix, //Nullify class members storing information about detected AIS objects. myAISCurDetected = 0; myAISDetectedSeq.Clear(); + myAISDetectedShapes.Clear(); #endif myCurDetected = 0; myDetectedSeq.Clear(); @@ -142,8 +143,20 @@ AIS_StatusOfDetection AIS_LocalContext::MoveTo(const Standard_Integer Xpix, myDetectedSeq.Append(i_detect); // normallly they are already arranged in correct order... #ifdef IMP160701 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable()); - if(!Handle(AIS_Shape)::DownCast(anObj).IsNull()) + Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast(anObj); + if(!aisShape.IsNull()) + { myAISDetectedSeq.Append(anObj); + + // Memorize detected shape. + TopoDS_Shape detectedShape; + Handle(StdSelect_BRepOwner) BO = Handle(StdSelect_BRepOwner)::DownCast(EO); + if (!BO.IsNull() && BO->HasShape()) + detectedShape = BO->Shape(); + else if (!aisShape->Shape().IsNull()) + detectedShape = aisShape->Shape(); + myAISDetectedShapes.Append(detectedShape); + } #endif } } @@ -1017,7 +1030,9 @@ void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& } } if(EO.IsNull()) + { EO = new SelectMgr_EntityOwner(anIObj); + } #ifndef OCC138 EO->State(1); #endif @@ -1596,7 +1611,11 @@ const TopoDS_Shape& AIS_LocalContext::DetectedCurrentShape() const { static TopoDS_Shape bidsh; if (MoreDetected()) - return Handle(AIS_Shape)::DownCast(myAISDetectedSeq(myAISCurDetected))->Shape(); + { + if (myAISDetectedShapes(myAISCurDetected).IsNull()) + return Handle(AIS_Shape)::DownCast(myAISDetectedSeq(myAISCurDetected))->Shape(); + return myAISDetectedShapes(myAISCurDetected); + } return bidsh; } diff --git a/src/AIS/AIS_RadiusDimension.cxx b/src/AIS/AIS_RadiusDimension.cxx index ab737d099d..ac0d07e07b 100644 --- a/src/AIS/AIS_RadiusDimension.cxx +++ b/src/AIS/AIS_RadiusDimension.cxx @@ -262,3 +262,33 @@ Standard_Boolean AIS_RadiusDimension::IsValidAnchor (const gp_Circ& theCircle, return Abs (anAnchorDist - aRadius) > Precision::Confusion() && aCirclePlane.Contains (theAnchor, Precision::Confusion()); } + +//======================================================================= +//function : GetTextPosition +//purpose : +//======================================================================= +const gp_Pnt AIS_RadiusDimension::GetTextPosition () const +{ + if (myIsTextPositionFixed) + { + return myFixedTextPosition; + } + + // Counts text position according to the dimension parameters + return GetTextPositionForLinear (myAnchorPoint, myCircle.Location(), Standard_True); +} + +//======================================================================= +//function : GetTextPosition +//purpose : +//======================================================================= +void AIS_RadiusDimension::SetTextPosition (const gp_Pnt& theTextPos) +{ + if (!myIsValid) + { + return; + } + + SetTextPositionForLinear (myAnchorPoint, myCircle.Location(), theTextPos); + SetToUpdate(); +} diff --git a/src/AIS/AIS_RadiusDimension.hxx b/src/AIS/AIS_RadiusDimension.hxx index f501b9bd4e..18a40ca826 100644 --- a/src/AIS/AIS_RadiusDimension.hxx +++ b/src/AIS/AIS_RadiusDimension.hxx @@ -50,7 +50,7 @@ public: //! orientation by location of the first point on that circle. //! @param theCircle [in] the circle to measure. //! @param theAnchorPoint [in] the point to define the position - //! of the dimension attachement on the circle. + //! of the dimension attachment on the circle. Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle, const gp_Pnt& theAnchorPoint); @@ -88,7 +88,7 @@ public: //! Measure radius of the circle and orient the dimension so //! the dimension lines attaches to anchor point on the circle. - //! The dimension will become invalid if the radiuss of the circle + //! The dimension will become invalid if the radius of the circle //! is less than Precision::Confusion(). //! @param theCircle [in] the circle to measure. //! @param theAnchorPoint [in] the point to attach the dimension lines. @@ -111,6 +111,10 @@ public: Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits); + Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos); + + Standard_EXPORT virtual const gp_Pnt GetTextPosition () const; + public: DEFINE_STANDARD_RTTI (AIS_RadiusDimension) diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 09521e1623..bcbf06499a 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -464,7 +464,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, } // insert the drawer in the BrepOwners for hilight... - StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer); + // StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer); } Quantity_NameOfColor AIS_Shape::Color() const { diff --git a/src/AIS/FILES b/src/AIS/FILES index 44b3f064ad..6e2c572caa 100755 --- a/src/AIS/FILES +++ b/src/AIS/FILES @@ -17,3 +17,4 @@ AIS_DiameterDimension.hxx AIS_DiameterDimension.cxx AIS_RadiusDimension.hxx AIS_RadiusDimension.cxx +AIS_DimensionLayoutMode.hxx diff --git a/src/BRep/BRep_Builder.cxx b/src/BRep/BRep_Builder.cxx index 9aebd3427b..6d1f20f8d6 100644 --- a/src/BRep/BRep_Builder.cxx +++ b/src/BRep/BRep_Builder.cxx @@ -5,8 +5,8 @@ // // This file is part of Open CASCADE Technology software library. // -// This library is free software; you can redistribute it and / or modify it -// under the terms of the GNU Lesser General Public version 2.1 as published +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. @@ -234,11 +234,20 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, Handle(BRep_CurveRepresentation) cr; Handle(BRep_GCurve) GC; Standard_Real f = 0.,l = 0.; + Standard_Boolean rangeFound = Standard_False; while (itcr.More()) { GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); if ( !GC.IsNull() ) { - GC->Range(f,l); + if (GC->IsCurve3D()) { + GC->Range(f,l); + Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) || + Precision::IsNegativeInfinite(f)); + + if (!undefined) { + rangeFound = Standard_True; + } + } Standard_Boolean iscos = GC->IsCurveOnSurface(S,L); if (iscos) break; } @@ -256,7 +265,7 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, Handle(BRep_CurveOnClosedSurface) COS = new BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0); // test if there is already a range - if (!GC.IsNull()) { + if (rangeFound) { COS->SetRange(f,l); } lcr.Append(COS); @@ -281,11 +290,20 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, Handle(BRep_CurveRepresentation) cr; Handle(BRep_GCurve) GC; Standard_Real f = 0.,l = 0.; + Standard_Boolean rangeFound = Standard_False; while (itcr.More()) { GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); if ( !GC.IsNull() ) { - GC->Range(f,l); + if (GC->IsCurve3D()) { + GC->Range(f,l); + Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) || + Precision::IsNegativeInfinite(f)); + + if (!undefined) { + rangeFound = Standard_True; + } + } Standard_Boolean iscos = GC->IsCurveOnSurface(S,L); if (iscos) break; } @@ -303,7 +321,7 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, Handle(BRep_CurveOnClosedSurface) COS = new BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0); // test if there is already a range - if (!GC.IsNull()) { + if (rangeFound) { COS->SetRange(f,l); } COS->SetUVPoints2(Pf,Pl); @@ -546,7 +564,6 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const TopLoc_Location l = L.Predivided(E.Location()); UpdateCurves(TE->ChangeCurves(),C,l); - if (!C.IsNull()) TE->Closed(C->IsClosed()); TE->UpdateTolerance(Tol); TE->Modified(Standard_True); @@ -613,8 +630,6 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const TopLoc_Location l = L.Predivided(E.Location()); UpdateCurves(TE->ChangeCurves(),C1,C2,S,l); - if (!C1.IsNull() && !C2.IsNull()) - TE->Closed(C1->IsClosed() && C2->IsClosed()); TE->UpdateTolerance(Tol); TE->Modified(Standard_True); @@ -639,9 +654,7 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const TopLoc_Location l = L.Predivided(E.Location()); UpdateCurves(TE->ChangeCurves(),C1,C2,S,l,Pf,Pl); - if (!C1.IsNull() && !C2.IsNull()) - TE->Closed(C1->IsClosed() && C2->IsClosed()); - + TE->UpdateTolerance(Tol); TE->Modified(Standard_True); } @@ -705,14 +718,14 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, while (itcr.More()) { if (itcr.Value()->IsPolygonOnTriangulation(T,l)) - { + { // cr is used to keep a reference on the curve representation // this avoid deleting it as its content may be referenced by T cr = itcr.Value(); lcr.Remove(itcr); isModified = Standard_True; break; - } + } itcr.Next(); } @@ -996,23 +1009,8 @@ void BRep_Builder::Range(const TopoDS_Edge& E, while (itcr.More()) { GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); - if (!GC.IsNull()) { - if (!Only3d || GC->IsCurve3D()) - GC->SetRange(First,Last); - if (GC->IsCurve3D()) { - // Set the closedness flag to the correct value. - Handle(Geom_Curve) C = GC->Curve3D(); - - //fixing a bug PRO18577 to avoid infinite values of First and Last - if ( !C.IsNull() && - !Precision::IsNegativeInfinite(First) && - !Precision::IsPositiveInfinite(Last) ) { - Standard_Boolean closed = - C->Value(First).IsEqual(C->Value(Last),BRep_Tool::Tolerance(E)); - TE->Closed(closed); - } - } - } + if (!GC.IsNull() && (!Only3d || GC->IsCurve3D())) + GC->SetRange(First,Last); itcr.Next(); } @@ -1040,20 +1038,10 @@ void BRep_Builder::Range(const TopoDS_Edge& E, while (itcr.More()) { GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); - if (!GC.IsNull()) { - if (GC->IsCurveOnSurface(S,l)) { - GC->SetRange(First,Last); - - // Set the closedness flag to the correct value. - Handle(Geom2d_Curve) PC = GC->PCurve(); - gp_Pnt2d P1 = PC->Value(First); - gp_Pnt2d P2 = PC->Value(Last); - gp_Pnt PP1 = S->Value(P1.X(),P1.Y()); - gp_Pnt PP2 = S->Value(P2.X(),P2.Y()); - Standard_Boolean closed = PP1.IsEqual(PP2,BRep_Tool::Tolerance(E)); - TE->Closed(closed); - break; - } + if (!GC.IsNull() && GC->IsCurveOnSurface(S,l)) + { + GC->SetRange(First,Last); + break; } itcr.Next(); } @@ -1076,7 +1064,7 @@ void BRep_Builder::Transfert(const TopoDS_Edge& Ein, const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &Ein.TShape()); const Standard_Real tol = TE->Tolerance(); - + BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); diff --git a/src/BRepBuilderAPI/BRepBuilderAPI_VertexInspector.hxx b/src/BRepBuilderAPI/BRepBuilderAPI_VertexInspector.hxx index 0183523933..ad763eb01a 100644 --- a/src/BRepBuilderAPI/BRepBuilderAPI_VertexInspector.hxx +++ b/src/BRepBuilderAPI/BRepBuilderAPI_VertexInspector.hxx @@ -4,8 +4,8 @@ // // This file is part of Open CASCADE Technology software library. // -// This library is free software; you can redistribute it and / or modify it -// under the terms of the GNU Lesser General Public version 2.1 as published +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. @@ -16,22 +16,11 @@ #ifndef _BRepBuilderAPI_VertexInspector_Header #define _BRepBuilderAPI_VertexInspector_Header -#ifndef _TColStd_ListOfInteger_HeaderFile #include -#endif -#ifndef NCollection_Vector_HeaderFile #include -#endif -#ifndef _gp_XY_HeaderFile #include -#endif -#ifndef _gp_XYZ_HeaderFile #include -#endif - -#ifndef NCollection_CellFilter_HeaderFile #include -#endif typedef NCollection_Vector VectorOfPoint; @@ -48,8 +37,7 @@ class BRepBuilderAPI_VertexInspector : public NCollection_CellFilter_InspectorXY public: typedef Standard_Integer Target; //! Constructor; remembers the tolerance - BRepBuilderAPI_VertexInspector (const Standard_Real theTol) - : myTol(theTol*theTol) + BRepBuilderAPI_VertexInspector (const Standard_Real theTol):myTol(theTol*theTol) {} //! Keep the points used for comparison @@ -77,7 +65,7 @@ public: } //! Implementation of inspection method - NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget); + Standard_EXPORT NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget); private: Standard_Real myTol; diff --git a/src/BRepFill/BRepFill_OffsetWire.cdl b/src/BRepFill/BRepFill_OffsetWire.cdl index 6c766f460f..092db05eeb 100644 --- a/src/BRepFill/BRepFill_OffsetWire.cdl +++ b/src/BRepFill/BRepFill_OffsetWire.cdl @@ -5,8 +5,8 @@ -- -- This file is part of Open CASCADE Technology software library. -- --- This library is free software; you can redistribute it and / or modify it --- under the terms of the GNU Lesser General Public version 2.1 as published +-- This library is free software; you can redistribute it and/or modify it under +-- the terms of the GNU Lesser General Public License version 2.1 as published -- by the Free Software Foundation, with special exception defined in the file -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -- distribution for complete text of the license and disclaimer of any warranty. @@ -18,17 +18,22 @@ class OffsetWire from BRepFill ---Purpose: Constructs a Offset Wire to a spine (wire or face) -- on the left of spine. - + -- The Wire or the Face must be planar. uses Face from TopoDS, Shape from TopoDS, JoinType from GeomAbs, ListOfShape from TopTools, + SequenceOfShape from TopTools, + SequenceOfPnt from TColgp, DataMapOfShapeShape from TopTools, IndexedDataMapOfOrientedShapeListOfShape from BRepFill, + DataMapOfOrientedShapeListOfShape from BRepFill, BisectingLocus from BRepMAT2d, - LinkTopoBilo from BRepMAT2d + LinkTopoBilo from BRepMAT2d, + Bisec from Bisector, + TrimEdgeTool from BRepFill raises ConstructionError from Standard, @@ -39,12 +44,14 @@ is Create returns OffsetWire from BRepFill; Create ( Spine : Face from TopoDS; - Join : JoinType from GeomAbs = GeomAbs_Arc) + Join : JoinType from GeomAbs = GeomAbs_Arc; + IsOpenResult : Boolean from Standard = Standard_False) returns OffsetWire from BRepFill; Init ( me : in out; Spine : Face from TopoDS; - Join : JoinType from GeomAbs = GeomAbs_Arc) + Join : JoinType from GeomAbs = GeomAbs_Arc; + IsOpenResult : Boolean from Standard = Standard_False) ---Purpose: Initialize the evaluation of Offseting. raises ConstructionError from Standard @@ -114,6 +121,16 @@ is ---Purpose: Add the OffsetWire to and update is static private; + UpdateDetromp (me; Detromp : in out DataMapOfOrientedShapeListOfShape from BRepFill; + Shape1, Shape2 : Shape from TopoDS; + Vertices : SequenceOfShape from TopTools; + Params : SequenceOfPnt from TColgp; + Bisec : Bisec from Bisector; + SOnE : Boolean from Standard; + EOnE : Boolean from Standard; + Trim : TrimEdgeTool from BRepFill) + is static private; + MakeWires (me : in out) ---Purpose: Constructs the wires with the trimmed offset edges. is static private; @@ -127,6 +144,7 @@ fields mySpine : Face from TopoDS; myWorkSpine : Face from TopoDS; myOffset : Real from Standard; -- >0 ; + myIsOpenResult : Boolean from Standard; myShape : Shape from TopoDS; myIsDone : Boolean from Standard; myJoinType : JoinType from GeomAbs; diff --git a/src/BRepFill/BRepFill_OffsetWire.cxx b/src/BRepFill/BRepFill_OffsetWire.cxx index ee07c071a4..aed31f7483 100644 --- a/src/BRepFill/BRepFill_OffsetWire.cxx +++ b/src/BRepFill/BRepFill_OffsetWire.cxx @@ -5,8 +5,8 @@ // // This file is part of Open CASCADE Technology software library. // -// This library is free software; you can redistribute it and / or modify it -// under the terms of the GNU Lesser General Public version 2.1 as published +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -105,9 +106,6 @@ #include #include #include -#endif - -#ifdef DEB static Standard_Boolean AffichGeom = Standard_False; static Standard_Boolean Affich2d = Standard_False; static Standard_Boolean AffichEdge = Standard_False; @@ -115,10 +113,6 @@ static Standard_Integer NbTRIMEDGES = 0; static Standard_Integer NbOFFSET = 0; static Standard_Integer NbEDGES = 0; static Standard_Integer NbBISSEC = 0; -#ifndef WNT -static char tname[100]; -static Standard_CString name = tname ; -#endif #endif // Modified by Sergey KHROMOV - Thu Nov 16 17:24:39 2000 Begin @@ -174,15 +168,6 @@ static void EdgeVertices (const TopoDS_Edge& E, } } -static void UpdateDetromp (TopTools_ListOfShape& Detromp1, - TopTools_ListOfShape& Detromp2, - const TopTools_SequenceOfShape& Vertices, - const TColgp_SequenceOfPnt& Params, - const Bisector_Bisec& Bisec, - const Standard_Boolean SOnE, - const Standard_Boolean EOnE, - const BRepFill_TrimEdgeTool& Trim); - static Standard_Boolean VertexFromNode (const Handle(MAT_Node)& aNode, const Standard_Real Offset, @@ -196,10 +181,11 @@ static void StoreInMap (const TopoDS_Shape& V1, static void TrimEdge (const TopoDS_Edge& CurrentEdge, const TopTools_ListOfShape& D, - TopTools_SequenceOfShape& Sv, - TColStd_SequenceOfReal& MapverPar, - TopTools_SequenceOfShape& S, - TopTools_IndexedDataMapOfShapeShape& MapVV); + TopTools_SequenceOfShape& Sv, + TColStd_SequenceOfReal& MapverPar, + TopTools_SequenceOfShape& S, + TopTools_IndexedDataMapOfShapeShape& MapVV, + const Standard_Integer IndOfE); static Standard_Boolean DoubleOrNotInside (const TopTools_ListOfShape& EC, const TopoDS_Vertex& V); @@ -220,7 +206,9 @@ static void MakeOffset const TopoDS_Face& F, const Standard_Real Offset, BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map, - const Handle(Geom_Plane)& RefPlane); + const Handle(Geom_Plane)& RefPlane, + const Standard_Boolean IsOpenResult, + const TopoDS_Vertex * Ends); @@ -265,9 +253,6 @@ static Standard_Boolean KPartCircle E = TopoDS::Edge(exp.Current()); if (NbEdges > 1) return Standard_False; } - TopoDS_Vertex V1,V2; - TopExp::Vertices(E,V1,V2); - if (!V1.IsSame(V2)) return Standard_False; Standard_Real f,l; TopLoc_Location L; @@ -278,15 +263,43 @@ static Standard_Boolean KPartCircle C = Ct->BasisCurve(); } - if (!C->IsKind(STANDARD_TYPE(Geom_Circle))) return Standard_False; - Handle(Geom_Circle) CE = Handle(Geom_Circle)::DownCast(C); - Standard_Real anOffset = myOffset; - if (E.Orientation() == TopAbs_REVERSED) anOffset *= -1; - - if (anOffset < 0. || Abs(anOffset) < CE->Radius()) { - Handle(Geom_Circle) OC = new Geom_Circle (CE->Position(),CE->Radius() - anOffset); - myShape = BRepLib_MakeEdge(OC,f,l); - + TopoDS_Vertex V1,V2; + TopExp::Vertices(E,V1,V2); + if (!V1.IsSame(V2) || //open result or closed circle + C->IsKind(STANDARD_TYPE(Geom_Circle))) + { + Standard_Real anOffset = myOffset; + + Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(E, mySpine, f, l); + Handle(Geom2dAdaptor_HCurve) AHC = new Geom2dAdaptor_HCurve(aPCurve, f, l); + Handle(Geom2d_Curve) OC; + if (AHC->GetType() == GeomAbs_Line) + { + if (E.Orientation() == TopAbs_REVERSED) + anOffset *= -1; + Adaptor3d_OffsetCurve Off(AHC,anOffset); + OC = new Geom2d_Line(Off.Line()); + } + else if (AHC->GetType() == GeomAbs_Circle) + { + if (E.Orientation() == TopAbs_FORWARD) + anOffset *= -1; + gp_Circ2d theCirc = AHC->Circle(); + if (anOffset < 0. || Abs(anOffset) < theCirc.Radius()) + OC = new Geom2d_Circle (theCirc.Position(), theCirc.Radius() - anOffset); + } + else + { + if (E.Orientation() == TopAbs_FORWARD) + anOffset *= -1; + Handle(Geom2d_TrimmedCurve) G2dT = new Geom2d_TrimmedCurve(aPCurve, f, l); + OC = new Geom2d_OffsetCurve( G2dT, anOffset); + } + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(mySpine); + Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf); + myShape = BRepLib_MakeEdge(OC, aPlane, f, l); + BRepLib::BuildCurve3d(TopoDS::Edge(myShape)); + myShape.Orientation(E.Orientation()); myShape.Location(L); if (Alt != 0.) { @@ -298,13 +311,19 @@ static Standard_Boolean KPartCircle T.SetTranslation(Trans); myShape.Move(TopLoc_Location(T)); } - + TopTools_ListOfShape LL; LL.Append(myShape); myMap.Add(E,LL); + + TopoDS_Edge myEdge = TopoDS::Edge(myShape); + myShape = BRepLib_MakeWire(myEdge); + + myIsDone = Standard_True; + return Standard_True; } - myIsDone = Standard_True; - return Standard_True; + + return Standard_False; } //======================================================================= @@ -313,7 +332,8 @@ static Standard_Boolean KPartCircle //======================================================================= BRepFill_OffsetWire::BRepFill_OffsetWire() -:myIsDone(Standard_False) + : myIsOpenResult(Standard_False), + myIsDone(Standard_False) { } @@ -324,9 +344,10 @@ BRepFill_OffsetWire::BRepFill_OffsetWire() //======================================================================= BRepFill_OffsetWire::BRepFill_OffsetWire(const TopoDS_Face& Spine, - const GeomAbs_JoinType Join ) + const GeomAbs_JoinType Join, + const Standard_Boolean IsOpenResult) { - Init(Spine,Join); + Init(Spine,Join,IsOpenResult); } //======================================================================= @@ -335,16 +356,15 @@ BRepFill_OffsetWire::BRepFill_OffsetWire(const TopoDS_Face& Spine, //======================================================================= void BRepFill_OffsetWire::Init(const TopoDS_Face& Spine, - const GeomAbs_JoinType Join ) + const GeomAbs_JoinType Join, + const Standard_Boolean IsOpenResult) { - Standard_NotImplemented_Raise_if(Join > GeomAbs_Arc, - "Only GeomAbs_Arc is implemented"); - myIsDone = Standard_False; TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD); mySpine = TopoDS::Face(aLocalShape); // mySpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD)); myJoinType = Join; + myIsOpenResult = IsOpenResult; CheckFace(mySpine); @@ -379,8 +399,8 @@ void BRepFill_OffsetWire::Init(const TopoDS_Face& Spine, // static BRepMAT2d_Explorer Exp; // Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End Exp.Perform(myWorkSpine); - myBilo.Compute(Exp,1,MAT_Left); - myLink.Perform(Exp,myBilo); + myBilo.Compute(Exp, 1 ,MAT_Left, myJoinType, myIsOpenResult); + myLink.Perform(Exp, myBilo); } @@ -500,7 +520,7 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset, { OCC_CATCH_SIGNALS myCallGen = Standard_False; - if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone)) return; + if (KPartCircle(myWorkSpine,Offset,Alt,myShape,myMap,myIsDone)) return; TopoDS_Face oldWorkSpain = myWorkSpine; @@ -602,14 +622,12 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset, if(aSubst.IsCopied(myWorkSpine)) { myWorkSpine = TopoDS::Face(aSubst.Copy(myWorkSpine).First()); - //sprintf(name,"WS1"); - //DBRep::Set(name,myWorkSpine); BRepMAT2d_Explorer newExp; newExp.Perform(myWorkSpine); BRepMAT2d_BisectingLocus newBilo; BRepMAT2d_LinkTopoBilo newLink; - newBilo.Compute(newExp,1,MAT_Left); + newBilo.Compute(newExp, 1, MAT_Left, myJoinType, myIsOpenResult); if(!newBilo.IsDone()) { @@ -635,24 +653,29 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset, { myShape.Nullify(); myIsDone = Standard_False; +#ifdef BREPFILL_DEB cout<<"An exception was caught in BRepFill_OffsetWire::Perform : "; Standard_Failure::Caught()->Print(cout); cout< GeomAbs_Arc, - "Only GeomAbs_Arc is implemented"); - myIsDone = Standard_False; TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD); myWorkSpine = TopoDS::Face(aLocalShape); @@ -734,7 +754,7 @@ void BRepFill_OffsetWire::PerformWithBiLo //******************************** // Calculate for a non null offset //******************************** - if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone)) + if (KPartCircle(myWorkSpine,Offset,Alt,myShape,myMap,myIsDone)) return; BRep_Builder myBuilder; @@ -770,25 +790,36 @@ void BRepFill_OffsetWire::PerformWithBiLo //--------------------------------------------------------------- // Construction of Circles and OffsetCurves //--------------------------------------------------------------- - + + TopoDS_Vertex Ends [2]; + if (myIsOpenResult) + { + TopoDS_Wire theWire; + TopoDS_Iterator iter(mySpine); + theWire = TopoDS::Wire(iter.Value()); + TopExp::Vertices(theWire, Ends[0], Ends[1]); + } + for (Standard_Integer ic = 1; ic <= Locus.NumberOfContours(); ic++) { TopoDS_Shape PEE = Link.GeneratingShape(Locus.BasicElt(ic,Locus.NumberOfElts(ic))); TopoDS_Shape& PE = PEE ; for (Standard_Integer ie = 1; ie <= Locus.NumberOfElts(ic); ie++) { const TopoDS_Shape& SE = Link.GeneratingShape(Locus.BasicElt(ic,ie)); if (SE.ShapeType() == TopAbs_VERTEX) { - MakeCircle (TopoDS::Edge(PE),TopoDS::Vertex(SE), - myWorkSpine,myOffset,myMap,RefPlane); + if (!SE.IsSame(Ends[0]) && !SE.IsSame(Ends[1])) + MakeCircle (TopoDS::Edge(PE),TopoDS::Vertex(SE), + myWorkSpine,myOffset,myMap,RefPlane); } else { - MakeOffset (TopoDS::Edge(SE),myWorkSpine,myOffset,myMap,RefPlane); + MakeOffset (TopoDS::Edge(SE),myWorkSpine,myOffset,myMap,RefPlane, + myIsOpenResult, Ends); PE = SE; } } } -#ifdef DEB +#ifdef DRAW if (AffichEdge) { cout << " End Construction of geometric primitives "< offset +// in this case vertices corresponding to the extremities of the interval +// are ranked in the proofing. +// => If the same vertex appears in the proofing, the +// border of the zone of proximity is tangent to the offset . +//======================================================================= + +void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfShape& Detromp, + const TopoDS_Shape& Shape1, + const TopoDS_Shape& Shape2, + const TopTools_SequenceOfShape& Vertices, + const TColgp_SequenceOfPnt& Params, + const Bisector_Bisec& Bisec, + const Standard_Boolean SOnE, + const Standard_Boolean EOnE, + const BRepFill_TrimEdgeTool& Trim) const +{ + if (myJoinType == GeomAbs_Intersection && + Vertices.Length() == 1 && + !EOnE) + { + TopTools_IndexedMapOfShape Vmap1, Vmap2; + TopExp::MapShapes(Shape1, TopAbs_VERTEX, Vmap1); + TopExp::MapShapes(Shape2, TopAbs_VERTEX, Vmap2); + Standard_Boolean Adjacent = Standard_False; + for (Standard_Integer i = 1; i <= Vmap1.Extent(); i++) + for (Standard_Integer j = 1; j <= Vmap2.Extent(); j++) + if (Vmap1(i).IsSame(Vmap2(j))) + { + Adjacent = Standard_True; + break; + } + if (Adjacent) + { + Detromp(Shape1).Append(Vertices.First()); + Detromp(Shape2).Append(Vertices.First()); + return; + } + } + + Standard_Integer ii = 1; + Standard_Real U1,U2; + TopoDS_Vertex V1,V2; + + Handle(Geom2d_Curve) Bis = Bisec.Value(); + + U1 = Bis->FirstParameter(); + + if (SOnE) { + // the first point of the bissectrice is on the offset + V1 = TopoDS::Vertex(Vertices.Value(ii)); + ii++; + } + + while (ii <= Vertices.Length()) { + U2 = Params.Value(ii).X(); + V2 = TopoDS::Vertex(Vertices.Value(ii)); + + gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); + if (!Trim.IsInside(P)) { + if (!V1.IsNull()) { + Detromp(Shape1).Append(V1); + Detromp(Shape2).Append(V1); + } + Detromp(Shape1).Append(V2); + Detromp(Shape2).Append(V2); + } + U1 = U2; + V1 = V2; + ii ++; + } + + // test medium point between the last parameter and the end of the bissectrice. + U2 = Bis->LastParameter(); + if (!EOnE) { + if (!Precision::IsInfinite(U2)) { + gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); + if (!Trim.IsInside(P)) { + if (!V1.IsNull()) { + Detromp(Shape1).Append(V1); + Detromp(Shape2).Append(V1); + } + } + } + else { + if (!V1.IsNull()) { + Detromp(Shape1).Append(V1); + Detromp(Shape2).Append(V1); + } + } + } +} + //======================================================================= //function : MakeWires //purpose : @@ -1825,6 +1960,7 @@ void MakeCircle (const TopoDS_Edge& E, #ifdef DRAW if ( AffichGeom && !OE.IsNull()) { + char name[256]; sprintf(name,"OFFSET_%d",++NbOFFSET); DBRep::Set(name,OE); } @@ -1840,7 +1976,9 @@ void MakeOffset (const TopoDS_Edge& E, const TopoDS_Face& F, const Standard_Real Offset, BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map, - const Handle(Geom_Plane)& RefPlane) + const Handle(Geom_Plane)& RefPlane, + const Standard_Boolean IsOpenResult, + const TopoDS_Vertex * Ends) { Standard_Real f,l; Standard_Real anOffset = Offset; @@ -1850,6 +1988,20 @@ void MakeOffset (const TopoDS_Edge& E, Handle(Geom2d_Curve) G2d = BRep_Tool::CurveOnSurface(E,F,f,l); Handle(Geom2d_Curve) G2dOC; + Standard_Boolean ToExtendFirstPar = Standard_True; + Standard_Boolean ToExtendLastPar = Standard_True; + if (IsOpenResult) + { + TopoDS_Vertex V1, V2; + TopExp::Vertices(E, V1, V2); + if (V1.IsSame(Ends[0]) || + V1.IsSame(Ends[1])) + ToExtendFirstPar = Standard_False; + if (V2.IsSame(Ends[0]) || + V2.IsSame(Ends[1])) + ToExtendLastPar = Standard_False; + } + Geom2dAdaptor_Curve AC(G2d,f,l); if ( AC.GetType() == GeomAbs_Circle) { // if the offset is greater otr equal to the radius and the side of the @@ -1861,7 +2013,7 @@ void MakeOffset (const TopoDS_Edge& E, Standard_Real Crossed = Xd.X()*Yd.Y()-Xd.Y()*Yd.X(); Standard_Real Signe = ( Crossed > 0.) ? 1. : -1.; - if (anOffset*Signe < AC.Circle().Radius()) { + if (anOffset*Signe < AC.Circle().Radius() - Precision::Confusion()) { Handle(Geom2dAdaptor_HCurve) AHC = new Geom2dAdaptor_HCurve(G2d); @@ -1869,7 +2021,10 @@ void MakeOffset (const TopoDS_Edge& E, Handle(Geom2d_Circle) CC = new Geom2d_Circle(Off.Circle()); Standard_Real Delta = 2*M_PI - l + f; - f -= 0.2*Delta; l += 0.2*Delta; + if (ToExtendFirstPar) + f -= 0.2*Delta; + if (ToExtendLastPar) + l += 0.2*Delta; G2dOC = new Geom2d_TrimmedCurve(CC,f,l); } @@ -1880,7 +2035,10 @@ void MakeOffset (const TopoDS_Edge& E, Adaptor3d_OffsetCurve Off(AHC,anOffset); Handle(Geom2d_Line) CC = new Geom2d_Line(Off.Line()); Standard_Real Delta = (l - f); - f -= Delta; l += Delta; + if (ToExtendFirstPar) + f -= Delta; + if (ToExtendLastPar) + l += Delta; G2dOC = new Geom2d_TrimmedCurve(CC,f,l); } else { @@ -1901,6 +2059,7 @@ void MakeOffset (const TopoDS_Edge& E, #ifdef DRAW if (AffichGeom && !OE.IsNull()) { + char name[256]; sprintf(name,"OFFSET_%d",++NbOFFSET); DBRep::Set(name,OE); Standard_Real ii = 0; @@ -1910,77 +2069,6 @@ void MakeOffset (const TopoDS_Edge& E, } } -//======================================================================= -//function : UpdateDetromp -//purpose : For each interval on bissectrice defined by parameters -// test if the medium point is at a distance > offset -// in this case vertices corresponding to the extremities of the interval -// are ranked in the proofing. -// => If the same vertex appears in the proofing, the -// border of the zone of proximity is tangent to the offset . -//======================================================================= - -void UpdateDetromp (TopTools_ListOfShape& Detromp1, - TopTools_ListOfShape& Detromp2, - const TopTools_SequenceOfShape& Vertices, - const TColgp_SequenceOfPnt& Params, - const Bisector_Bisec& Bisec, - const Standard_Boolean SOnE, - const Standard_Boolean EOnE, - const BRepFill_TrimEdgeTool& Trim) -{ - Standard_Integer ii = 1; - Standard_Real U1,U2; - TopoDS_Vertex V1,V2; - - Handle(Geom2d_Curve) Bis = Bisec.Value(); - - U1 = Bis->FirstParameter(); - - if (SOnE) { - // the first point of the bissectrice is on the offset - V1 = TopoDS::Vertex(Vertices.Value(ii)); - ii++; - } - - while (ii <= Vertices.Length()) { - U2 = Params.Value(ii).X(); - V2 = TopoDS::Vertex(Vertices.Value(ii)); - - gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); - if (!Trim.IsInside(P)) { - if (!V1.IsNull()) { - Detromp1.Append(V1); - Detromp2.Append(V1); - } - Detromp1.Append(V2); - Detromp2.Append(V2); - } - U1 = U2; - V1 = V2; - ii ++; - } - - // test medium point between the last parameter and the end of the bissectrice. - U2 = Bis->LastParameter(); - if (!EOnE) { - if (!Precision::IsInfinite(U2)) { - gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); - if (!Trim.IsInside(P)) { - if (!V1.IsNull()) { - Detromp1.Append(V1); - Detromp2.Append(V1); - } - } - } - else { - if (!V1.IsNull()) { - Detromp1.Append(V1); - Detromp2.Append(V1); - } - } - } -} //======================================================================= //function : VertexFromNode @@ -2050,10 +2138,11 @@ void StoreInMap (const TopoDS_Shape& V1, void TrimEdge (const TopoDS_Edge& E, const TopTools_ListOfShape& Detromp, - TopTools_SequenceOfShape& TheVer, - TColStd_SequenceOfReal& ThePar, - TopTools_SequenceOfShape& S, - TopTools_IndexedDataMapOfShapeShape& MapVV) + TopTools_SequenceOfShape& TheVer, + TColStd_SequenceOfReal& ThePar, + TopTools_SequenceOfShape& S, + TopTools_IndexedDataMapOfShapeShape& MapVV, + const Standard_Integer IndOfE) { Standard_Boolean Change = Standard_True; BRep_Builder TheBuilder; @@ -2124,44 +2213,93 @@ void TrimEdge (const TopoDS_Edge& E, // the number of vertices should be even. The created edges // go from a vertex with uneven index i to vertex i+1; //----------------------------------------------------------- - for (Standard_Integer k = 1; k < TheVer.Length(); k = k+2) { + if (IndOfE == 1 || IndOfE == -1) //open result and extreme edges of result + { TopoDS_Shape aLocalShape = E.EmptyCopied(); TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape); -// TopoDS_Edge NewEdge = TopoDS::Edge(E.EmptyCopied()); - - if (NewEdge.Orientation() == TopAbs_REVERSED) { - TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_REVERSED)); - TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_FORWARD)); + TopoDS_Vertex V1, V2; + TopExp::Vertices(E, V1, V2); + Standard_Real fpar, lpar; + BRep_Tool::Range(E, fpar, lpar); + if (IndOfE == 1) //first edge of open wire + { + if (NewEdge.Orientation() == TopAbs_FORWARD) + { + TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_FORWARD)); + TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED)); + TheBuilder.Range(NewEdge, fpar, ThePar.First()); + } + else + { + //TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_REVERSED)); + //TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD)); + TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED)); + TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_FORWARD)); + TheBuilder.Range(NewEdge, ThePar.First(), lpar); + } } - else { - TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_FORWARD)); - TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_REVERSED)); + else //last edge of open wire + { + if (NewEdge.Orientation() == TopAbs_FORWARD) + { + TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD)); + TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_REVERSED)); + TheBuilder.Range(NewEdge, ThePar.First(), lpar); + } + else + { + //TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED)); + //TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_FORWARD)); + TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_REVERSED)); + TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD)); + TheBuilder.Range(NewEdge, fpar, ThePar.First()); + } } - - - TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1)); - + S.Append(NewEdge); + } + else + { + for (Standard_Integer k = 1; k < TheVer.Length(); k = k+2) { + TopoDS_Shape aLocalShape = E.EmptyCopied(); + TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape); + // TopoDS_Edge NewEdge = TopoDS::Edge(E.EmptyCopied()); + + if (NewEdge.Orientation() == TopAbs_REVERSED) { + TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_REVERSED)); + TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_FORWARD)); + } + else { + TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_FORWARD)); + TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_REVERSED)); + } + + + TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1)); + #ifdef DRAW - if ( AffichEdge) { - sprintf(name,"TRIMEDGE_%d",NbTRIMEDGES); - DBRep::Set(name,NewEdge); - } - if (Affich2d) { - TopLoc_Location L; - Standard_Real f,l; - Handle(Geom_Surface) Surf; - Handle(Geom2d_Curve) C; - BRep_Tool::CurveOnSurface(NewEdge,C,Surf,L,f,l); - sprintf(name,"OFFSET2d_%d",NbTRIMEDGES++); - Handle(Geom2d_TrimmedCurve) C2d = new Geom2d_TrimmedCurve(C,f,l); - Handle(DrawTrSurf_Curve2d) dr = - new DrawTrSurf_Curve2d(C2d,Standard_False); - dr->SetColor(Draw_bleu); - Draw::Set(name,dr); - } + if ( AffichEdge) { + char name[256]; + sprintf(name,"TRIMEDGE_%d",NbTRIMEDGES); + DBRep::Set(name,NewEdge); + } + if (Affich2d) { + TopLoc_Location L; + Standard_Real f,l; + Handle(Geom_Surface) Surf; + Handle(Geom2d_Curve) C; + BRep_Tool::CurveOnSurface(NewEdge,C,Surf,L,f,l); + char name[256]; + sprintf(name,"OFFSET2d_%d",NbTRIMEDGES++); + Handle(Geom2d_TrimmedCurve) C2d = new Geom2d_TrimmedCurve(C,f,l); + Handle(DrawTrSurf_Curve2d) dr = + new DrawTrSurf_Curve2d(C2d,Standard_False); + dr->SetColor(Draw_bleu); + Draw::Set(name,dr); + } #endif - - S.Append(NewEdge); + + S.Append(NewEdge); + } } } diff --git a/src/BRepFill/BRepFill_PipeShell.cxx b/src/BRepFill/BRepFill_PipeShell.cxx index 3b48a9c153..b66e786f32 100644 --- a/src/BRepFill/BRepFill_PipeShell.cxx +++ b/src/BRepFill/BRepFill_PipeShell.cxx @@ -686,7 +686,8 @@ void BRepFill_PipeShell::SetForceApproxC1(const Standard_Boolean ForceApproxC1) // 1) Preparation Prepare(); - if (myStatus != GeomFill_PipeOk) { + if (myStatus != GeomFill_PipeOk || + !mySection->NbLaw()) { BRep_Builder B; TopoDS_Shell Sh; B.MakeShell(Sh); diff --git a/src/BRepFill/BRepFill_SectionLaw.cxx b/src/BRepFill/BRepFill_SectionLaw.cxx index 62c1684008..27db483714 100644 --- a/src/BRepFill/BRepFill_SectionLaw.cxx +++ b/src/BRepFill/BRepFill_SectionLaw.cxx @@ -44,6 +44,8 @@ //======================================================================= Standard_Integer BRepFill_SectionLaw::NbLaw() const { + if (myLaws.IsNull()) + return 0; return myLaws->Length(); } diff --git a/src/BRepFill/BRepFill_Sweep.cxx b/src/BRepFill/BRepFill_Sweep.cxx index 93c3d3d01c..85077803a4 100644 --- a/src/BRepFill/BRepFill_Sweep.cxx +++ b/src/BRepFill/BRepFill_Sweep.cxx @@ -1437,13 +1437,17 @@ static TopoDS_Edge BuildEdge(const Handle(Geom_Surface)& S, // Associate 2d Handle(Geom2d_Line) L; TopLoc_Location Loc; + Standard_Real Umin, Umax, Vmin, Vmax; + S->Bounds(Umin, Umax, Vmin, Vmax); if (isUiso) { - gp_Pnt2d P(ValIso, 0); + //gp_Pnt2d P(ValIso, 0); + gp_Pnt2d P( ValIso, Vmin - Iso->FirstParameter() ); gp_Vec2d V(0., 1.); L = new (Geom2d_Line) (P, V); } else { - gp_Pnt2d P(0., ValIso); + //gp_Pnt2d P(0., ValIso); + gp_Pnt2d P( Umin -Iso->FirstParameter() , ValIso ); gp_Vec2d V(1., 0.); L = new (Geom2d_Line) (P, V); } diff --git a/src/BRepMAT2d/BRepMAT2d.cdl b/src/BRepMAT2d/BRepMAT2d.cdl index 53e478f6ec..5674253632 100644 --- a/src/BRepMAT2d/BRepMAT2d.cdl +++ b/src/BRepMAT2d/BRepMAT2d.cdl @@ -5,8 +5,8 @@ -- -- This file is part of Open CASCADE Technology software library. -- --- This library is free software; you can redistribute it and / or modify it --- under the terms of the GNU Lesser General Public version 2.1 as published +-- This library is free software; you can redistribute it and/or modify it under +-- the terms of the GNU Lesser General Public License version 2.1 as published -- by the Free Software Foundation, with special exception defined in the file -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -- distribution for complete text of the license and disclaimer of any warranty. @@ -19,6 +19,7 @@ package BRepMAT2d ---Purpose: uses + GeomAbs, MAT2d, MAT, TCollection, @@ -27,29 +28,20 @@ uses Geom2d, gp, TopoDS, - TopTools + TopTools, + Bisector is class Explorer; - ---Purpose: Construct an explorer for the computation of the - -- bisecting locus from a Wire, a Face, or a set of - -- curves from Geom2d. - class BisectingLocus instantiates BisectingLocus from MAT2d - (Explorer from BRepMAT2d); - ---Purpose: the map of bisecting locus. - + class BisectingLocus; + class LinkTopoBilo; - ---Purpose: Constucts links between the Wire or the Face and - -- the BasicElts contained in the bisecting locus. - class SequenceOfBasicElt instantiates Sequence from TCollection - (BasicElt from MAT); - class DataMapOfShapeSequenceOfBasicElt instantiates DataMap from TCollection (Shape from TopoDS, - SequenceOfBasicElt from BRepMAT2d, + SequenceOfBasicElt from MAT, ShapeMapHasher from TopTools); class DataMapOfBasicEltShape instantiates diff --git a/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl b/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl new file mode 100644 index 0000000000..9d258ba1d7 --- /dev/null +++ b/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl @@ -0,0 +1,166 @@ +-- Created on: 1993-07-06 +-- Created by: Yves FRICAUD +-- Copyright (c) 1993-1999 Matra Datavision +-- Copyright (c) 1999-2014 OPEN CASCADE SAS +-- +-- This file is part of Open CASCADE Technology software library. +-- +-- This library is free software; you can redistribute it and/or modify it under +-- the terms of the GNU Lesser General Public License version 2.1 as published +-- by the Free Software Foundation, with special exception defined in the file +-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +-- distribution for complete text of the license and disclaimer of any warranty. +-- +-- Alternatively, this file may be used under the terms of Open CASCADE +-- commercial license or contractual agreement. + +class BisectingLocus from BRepMAT2d + + ---Purpose : BisectingLocus generates and contains the Bisecting_Locus + -- of a set of lines from Geom2d, defined by . + -- + -- If the set of lines contains closed lines: + -- ------------------------------------------ + -- These lines cut the plane in areas. + -- One map can be computed for each area. + -- + -- Bisecting locus computes a map in an area. + -- The area is defined by a side (MAT_Left,MAT_Right) + -- on one of the closed lines. + -- + -- If the set of lines contains only open lines: + -- -------------------------------------------- + -- the map recovers all the plane. + -- + -- Warning: Assume the orientation of the closed lines are + -- compatible. + -- + -- Assume the explo contains only lines located in the + -- area where the bisecting locus will be computed. + -- + -- Assume a line don't cross itself or an other line. + -- + -- Remark: + -- the curves coming from the explorer can be + -- decomposed in different parts. It the case for the + -- curves other than circles or lines. + -- + -- The map of bisecting locus is described by a graph. + -- - The BasicsElements correspond to elements on + -- the figure described by the Explorer from BRepMAT2d. + -- - The Arcs correspond to the bisectors. + -- - The Nodes are the extremities of the arcs. + +uses + JoinType from GeomAbs, + Graph from MAT, + Arc from MAT, + BasicElt from MAT, + Node from MAT, + Side from MAT, + DataMapOfIntegerBasicElt from MAT, + DataMapOfBiIntInteger from MAT2d, + Bisec from Bisector, + Geometry from Geom2d, + Pnt2d from gp, + Tool2d from MAT2d, + Explorer from BRepMAT2d + +is + Create returns BisectingLocus from BRepMAT2d; + +---Category: Construction. + + Compute (me : in out ; + anExplo : in out Explorer from BRepMAT2d; + LineIndex : Integer = 1; + aSide : Side from MAT = MAT_Left; + aJoinType : JoinType from GeomAbs = GeomAbs_Arc; + IsOpenResult : Boolean = Standard_False) + --- Purpose : Computation of the Bisector_Locus in a set of Lines + -- defined in . + -- The bisecting locus are computed on the side