From 0d4f55c2aee1b21942224c76f0ec418196e6f1dc Mon Sep 17 00:00:00 2001 From: nbv Date: Wed, 21 Feb 2018 17:31:37 +0300 Subject: [PATCH] 0029115: [Regression] GeomAdaptor mistakenly reports non-periodic curves to be periodic 1. Adaptors' and trimmed curves' periodicity is always got from the basis geometry (independently of trim boundaries). 2. Section "Periodicity concept" has been added in Doxigen-documentation. 3. The methods IsPeriodic(), IsU(V)Periodic() of classes Geom(2d)_TrimmedCurve(RectangularTrimmedSurface) have changed their behavior. Periodicity of basis curve is taken into account only (trim boundaries are ignored). 4. Currently, the methods Period(), U(V)Period() are overridden in classes inherited from Geom(2d)_Curve(Surface) and Adaptor(2d)_Curve(Surface), which IsPeriodic (IsU(V)Periodic()) can return TRUE in. In basis classes, such methods throw exceptions. 5. Method GeomLib::IsClosed(...) has been added in order to check of closure of 3D/2D curve with some tolerance. At the same time, IntTools_Tools::IsClosed(...) method has been removed. 6. Methods GeomLib::IsTrimAllowed(...), GeomLib::IsUTrimAllowed(...) and GeomLib::IsVTrimAllowed(...) have been created. 7. Method ShapeAnalysis_Curve::IsPeriodic(...) has been removed. 8. Method void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& theF, const Handle(Geom_Curve)& theC3D, const Handle(Geom2d_Curve)& theC2D, Handle(Geom2d_Curve)& theC2DA, const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); has been removed. 9. Interface of Geom_ConicalSurface::Apex(...) method has been corrected insignificantly. 10. The DRAW-commands "curveperiod" and "surfaceperiod" have been created. Please see help-system to obtain the information about these commands. 11. Several DRAW-commands have been created to provide work with adapters. They are defined in the file GeomliteTest_AdaptorCommands.cxx. Currently they allow reading the following adapter's properties: periodicity, closure and resolution. 12. New test cases have been created. --- .../draw_test_harness/draw_test_harness.md | 255 +++++++++ .../modeling_data/modeling_data.md | 137 +++++ src/Adaptor2d/Adaptor2d_Curve2d.hxx | 2 + src/Adaptor2d/Adaptor2d_HCurve2d.hxx | 6 +- src/Adaptor2d/Adaptor2d_Line2d.cxx | 10 - src/Adaptor2d/Adaptor2d_Line2d.hxx | 3 +- src/Adaptor2d/Adaptor2d_OffsetCurve.hxx | 2 + src/Adaptor3d/Adaptor3d_Curve.cxx | 1 - src/Adaptor3d/Adaptor3d_Curve.hxx | 2 + src/Adaptor3d/Adaptor3d_CurveOnSurface.hxx | 2 + src/Adaptor3d/Adaptor3d_HCurve.hxx | 2 + src/Adaptor3d/Adaptor3d_HSurface.hxx | 4 + src/Adaptor3d/Adaptor3d_HSurfaceTool.hxx | 14 +- src/Adaptor3d/Adaptor3d_IsoCurve.hxx | 3 + src/Adaptor3d/Adaptor3d_Surface.cxx | 1 - src/Adaptor3d/Adaptor3d_Surface.hxx | 8 +- src/BOPTools/BOPTools_AlgoTools.cxx | 16 +- src/BOPTools/BOPTools_AlgoTools2D.cxx | 16 - src/BOPTools/BOPTools_AlgoTools2D.hxx | 8 - src/BOPTools/BOPTools_AlgoTools3D.cxx | 64 +-- src/BRepAdaptor/BRepAdaptor_CompCurve.cxx | 5 - src/BRepAdaptor/BRepAdaptor_CompCurve.hxx | 3 +- src/BRepAdaptor/BRepAdaptor_Curve.hxx | 2 + src/BRepAdaptor/BRepAdaptor_Surface.hxx | 4 + src/BRepAlgo/BRepAlgo.cxx | 15 +- src/BRepApprox/BRepApprox_SurfaceTool.hxx | 14 +- src/BRepBlend/BRepBlend_HCurve2dTool.hxx | 6 +- src/BRepBlend/BRepBlend_HCurveTool.hxx | 6 +- src/BRepBndLib/BRepBndLib.cxx | 32 +- src/BRepCheck/BRepCheck_Edge.cxx | 6 + src/BRepClass/BRepClass_Intersector.cxx | 7 - src/BRepFeat/BRepFeat_Form.cxx | 1 + src/BRepFill/BRepFill_MultiLine.cxx | 25 +- src/BRepFill/BRepFill_OffsetWire.cxx | 11 +- src/BRepLib/BRepLib.cxx | 31 +- src/BRepLib/BRepLib_MakeEdge.cxx | 20 +- src/BRepLib/BRepLib_MakeShell.cxx | 11 +- src/BRepMesh/BRepMesh_CurveTessellator.cxx | 2 + .../BRepMesh_DefaultRangeSplitter.cxx | 6 +- src/BRepOffset/BRepOffset_Inter2d.cxx | 3 + src/BRepOffset/BRepOffset_Tool.cxx | 531 +++++++++--------- src/BRepTest/BRepTest_SurfaceCommands.cxx | 2 + src/BRepTools/BRepTools.cxx | 25 +- .../BRepTools_NurbsConvertModification.cxx | 7 +- src/BRepTools/BRepTools_TrsfModification.cxx | 25 +- src/BiTgte/BiTgte_CurveOnEdge.cxx | 23 - src/BiTgte/BiTgte_CurveOnEdge.hxx | 4 - src/BiTgte/BiTgte_CurveOnVertex.cxx | 23 - src/BiTgte/BiTgte_CurveOnVertex.hxx | 4 - src/BinTools/BinTools_Curve2dSet.cxx | 4 +- src/BinTools/BinTools_CurveSet.cxx | 4 +- src/BinTools/BinTools_SurfaceSet.cxx | 8 +- src/Bisector/Bisector_BisecAna.cxx | 11 +- src/Bisector/Bisector_BisecAna.hxx | 4 + src/Bisector/Bisector_BisecCC.hxx | 1 + src/Bisector/Bisector_BisecPC.hxx | 1 + src/ChFi2d/ChFi2d_FilletAlgo.cxx | 19 +- src/ChFi3d/ChFi3d_Builder_0.cxx | 72 ++- src/ChFi3d/ChFi3d_Builder_C1.cxx | 11 +- src/ChFiDS/ChFiDS_ElSpine.cxx | 13 + src/ChFiDS/ChFiDS_ElSpine.hxx | 5 + src/Contap/Contap_HCurve2dTool.hxx | 6 +- src/DBRep/DBRep_DrawableShape.cxx | 8 +- src/Draft/Draft_Modification.cxx | 5 - src/Draft/Draft_Modification_1.cxx | 5 +- src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx | 2 +- src/Extrema/Extrema_CurveTool.cxx | 7 +- src/Extrema/Extrema_CurveTool.hxx | 8 +- src/Extrema/Extrema_ExtPExtS.cxx | 3 +- src/Geom/Geom_BSplineCurve.cxx | 44 +- src/Geom/Geom_BSplineCurve.hxx | 2 + src/Geom/Geom_BSplineSurface.cxx | 29 + src/Geom/Geom_BSplineSurface.hxx | 5 + src/Geom/Geom_BezierCurve.hxx | 3 +- src/Geom/Geom_Circle.hxx | 10 +- src/Geom/Geom_ConicalSurface.cxx | 6 +- src/Geom/Geom_ConicalSurface.hxx | 10 +- src/Geom/Geom_Curve.cxx | 7 +- src/Geom/Geom_Curve.hxx | 21 +- src/Geom/Geom_CylindricalSurface.hxx | 5 + src/Geom/Geom_Ellipse.hxx | 8 +- src/Geom/Geom_Hyperbola.hxx | 2 +- src/Geom/Geom_Line.hxx | 2 +- src/Geom/Geom_OffsetCurve.cxx | 6 + src/Geom/Geom_OffsetCurve.hxx | 6 +- src/Geom/Geom_OffsetSurface.cxx | 14 + src/Geom/Geom_OffsetSurface.hxx | 6 +- src/Geom/Geom_RectangularTrimmedSurface.cxx | 44 +- src/Geom/Geom_RectangularTrimmedSurface.hxx | 13 +- src/Geom/Geom_SphericalSurface.hxx | 6 + src/Geom/Geom_Surface.cxx | 16 +- src/Geom/Geom_Surface.hxx | 25 +- src/Geom/Geom_SurfaceOfLinearExtrusion.cxx | 9 + src/Geom/Geom_SurfaceOfLinearExtrusion.hxx | 5 +- src/Geom/Geom_SurfaceOfRevolution.cxx | 18 +- src/Geom/Geom_SurfaceOfRevolution.hxx | 11 +- src/Geom/Geom_ToroidalSurface.hxx | 12 + src/Geom/Geom_TrimmedCurve.cxx | 7 +- src/Geom/Geom_TrimmedCurve.hxx | 4 +- src/Geom2d/Geom2d_BSplineCurve.cxx | 44 +- src/Geom2d/Geom2d_BSplineCurve.hxx | 3 + src/Geom2d/Geom2d_BezierCurve.hxx | 3 +- src/Geom2d/Geom2d_Circle.hxx | 10 +- src/Geom2d/Geom2d_Curve.cxx | 7 +- src/Geom2d/Geom2d_Curve.hxx | 19 +- src/Geom2d/Geom2d_Ellipse.hxx | 8 +- src/Geom2d/Geom2d_OffsetCurve.cxx | 6 + src/Geom2d/Geom2d_OffsetCurve.hxx | 8 +- src/Geom2d/Geom2d_TrimmedCurve.cxx | 15 +- src/Geom2d/Geom2d_TrimmedCurve.hxx | 4 +- src/Geom2dAdaptor/Geom2dAdaptor_Curve.hxx | 14 +- src/Geom2dConvert/Geom2dConvert.cxx | 4 +- src/GeomAdaptor/GeomAdaptor_Curve.hxx | 2 + src/GeomAdaptor/GeomAdaptor_Surface.hxx | 4 + .../GeomAdaptor_SurfaceOfLinearExtrusion.cxx | 10 - .../GeomAdaptor_SurfaceOfLinearExtrusion.hxx | 6 +- .../GeomAdaptor_SurfaceOfRevolution.cxx | 4 +- .../GeomAdaptor_SurfaceOfRevolution.hxx | 5 + src/GeomConvert/GeomConvert.cxx | 4 +- src/GeomFill/GeomFill_GuideTrihedronPlan.cxx | 2 +- src/GeomFill/GeomFill_LocationGuide.cxx | 2 +- src/GeomFill/GeomFill_NSections.cxx | 11 +- src/GeomFill/GeomFill_SnglrFunc.cxx | 4 + src/GeomFill/GeomFill_SnglrFunc.hxx | 5 + src/GeomLib/GeomLib.cxx | 151 ++++- src/GeomLib/GeomLib.hxx | 68 ++- src/GeomPlate/GeomPlate_Surface.cxx | 24 - src/GeomPlate/GeomPlate_Surface.hxx | 29 +- src/GeomProjLib/GeomProjLib.cxx | 12 +- .../GeometryTest_CurveCommands.cxx | 56 ++ .../GeometryTest_SurfaceCommands.cxx | 45 ++ src/GeomliteTest/FILES | 1 + src/GeomliteTest/GeomliteTest.cxx | 1 + src/GeomliteTest/GeomliteTest.hxx | 2 + .../GeomliteTest_AdaptorCommands.cxx | 472 ++++++++++++++++ src/HLRBRep/HLRBRep_BCurveTool.hxx | 12 +- src/HLRBRep/HLRBRep_BSurfaceTool.hxx | 14 +- src/HLRBRep/HLRBRep_Curve.hxx | 6 + src/HLRBRep/HLRBRep_CurveTool.hxx | 6 +- src/HLRBRep/HLRBRep_LineTool.hxx | 6 +- src/HLRBRep/HLRBRep_Surface.hxx | 27 +- src/HLRBRep/HLRBRep_SurfaceTool.hxx | 12 +- src/IntCurveSurface/IntCurveSurface_Inter.gxx | 19 +- .../IntCurveSurface_TheHCurveTool.hxx | 6 +- src/IntPatch/IntPatch_HCurve2dTool.hxx | 6 +- src/IntPatch/IntPatch_Intersection.cxx | 8 +- src/IntPatch/IntPatch_PrmPrmIntersection.cxx | 38 +- src/IntPatch/IntPatch_RstInt.cxx | 87 +-- src/IntPatch/IntPatch_SpecialPoints.cxx | 23 +- src/IntPatch/IntPatch_WLineTool.cxx | 7 +- src/IntTools/IntTools_FaceFace.cxx | 48 +- src/IntTools/IntTools_Tools.cxx | 37 +- src/IntTools/IntTools_Tools.hxx | 8 - src/IntWalk/IntWalk_PWalking.cxx | 20 +- src/LocOpe/LocOpe_WiresOnShape.cxx | 14 +- src/MAT2d/MAT2d_Tool2d.cxx | 16 +- src/ProjLib/ProjLib_ComputeApprox.cxx | 58 +- .../ProjLib_ComputeApproxOnPolarSurface.cxx | 86 +-- src/ProjLib/ProjLib_ProjectOnPlane.hxx | 2 + src/ProjLib/ProjLib_ProjectedCurve.hxx | 2 + src/QABugs/QABugs_20.cxx | 80 +++ src/ShapeAnalysis/ShapeAnalysis_Curve.cxx | 40 +- src/ShapeAnalysis/ShapeAnalysis_Curve.hxx | 12 - src/ShapeBuild/ShapeBuild_Edge.cxx | 38 +- src/ShapeConstruct/ShapeConstruct.cxx | 20 +- .../ShapeConstruct_ProjectCurveOnSurface.cxx | 21 +- .../ShapeCustom_BSplineRestriction.cxx | 4 +- src/ShapeFix/ShapeFix_Edge.cxx | 2 +- src/ShapeFix/ShapeFix_EdgeProjAux.cxx | 8 +- src/ShapeFix/ShapeFix_Wire.cxx | 8 +- src/ShapeFix/ShapeFix_Wire_1.cxx | 8 +- .../ShapeUpgrade_SplitCurve2d.cxx | 2 +- .../ShapeUpgrade_SplitCurve3d.cxx | 4 +- .../StepToTopoDS_GeometricTool.cxx | 40 +- .../StepToTopoDS_TranslateEdgeLoop.cxx | 2 +- src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx | 6 +- .../TopOpeBRepTool_CurveTool.cxx | 4 +- .../TopOpeBRepTool_ShapeTool.cxx | 4 +- src/math/math_NewtonMinimum.cxx | 8 +- tests/adaptors/begin | 43 ++ tests/adaptors/end | 2 + tests/adaptors/grids.list | 2 + tests/adaptors/parse.rules | 1 + tests/adaptors/properties/A01 | 26 + tests/adaptors/properties/B01 | 26 + tests/adaptors/properties/C01 | 28 + tests/adaptors/properties/D01 | 29 + tests/adaptors/properties/E01 | 28 + tests/adaptors/properties/F01 | 37 ++ tests/adaptors/properties/F02 | 37 ++ tests/adaptors/properties/F03 | 39 ++ tests/adaptors/resolution/A1 | 10 + tests/adaptors/resolution/A2 | 10 + tests/adaptors/resolution/A3 | 11 + tests/bugs/modalg_7/bug29115_1 | 44 ++ tests/bugs/modalg_7/bug29115_2 | 44 ++ tests/bugs/modalg_7/bug29115_3 | 24 + tests/bugs/modalg_7/bug29115_4 | 19 + tests/bugs/modalg_7/bug29115_5 | 47 ++ tests/geometry/geomperiodic/A1 | 17 + tests/geometry/geomperiodic/A2 | 41 ++ tests/geometry/geomperiodic/B1 | 80 +++ tests/geometry/geomperiodic/B2 | 32 ++ tests/geometry/geomperiodic/B3 | 91 +++ tests/geometry/geomperiodic/B4 | 94 ++++ tests/geometry/geomperiodic/B5 | 29 + tests/geometry/grids.list | 3 +- 207 files changed, 3397 insertions(+), 1404 deletions(-) create mode 100644 src/GeomliteTest/GeomliteTest_AdaptorCommands.cxx create mode 100644 tests/adaptors/begin create mode 100644 tests/adaptors/end create mode 100644 tests/adaptors/grids.list create mode 100644 tests/adaptors/parse.rules create mode 100644 tests/adaptors/properties/A01 create mode 100644 tests/adaptors/properties/B01 create mode 100644 tests/adaptors/properties/C01 create mode 100644 tests/adaptors/properties/D01 create mode 100644 tests/adaptors/properties/E01 create mode 100644 tests/adaptors/properties/F01 create mode 100644 tests/adaptors/properties/F02 create mode 100644 tests/adaptors/properties/F03 create mode 100644 tests/adaptors/resolution/A1 create mode 100644 tests/adaptors/resolution/A2 create mode 100644 tests/adaptors/resolution/A3 create mode 100644 tests/bugs/modalg_7/bug29115_1 create mode 100644 tests/bugs/modalg_7/bug29115_2 create mode 100644 tests/bugs/modalg_7/bug29115_3 create mode 100644 tests/bugs/modalg_7/bug29115_4 create mode 100644 tests/bugs/modalg_7/bug29115_5 create mode 100644 tests/geometry/geomperiodic/A1 create mode 100644 tests/geometry/geomperiodic/A2 create mode 100644 tests/geometry/geomperiodic/B1 create mode 100644 tests/geometry/geomperiodic/B2 create mode 100644 tests/geometry/geomperiodic/B3 create mode 100644 tests/geometry/geomperiodic/B4 create mode 100644 tests/geometry/geomperiodic/B5 diff --git a/dox/user_guides/draw_test_harness/draw_test_harness.md b/dox/user_guides/draw_test_harness/draw_test_harness.md index 78447f534c..a1baa42897 100644 --- a/dox/user_guides/draw_test_harness/draw_test_harness.md +++ b/dox/user_guides/draw_test_harness/draw_test_harness.md @@ -4380,6 +4380,7 @@ The following topics are covered in the nine sections of this chapter: * **Curve and surface modification** deals with the commands used to modify the definition of curves and surfaces, most of which concern modifications to bezier and bspline curves. * **Geometric transformations** covers translation, rotation, mirror image and point scaling transformations. * **Curve and Surface Analysis** deals with the commands used to compute points, derivatives and curvatures. + * **Adaptor commands** deals with the commands providing work with (curve and surface) adaptors. * **Intersections** presents intersections of surfaces and curves. * **Approximations** deals with creating curves and surfaces from a set of points. * **Constraints** concerns construction of 2d circles and lines by constraints such as tangency. @@ -5385,6 +5386,8 @@ pscale s 0 0 0 2 * **parameters** to compute (u,v) values for a point on a surface. * **proj** and **2dproj** to project a point on a curve or a surface. * **surface_radius** to compute the curvature on a surface. + * **curveperiod** to check whether the curve is periodic and to compute its period. + * **surfaceperiod** to check whether the surface is periodic in U- and V-directions and to compute its period in correspond direction. @subsubsection occt_draw_6_6_1 coord @@ -5524,6 +5527,258 @@ surface_radius c pi 3 c1 c2 == Min Radius of Curvature : infinite ~~~~~ +@subsubsection occt_draw_6_6_8 curveperiod + +Syntax: +~~~~~ +curveperiod curve +~~~~~ + +where "curve" is a 2D- or 3D-curve. + +Checks if the curve is periodic and returns (in this case) its period. + +**Example 1** + +~~~~~ +# Create some 3D-curve +ellipse c1 0 0 0 0 1 1 100 40 + +# Check its periodicity +curveperiod c1 +# c1 is periodic with the period 6.2831853071795862 +~~~~~ + +**Example 2** + +~~~~~ +# Create 2D B-spline curve +2dbsplinecurve c1 2 6 -2.0943951023932 1 0 2 2.0943951023932 2 4.18879020478639 2 6.28318530717959 2 8.37758040957278 1 100 0 1 100 173 0.5 -50 87 1 -200 0 0.5 -50 -87 1 100 -173 0.5 100 0 1 + +# Check its periodicity +curveperiod c1 +# c1 is not periodic + +# Make it periodic +setperiodic c1 + +# Check its periodicity +curveperiod c1 +#c1 is periodic with the period 6.2831853071795898 +~~~~~ + +@subsubsection occt_draw_6_6_9 surfaceperiod + +Syntax: +~~~~~ +surfaceperiod surface +~~~~~ + +Checks if the surface is periodic (in U- and V-direction) and returns (if that is true) its period. + +**Example 1** + +~~~~~ +# Create some surface +sphere ss 100 +trim st ss 0 pi -1 1 + +# Check its periodicity +surfaceperiod st +# st is U-periodic with U-period 6.2831853071795862 +# st is not V-periodic +~~~~~ + +**Example 2** + +~~~~~ +# Create some surface +torus s1 100 20 + +# Check its periodicity +surfaceperiod s1 +# s1 is U-periodic with U-period 6.2831853071795862 +# s1 is V-periodic with V-period 6.2831853071795862 +~~~~~ + +@subsection occt_draw_6_6a Adaptor commands + +This group of Draw-commands allows obtaining (in Draw) some properties of curves/surfaces, which can be read via adapters in C++ code only (e.g. curve's or surface's resolution). + +Here is the list of these commands: + +* **nulifyadaptors** clears all earlier created adaptors; +* **makeadaptor** creates new adaptor. +* **adaptorproperties** returns the property of all existing adaptors. + +@subsubsection occt_draw_6_6a_1 nulifyadaptors + +Syntax: +~~~~~ +nulifyadaptors +~~~~~ + +Clears all earlier created adaptors. + +See example @ref occt_draw_6_6a_3 "below". + +@subsubsection occt_draw_6_6a_2 makeadaptor + +Syntax: +~~~~~ +makeadaptor argument +~~~~~ + +where argument can be + +- 3D/2D-curve; +- Surface; +- Edge; +- Face; +- Compound, containing edge and face. Moreover, the edge must have 2D-curve on the face. + +Creates new adaptor. If adaptor with such type already exists the new adaptor will replace the existing one. + +See example @ref occt_draw_6_6a_3 "below". + +@subsubsection occt_draw_6_6a_3 adaptorproperties + +Syntax: +~~~~~ +adaptorproperties +~~~~~ + +Returns the properties of all created adaptors. Currently the following properties are supported: + +- -isperiodic - Returns **IsPeriodic()** property and the period. +- -isclosed - Returns **IsClosed()** property. +- -resolution - Returns a value of resolution (see Examples 3 and 6). + +**Example 1** + +~~~~~ +# Create some 2D-curve +circle c 0 0 20 + +# Nulify all already created adaptors +nulifyadaptors +# All adapters have been nullified successful. + +# Create new adaptor +makeadaptor c +# OK: Adaptor2d_Curve2d has been created. + +# Check it +adaptorproperties -isclosed +# Adaptor2d_Curve2d is closed +~~~~~ + +**Example 2** + +~~~~~ +# Create some 3D-curve +bsplinecurve cc 4 3 0 5 3.1415926535897931 3 6.2831853071795862 5 0 20 100 1 -14.1421356237309 20 106.594586144012 1 -34.9044110322929 0 116.276194167748 1 -14.1421356237311 -20 106.594586144013 1 14.142135623731 -20 93.4054138559873 1 34.904411032293 0 83.7238058322526 1 14.1421356237309 20 93.4054138559873 1 0 20 100 1 + +# Nulify all already created adaptors +nulifyadaptors +# All adapters have been nullified successful. + +# Create new adaptor +makeadaptor cc +# OK: Adaptor3d_Curve has been created. + +# Check it +adaptorproperties -isperiodic -isclosed +# Adaptor3d_Curve is not periodic +# Adaptor3d_Curve is closed +~~~~~ + +**Example 3** + +~~~~~ +# Create some surface +sphere ss 68 + +# Nulify all already created adaptors +nulifyadaptors +# All adapters have been nullified successful. + +# Create new adaptor +makeadaptor bs +# OK: Adaptor3d_Surface has been created. + +# Get sphere's resolution from 1.0e-7 +adaptorproperties -resolution 1.0e-7 +# Adaptor3d_Surface: UResolution = 1.4705882352941176e-009; VResolution = 1.4705882352941176e-009 +~~~~~ + +**Example 4** + +~~~~~ +# Obtain some edge +box b 1 1 1 +explode b e + +# Nulify all already created adaptors +nulifyadaptors +# All adapters have been nullified successful. + +# Create new adaptor +makeadaptor b_1 +# OK: Adaptor3d_Curve has been created. + +# Check it +adaptorproperties -isperiodic +# Adaptor3d_Curve is not periodic + +adaptorproperties -isclosed +# Adaptor3d_Curve is not closed +~~~~~ + +**Example 5** + +~~~~~ +# Obtain some face +pcylinder f 20 200 +explode f f + +# Nulify all already created adaptors +nulifyadaptors +# All adapters have been nullified successful. + +# Create new adaptor +makeadaptor f_1 +# OK: Adaptor3d_Curve has been created. + +# Check it +adaptorproperties -isperiodic -isclosed +# Adaptor3d_Surface is U-periodic with U-period 6.2831853071795862 +# Adaptor3d_Surface is not V-periodic +# Adaptor3d_Surface is U-closed +# Adaptor3d_Surface is not V-closed +~~~~~ + +**Example 6** + +~~~~~ +# Obtain compound edge+face +pcone co 0 10 10 +explode co f +explode co_1 e +compound co_1_2 co_1 cm + +# Nulify all already created adaptors +nulifyadaptors +# All adapters have been nullified successful. + +# Create new adaptor +makeadaptor cm +# OK: Adaptor2d_Curve2d has been created. + +# Get curve's resolution from 1.0e-3 +adaptorproperties -resolution 1.0e-3 +# Adaptor2d_Curve2d::Resolution = 0.001 +~~~~~ @subsection occt_draw_6_7 Intersections diff --git a/dox/user_guides/modeling_data/modeling_data.md b/dox/user_guides/modeling_data/modeling_data.md index 5c31123d48..9f4be2bdba 100644 --- a/dox/user_guides/modeling_data/modeling_data.md +++ b/dox/user_guides/modeling_data/modeling_data.md @@ -723,6 +723,143 @@ When you write an algorithm which operates on geometric objects, use Adaptor As a result, you can use the algorithm with any kind of object, if you provide for this object an interface derived from *Adaptor3d* or *Adaptor2d*. These interfaces are easy to use: simply create an adapted curve or surface from a *Geom2d* curve, and then use this adapted curve as an argument for the algorithm? which requires it. +@section occt_modat_4per Periodicity concept + +@subsection occt_modat_4per_1 Mathematical definition + +In math, the following definition of periodicity is applied: + +A function of a real variable \f$ f(x) \f$ is said to be periodic with period \f$ T \neq 0 \f$ if
+1. For every \f$ x \in \mathfrak{D}_{f} \f$ (\f$ \mathfrak{D}_{f} \f$ is the domain of the function \f$ f(x) \f$), the point \f$ \left (x \pm T*n \right ) \in \mathfrak{D}_{f} \f$ (where \f$ n \f$ applies positive integer values only: \f$ n=1,2,... \f$ ) and the condition +\f[ f(x-T*n)=f(x+T*n)=f(x) \f] +is satisfied.
+2. For every \f$ x \notin \mathfrak{D}_{f} \f$, the point \f$ \left (x \pm T*n \right ) \notin \mathfrak{D}_{f} \f$, (where \f$ n=1,2,... \f$ ).
+ +@subsubsection occt_modat_4per_1_1 Example + +For example, the tangent function \f$ f(x)=\tan(x) \f$ is periodic with least period (a least positive constant \f$ T \f$, which will be called later as period) \f$ \pi \f$ because \f$ \tan(x) \f$ is not defined only in points \f$ x=\left (\frac{\pi }{2}\pm \pi *n \right ) \f$ (where \f$ n=0,1,2,... \f$) and for other points the condition
+\f[ \tan(x-\pi*n)=\tan(x+\pi*n)=\tan(x) \f] +is satisfied. + +As we can see from the definition, any periodic function cannot have bounded domain (because product \f$ T*n \f$ tends to infinite) but can be discontinuous. Let us look, how it is realized in OCCT. + +@subsection occt_modat_4per_2 Periodicity of bounded curves + +First of all, OCCT works only with continuous elements (curves and surfaces). I.e. work with curves having continuity less than C0 (e.g. with any gaps) is not supported. + +In OCCT, set of bounded curves includes only Bezier curves, B-spline curves and trimmed curves. Let us consider these objects from point of view to be periodic. + +@subsubsection occt_modat_4per_2_1 Bezier curves + +Bezier curve is always defined in the range \f$ \mathfrak{D}=\left [ 0,1 \right ] \f$ and does not allow any analytical extension. Therefore, Bezier curve cannot be periodic at all. + +@subsubsection occt_modat_4per_2_2 B-spline curve + +OCCT can create a periodic B-spline and can convert any closed B-spline into periodic one. At that, any periodic B-spline is defined on the set of real numbers (\f$ \mathfrak{D}=\mathbb{R} \f$). Nevertheless, in OCCT, periodic B-splines are included in set of bounded curves, too. The class of Bounded curves does not separate periodic and not periodic B-splines.
+ +However, range of not periodic B-spline must be considered as its domain. I.e. if any not periodic B-spline curve is parametrized in the range \f$ t \in \left [ 0,1 \right ] \f$ then its evaluation in the point \f$ t=1.5 \f$ is forbidden (in general). Evaluation of B-spline curve on its analytical extension can be used in some cases. However, it is out of scope of this article. + +@subsubsection occt_modat_4per_2_3 Trimmed curve + +OCCT algorithms allow trimmed curve’s existing out of trim boundaries (exceptionally, if these boundaries match the domain completely). Evidently, the trimmed curve is not defined in the region where its basis curve is not defined.
+ +E.g. if some trimmed curve is an arc of circle and the trim boundaries are \f$ t \in \left [ \frac{\pi }{2},\pi \right ] \f$ then nothing prevents us to compute the value of this arc in the point \f$ t=\frac{3\pi}{2} \f$. Analogically, for some line trimmed in the range \f$ t \in \left [ 0,1 \right ] \f$ nothing prevents us to compute the value in the point \f$ t=100 \f$. In other words, trim boundaries must not be considered as domain boundaries. And curve trimmed from any periodic curve exists out of trim boundaries. Consequently, this trimmed curve can be considered as periodic curve.
+ +Also, let us make the final conclusion. In OCCT algorithms, trimmed curve is considered to be periodic if its basis curve is periodic. At that trim boundaries do not play any role. I.e. the curve itself can be periodic and not closed.
+ +@subsubsection occt_modat_4per_2_4 Trim boundaries + +@ref occt_modat_4per_2_3 "We have just found out" that the trim boundaries are not domain boundaries. But what is their real role in OCCT algorithms? + +Trim boundaries define some work range of the trimmed curve. Indeed, this (default) work range exists for any OCCT curve (not only for trimmed one). For any periodic not trimmed curve, the work range is \f$ \mathfrak{W}=\left [ 0,T \right ) \f$ (where \f$ T \f$ is the period of the curve). For bounded not trimmed curve, this work range matches its domain. For other not trimmed curves (e.g. line), the work range is \f$ \mathfrak{W}=\left ( -\infty ,+\infty \right ) \f$ (i.e. matches its domain, too). + +Operation "TRIM" applied to the curve allows changing its work range (shifting or reducing but not increasing). Setting work range greater than the default one is strictly forbidden. + +E.g. the default work range of any circle is \f$ \mathfrak{W}=\left [ 0,2\pi \right ) \f$. With "TRIM" operation you can create trimmed circle (i.e. arc) with work ranges \f$ \left [ 0,\pi \right ] \f$, \f$ \left [ 5\pi,\frac{11\pi}{2} \right ] \f$, \f$ \left [ 100\pi,102\pi \right ] \f$ etc. However, you must have failed to create arc with work range \f$ \left [ 50\pi,55\pi \right ] \f$, because this new work range is greater than \f$ \mathfrak{W} \f$. + +For not periodic B-spline curve with default work range \f$ \mathfrak{W}=\left [ 0,1 \right ] \f$, you can create trimmed B-spline curve with work ranges \f$ \left [ 0,0.1 \right ] \f$, \f$ \left [ 0.6,0.78 \right ] \f$, \f$ \left [ 0.5,1 \right ] \f$ etc. However, you must have failed to set work range to \f$ \left [ 0.8,1.5 \right ] \f$ (because the input B-spline is not defined in the range \f$ \left ( 1,1.5 \right ] \f$). + +For a line, you can create any work range with "TRIM" operation. Every work range will be valid. + +Use the method **GeomLib::IsTrimAllowed(...)** in order to check whether the new work range can be applied to the curve. Please see documentation about this method. + +However, what does work range bring to OCCT? The point is that the most OCCT algorithms tend to work in work ranges of their input data. So, if you call extrema high level tool (exactly API) then you will obtain point with parameters already adjusted in work range of the arguments. If you call surface-surface intersection algorithm (API again) then you will obtain 3D curve and two 2D curves, which are already in surfaces’ work ranges (you do not need any shifting them). So, correct using work ranges makes work with OCCT more convenient. + +@subsection occt_modat_4per_3 Periodicity of curves’ adaptors + +In OCCT, periodicity of adaptors depends on the periodicity of their curves only. Any ranges are not taken into account. + +At that, it is useful to note the fact that adaptor’s curve is always not trimmed. I.e. if some trimmed curve is sent into some adaptor then the adaptor will store the basis (not trimmed) curve and First/Last parameters of adaptor will be set to the corresponding trim boundaries. + +Moreover, there are some specific adaptors in OCCT. E.g. **BRepAdaptor_CompCurve**. Periodicity of such adaptors is defined in a special way. So, it is necessary to read reference manual about these classes in order to get more clear understanding of their behavior. + +@subsection occt_modat_4per_4 Periodicity of surfaces + +In OCCT, a surface is set in parametric form by vector function of two real variables: \f$ S(U,V) \f$. As result, term of periodicity is considered for every such variable separately (\f$ U\f$ periodic and \f$ V \f$ periodic surfaces are considered). Also, there exist biperiodic surfaces (e.g. Toroidal surface), which are periodic in both \f$ U \f$ and \f$ V \f$ directions (OCCT does not work with univariate function of a complex argument; therefore commonly-used terms "Double periodic" or "Triple periodic" are not figured in OCCT). + +Also, it should be noticed that any surface always has rectangular domain. I.e. the surface domain always has such form: \f$ \mathfrak{D}_{S} = \left \{ (U, V) | U_{1}\leq U \leq U_{2}, V_{1}\leq V \leq V_{2} \right \} \f$, where \f$ U_{1} \f$, \f$ U_{2} \f$, \f$ V_{1} \f$ and \f$ V_{2} \f$ are four independent (on each other) numbers (they can apply infinite values). + +Having taken into account this remark, periodicity of some surface can be defined as follows: + +The surface \f$ S(U,V) \f$ is \f$ U \f$ periodic if for every fixed value of \f$V\f$ argument \f$ (V=V_{0}, V_{0}\in \mathfrak{D}_{S})\f$, the univariate function of real variable \f$ F(U)=S(U,V_{0} ) \f$ is periodic. + +Analogically, The surface \f$ S(U,V) \f$ is \f$ V \f$ periodic if for every fixed value of \f$U\f$ argument \f$ (U=U_{0}, U_{0}\in \mathfrak{D}_{S})\f$, the univariate function of real variable \f$ F(V)=S(U_{0}, V) \f$ is periodic. + +All remarks made @ref occt_modat_4per_2 "above" considering bounded curves are satisfied for bounded surfaces. At that, a work range of any surface is a region in 2D (rectangular) Cartesian coordinate system taking into account permissible values of U and V parameters. The example is given @ref occt_modat_4per_5 "below". + +The methods analogical to **GeomLib::IsTrimAllowed(...)** that can be applied to a surface are called **GeomLib::IsUTrimAllowed(...)** and **GeomLib::IsVTrimAllowed(...)**. + +@subsection occt_modat_4per_5 Special questions about periodicity of surfaces +@subsubsection occt_modat_4per_5_1 Periodicity of a spherical surface + +Let us consider a spherical surface having radius \f$ R \f$. It can be defined in local coordinate system (UCS) by the vector function of two scalar arguments: +\f[ + S\left ( U,V \right )=R* \begin{pmatrix} + \cos (U)*\cos (V)\\ + \sin (U)*\cos (V)\\ + \sin (V) + \end{pmatrix} +\f] + +As we can see, this function is \f$ V \f$ periodic and its \f$ V \f$ period is equal to \f$ 2\pi \f$. And it is \f$ U \f$ periodic with \f$ U \f$ period \f$ 2\pi \f$. I.e. (theoretically) the default work range of any surface with such equation is the set of 2D points such \f$ \mathfrak{W}=\left \{(U,V)|0\leq U < 2\pi, 0\leq V < 2\pi \right \} \f$. + +However, let us take two different points in the parametric space: \f$ (0,0) \f$ and \f$ (\pi,\pi) \f$. Their 3D images are: \f$ S\left ( 0,0 \right )=\begin{pmatrix}R & 0 & 0\end{pmatrix}^{T} \f$, \f$ S\left ( \pi,\pi \right )=\begin{pmatrix}R & 0 & 0\end{pmatrix}^{T} \f$. As we can see, 3D points are the same. This fact is inappropriate for different points from one work range. Such result says about that the surface \f$ S(U,V) \f$ is self-interfered surface. + +Working with self-interfered elements is not supported by OCCT at all. Therefore, in order to make spherical surface valid, specific domain is assigned to sphere. Namely:
+ +\f[ \mathfrak{D}_{S}= \left \{(U,V)|-\infty < U < +\infty , -\frac{\pi}{2}\leq V \leq \frac{\pi}{2} \right \} \f] + +Of course, the range for V parameter must be \f$ -\frac{\pi}{2}+2\pi n\leq V \leq \frac{\pi}{2}+2\pi n \f$ (where \f$ n \f$ applies positive integer values only: \f$ n=1,2,... \f$). However, this range is discontinuous and is not supported (see the section @ref occt_modat_4per_2). Therefore, \f$ V \f$ parameter of spherical surface is considered to be bounded. Consequently, sphere is considered to be not \f$ V \f$ periodic. + +Based on this fact, the default sphere’s work range is \f$ \mathfrak{W}=\left \{(U,V)|0\leq U < 2\pi, -\frac{\pi}{2}\leq V \leq \frac{\pi}{2} \right \} \f$. Please pay attention to the fact that the spherical surface is \f$ U \f$ periodic surface with \f$ U \f$ period is equal to \f$ 2\pi \f$. Therefore, value of \f$ U \f$ parameter can be any real number (\f$U \in \mathbb{R}\f$). However, its work range in \f$ U \f$ direction cannot be greater than \f$ 2\pi \f$. In that way the sphere is not self-interfered (the point \f$ (\pi,\pi) \f$ is out of its domain) and is valid completely. + +@subsubsection occt_modat_4per_5_2 Periodicity of a Surface-of-Revolution + +@ref occt_modat_4per_5_1 "Analogical situation" exists with surface of revolution. Having taken into account all said above, let us formulate conditions when the surface of revolution is \f$ V \f$ periodic. + +Evidently, for that case, the basis curve must be periodic curve. Additionally, revolving full curve (taken with its default work range) must not lead to create self-interfered surface of revolution (i.e. this curve must not intersect the rotation axis). In other words, the valid (not self-interfered) surface of revolution must be based on closed periodic curve in order to be \f$ V \f$ periodic. + +Please note that the basis curve can be not closed by different reasons (not only in order to avoid creating self-interfered surface of revolution), which are neither nor separated nor analyzed by OCCT. OCCT uses simple check: periodicity of basis curve and its closure. It is connected with the fact that the property of periodicity of a Surface-of-Revolution is not very important for OCCT-algorithms because almost all algorithms work only with work range of a Surface-of-Revolution (i.e. in most cases we do not need in adjusting parameters). + +Based on the foregoing, the domain of any not \f$ V \f$ periodic surface of revolution is \f$ \mathfrak{D}_{S}= \left \{(U,V)|-\infty < U < +\infty , C_{f} \leq V \leq C_{l} \right \} \f$, where \f$ \left [C_{f},C_{l} \right ] \f$ is the work range of the basis curve (i.e. the work range of the basis curve defines the domain of the surface). The default work range of this surface is \f$ \mathfrak{W}=\left \{(U,V)|0\leq U < 2\pi, C_{f} \leq V \leq C_{l} \right \} \f$. + +Finally, it is got to be said that the constructors of surface of revolution do not check the situation when invalid result can be created. It must be done on application level (e.g. by using **GeomLib::IsVTrimAllowed(...)** method). We recommend to use the following steps (which should be used only in places where you doubt in validity of created surface of revolution): + +1.Create a surface of revolution with default work range of the basis curve;
+2.Compute new work range of the basis curve (it depends on your requirements only);
+3.Call **GeomLib::IsVTrimAllowed(...)** method with existing surface of revolution and the new range. If the new range is valid the method will return TRUE.
+ +The method **GeomLib::IsVTrimAllowed(...)** works with spherical surface, too. + +@subsection occt_modat_4per_6 Periodicity of surfaces’ adaptors + +@ref occt_modat_4per_3 "As for curves", periodicity of adaptors depends on the periodicity of their surfaces only. All remarks about curve's adaptor are fair to surfaces. + +@subsection occt_modat_4per_7 Methods IsPeriodic(), IsUPeriodic(), IsVPeriodic(), Period(), UPeriod() and VPeriod() + +Periodicity can be checked with methods IsPeriodic(), IsUPeriodic() and IsVPeriodic(), which are overriden for curves, surfaces and adaptors. + +For periodic elements (curves/surfaces/adaptors) methods Period(), UPeriod() and VPeriod() return their period value. For not periodic elements, it throws an exception "Standard_NotImplemented". @section occt_modat_5 Topology diff --git a/src/Adaptor2d/Adaptor2d_Curve2d.hxx b/src/Adaptor2d/Adaptor2d_Curve2d.hxx index c845bcef7a..e65dbc9c18 100644 --- a/src/Adaptor2d/Adaptor2d_Curve2d.hxx +++ b/src/Adaptor2d/Adaptor2d_Curve2d.hxx @@ -86,8 +86,10 @@ public: Standard_EXPORT virtual Standard_Boolean IsClosed() const; + //! Returns TRUE if the curve is periodic Standard_EXPORT virtual Standard_Boolean IsPeriodic() const; + //! Returns the period of the curve Standard_EXPORT virtual Standard_Real Period() const; //! Computes the point of parameter U on the curve. diff --git a/src/Adaptor2d/Adaptor2d_HCurve2d.hxx b/src/Adaptor2d/Adaptor2d_HCurve2d.hxx index 1e2f815751..039661b26a 100644 --- a/src/Adaptor2d/Adaptor2d_HCurve2d.hxx +++ b/src/Adaptor2d/Adaptor2d_HCurve2d.hxx @@ -76,9 +76,11 @@ public: Standard_Boolean IsClosed() const; - Standard_Boolean IsPeriodic() const; + //! Returns true if the curve in this adapter is periodic + Standard_Boolean IsPeriodic() const; - Standard_Real Period() const; + //! Returns the period of 2D-adapter's curve + Standard_Real Period() const; gp_Pnt2d Value (const Standard_Real U) const; diff --git a/src/Adaptor2d/Adaptor2d_Line2d.cxx b/src/Adaptor2d/Adaptor2d_Line2d.cxx index d9c117832d..843a2c2b41 100644 --- a/src/Adaptor2d/Adaptor2d_Line2d.cxx +++ b/src/Adaptor2d/Adaptor2d_Line2d.cxx @@ -166,16 +166,6 @@ Standard_Boolean Adaptor2d_Line2d::IsPeriodic() const return Standard_False; } -//======================================================================= -//function : Period -//purpose : -//======================================================================= - -Standard_Real Adaptor2d_Line2d::Period() const -{ - throw Standard_NoSuchObject(); -} - //======================================================================= //function : Value //purpose : diff --git a/src/Adaptor2d/Adaptor2d_Line2d.hxx b/src/Adaptor2d/Adaptor2d_Line2d.hxx index f365e50804..3bb60483df 100644 --- a/src/Adaptor2d/Adaptor2d_Line2d.hxx +++ b/src/Adaptor2d/Adaptor2d_Line2d.hxx @@ -87,10 +87,9 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Always returns FALSE Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; - Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; - Standard_EXPORT gp_Pnt2d Value (const Standard_Real X) const Standard_OVERRIDE; Standard_EXPORT void D0 (const Standard_Real X, gp_Pnt2d& P) const Standard_OVERRIDE; diff --git a/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx b/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx index b1b1c356f3..358adb62fd 100644 --- a/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx +++ b/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx @@ -105,8 +105,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the curve is periodic Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns the period of the curve Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve. diff --git a/src/Adaptor3d/Adaptor3d_Curve.cxx b/src/Adaptor3d/Adaptor3d_Curve.cxx index 49b02da158..155cdb4dee 100644 --- a/src/Adaptor3d/Adaptor3d_Curve.cxx +++ b/src/Adaptor3d/Adaptor3d_Curve.cxx @@ -106,7 +106,6 @@ Handle(Adaptor3d_HCurve) Adaptor3d_Curve::Trim(const Standard_Real , const Stand throw Standard_NotImplemented("Adaptor3d_Curve::Trim"); } - //======================================================================= //function : IsClosed //purpose : diff --git a/src/Adaptor3d/Adaptor3d_Curve.hxx b/src/Adaptor3d/Adaptor3d_Curve.hxx index de882dc430..cad77f24a2 100644 --- a/src/Adaptor3d/Adaptor3d_Curve.hxx +++ b/src/Adaptor3d/Adaptor3d_Curve.hxx @@ -88,8 +88,10 @@ public: Standard_EXPORT virtual Standard_Boolean IsClosed() const; + //! Returns TRUE if the curve is periodic Standard_EXPORT virtual Standard_Boolean IsPeriodic() const; + //! Returns the period of the curve Standard_EXPORT virtual Standard_Real Period() const; //! Computes the point of parameter U on the curve. diff --git a/src/Adaptor3d/Adaptor3d_CurveOnSurface.hxx b/src/Adaptor3d/Adaptor3d_CurveOnSurface.hxx index c7431f67a4..7b2d308fcb 100644 --- a/src/Adaptor3d/Adaptor3d_CurveOnSurface.hxx +++ b/src/Adaptor3d/Adaptor3d_CurveOnSurface.hxx @@ -112,8 +112,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the curve is periodic Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns the period of the curve Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve. diff --git a/src/Adaptor3d/Adaptor3d_HCurve.hxx b/src/Adaptor3d/Adaptor3d_HCurve.hxx index 3e4e321af0..65ea0bbdbd 100644 --- a/src/Adaptor3d/Adaptor3d_HCurve.hxx +++ b/src/Adaptor3d/Adaptor3d_HCurve.hxx @@ -93,8 +93,10 @@ public: Standard_Boolean IsClosed() const; + //! Returns true if the curve in this adapter is periodic Standard_Boolean IsPeriodic() const; + //! Returns the period of the adapter's curve Standard_Real Period() const; gp_Pnt Value (const Standard_Real U) const; diff --git a/src/Adaptor3d/Adaptor3d_HSurface.hxx b/src/Adaptor3d/Adaptor3d_HSurface.hxx index 80fd5f8199..9ed745d857 100644 --- a/src/Adaptor3d/Adaptor3d_HSurface.hxx +++ b/src/Adaptor3d/Adaptor3d_HSurface.hxx @@ -95,12 +95,16 @@ public: Standard_Boolean IsVClosed() const; + //! Returns true if the surface in this adapter is U periodic Standard_Boolean IsUPeriodic() const; + //! Returns U period of U-periodic surface Standard_Real UPeriod() const; + //! Returns true if the surface in this adapter is V periodic Standard_Boolean IsVPeriodic() const; + //! Returns V period of V-periodic surface Standard_Real VPeriod() const; gp_Pnt Value (const Standard_Real U, const Standard_Real V) const; diff --git a/src/Adaptor3d/Adaptor3d_HSurfaceTool.hxx b/src/Adaptor3d/Adaptor3d_HSurfaceTool.hxx index 6fd07573f3..60d6dfb63f 100644 --- a/src/Adaptor3d/Adaptor3d_HSurfaceTool.hxx +++ b/src/Adaptor3d/Adaptor3d_HSurfaceTool.hxx @@ -80,13 +80,17 @@ public: static Standard_Boolean IsVClosed (const Handle(Adaptor3d_HSurface)& S); - static Standard_Boolean IsUPeriodic (const Handle(Adaptor3d_HSurface)& S); + //! Returns TRUE if S is U-periodic + static Standard_Boolean IsUPeriodic (const Handle(Adaptor3d_HSurface)& S); - static Standard_Real UPeriod (const Handle(Adaptor3d_HSurface)& S); - - static Standard_Boolean IsVPeriodic (const Handle(Adaptor3d_HSurface)& S); + //! Returns U-period of S + static Standard_Real UPeriod (const Handle(Adaptor3d_HSurface)& S); + + //! Returns TRUE if S is V-periodic + static Standard_Boolean IsVPeriodic (const Handle(Adaptor3d_HSurface)& S); - static Standard_Real VPeriod (const Handle(Adaptor3d_HSurface)& S); + //! Returns V-period of S + static Standard_Real VPeriod (const Handle(Adaptor3d_HSurface)& S); static gp_Pnt Value (const Handle(Adaptor3d_HSurface)& S, const Standard_Real u, const Standard_Real v); diff --git a/src/Adaptor3d/Adaptor3d_IsoCurve.hxx b/src/Adaptor3d/Adaptor3d_IsoCurve.hxx index 2032eb9888..1e6107ab1a 100644 --- a/src/Adaptor3d/Adaptor3d_IsoCurve.hxx +++ b/src/Adaptor3d/Adaptor3d_IsoCurve.hxx @@ -114,8 +114,11 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the surface (returned by Surface() method) is periodic + //! along specified direction. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + // Returns the period value along specified direction. Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve. diff --git a/src/Adaptor3d/Adaptor3d_Surface.cxx b/src/Adaptor3d/Adaptor3d_Surface.cxx index 42adac71bb..4f628492f6 100644 --- a/src/Adaptor3d/Adaptor3d_Surface.cxx +++ b/src/Adaptor3d/Adaptor3d_Surface.cxx @@ -179,7 +179,6 @@ Handle(Adaptor3d_HSurface) Adaptor3d_Surface::VTrim(const Standard_Real , const throw Standard_NotImplemented("Adaptor3d_Surface::VTrim"); } - //======================================================================= //function : IsUClosed //purpose : diff --git a/src/Adaptor3d/Adaptor3d_Surface.hxx b/src/Adaptor3d/Adaptor3d_Surface.hxx index 1f5c3061ee..ab963e3d48 100644 --- a/src/Adaptor3d/Adaptor3d_Surface.hxx +++ b/src/Adaptor3d/Adaptor3d_Surface.hxx @@ -51,7 +51,7 @@ class Adaptor3d_HCurve; //! the surface by algorithms which use it. //! A derived concrete class is provided: //! GeomAdaptor_Surface for a surface from the Geom package. -//! The Surface class describes the standard behaviour +//! The Surface class describes the standard behavior //! of a surface for generic algorithms. //! //! The Surface can be decomposed in intervals of any @@ -59,7 +59,7 @@ class Adaptor3d_HCurve; //! NbIntervals. A current interval can be set. Most //! of the methods apply to the current interval. //! Warning: All the methods are virtual and implemented with a -//! raise to allow to redefined only the methods realy +//! raise to allow to redefined only the methods really //! used. //! //! Polynomial coefficients of BSpline surfaces used for their evaluation are @@ -117,12 +117,16 @@ public: Standard_EXPORT virtual Standard_Boolean IsVClosed() const; + //! Returns TRUE if the surface is U periodic Standard_EXPORT virtual Standard_Boolean IsUPeriodic() const; + //! Returns U period of the surface Standard_EXPORT virtual Standard_Real UPeriod() const; + //! Returns TRUE if the surface is V periodic Standard_EXPORT virtual Standard_Boolean IsVPeriodic() const; + //! Returns V period of the surface Standard_EXPORT virtual Standard_Real VPeriod() const; //! Computes the point of parameters U,V on the surface. diff --git a/src/BOPTools/BOPTools_AlgoTools.cxx b/src/BOPTools/BOPTools_AlgoTools.cxx index b65d4aaf05..4a00a843af 100644 --- a/src/BOPTools/BOPTools_AlgoTools.cxx +++ b/src/BOPTools/BOPTools_AlgoTools.cxx @@ -1580,9 +1580,7 @@ void BOPTools_AlgoTools::MakePCurve(const TopoDS_Edge& aE, // aTolE=BRep_Tool::Tolerance(aE); // - const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aT1, aT2); - Handle(Geom_TrimmedCurve)aC3DETrim= - new Geom_TrimmedCurve(aC3DE, aT1, aT2); + BRep_Tool::Range(aE, aT1, aT2); // for (i=0; i<2; ++i) { bPC = !i ? bPC1 : bPC2; @@ -1602,21 +1600,15 @@ void BOPTools_AlgoTools::MakePCurve(const TopoDS_Edge& aE, aFFWD.Orientation(TopAbs_FORWARD); // aC2D=aC2Dx1; - if (aC2D.IsNull()) { + if (aC2D.IsNull()) + { BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aFFWD, theContext); BOPTools_AlgoTools2D::CurveOnSurface(aE, aFFWD, aC2D, aOutFirst, aOutLast, aOutTol, theContext); } // - if (aC3DE->IsPeriodic()) { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(aFFWD, aT1, aT2, aC2D, - aC2DA, theContext); - } - else { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(aFFWD, aC3DETrim, aC2D, - aC2DA, theContext); - } + BOPTools_AlgoTools2D::AdjustPCurveOnFace(aFFWD, aT1, aT2, aC2D, aC2DA, theContext); // aBB.UpdateEdge(aE, aC2DA, aFFWD, aTolE); //BRepLib::SameParameter(aE); diff --git a/src/BOPTools/BOPTools_AlgoTools2D.cxx b/src/BOPTools/BOPTools_AlgoTools2D.cxx index b24667e264..bef30d6205 100644 --- a/src/BOPTools/BOPTools_AlgoTools2D.cxx +++ b/src/BOPTools/BOPTools_AlgoTools2D.cxx @@ -250,22 +250,6 @@ Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface //function : AdjustPCurveOnFace //purpose : //======================================================================= -void BOPTools_AlgoTools2D::AdjustPCurveOnFace - (const TopoDS_Face& theF, - const Handle(Geom_Curve)& theC3D, - const Handle(Geom2d_Curve)& theC2D, - Handle(Geom2d_Curve)& theC2DA, - const Handle(IntTools_Context)& theContext) -{ - Standard_Real aT1 = theC3D->FirstParameter(); - Standard_Real aT2 = theC3D->LastParameter(); - // - BOPTools_AlgoTools2D::AdjustPCurveOnFace (theF, aT1, aT2, theC2D, theC2DA, theContext); -} -//======================================================================= -//function : AdjustPCurveOnFace -//purpose : -//======================================================================= void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& theF, const Standard_Real theFirst, diff --git a/src/BOPTools/BOPTools_AlgoTools2D.hxx b/src/BOPTools/BOPTools_AlgoTools2D.hxx index 8db49a549d..17082d3752 100644 --- a/src/BOPTools/BOPTools_AlgoTools2D.hxx +++ b/src/BOPTools/BOPTools_AlgoTools2D.hxx @@ -110,14 +110,6 @@ public: Standard_EXPORT static Standard_Boolean HasCurveOnSurface(const TopoDS_Edge& aE, const TopoDS_Face& aF); - //! Adjust P-Curve (3D-curve ) on surface of the face .
- //! - storage for caching the geometrical tools - Standard_EXPORT static void AdjustPCurveOnFace(const TopoDS_Face& theF, - const Handle(Geom_Curve)& theC3D, - const Handle(Geom2d_Curve)& theC2D, - Handle(Geom2d_Curve)& theC2DA, - const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); - //! Adjust P-Curve (3D-curve ) on surface .
//! [aT1, aT2] - range to adjust
//! - storage for caching the geometrical tools diff --git a/src/BOPTools/BOPTools_AlgoTools3D.cxx b/src/BOPTools/BOPTools_AlgoTools3D.cxx index 06653d1605..5dcd0739aa 100644 --- a/src/BOPTools/BOPTools_AlgoTools3D.cxx +++ b/src/BOPTools/BOPTools_AlgoTools3D.cxx @@ -75,8 +75,8 @@ static void BOPTools_AlgoTools3D::DoSplitSEAMOnFace (const TopoDS_Edge& aSplit, const TopoDS_Face& aF) { - Standard_Boolean bIsUPeriodic, bIsVPeriodic, bIsLeft; - Standard_Real aTol, a, b, anUPeriod, anVPeriod, aT, anU, dU, anU1; + Standard_Boolean bIsLeft; + Standard_Real aTol, a, b, aT, anU, dU, anU1; Standard_Real aScPr, anV, dV, anV1; Standard_Real aUmin, aUmax, aVmin, aVmax; gp_Pnt2d aP2D; @@ -97,59 +97,17 @@ void BOPTools_AlgoTools3D::DoSplitSEAMOnFace (const TopoDS_Edge& aSplit, // aS->Bounds(aUmin, aUmax, aVmin, aVmax); // - bIsUPeriodic=aS->IsUPeriodic(); - bIsVPeriodic=aS->IsVPeriodic(); + const Standard_Boolean bIsUPeriodic = aS->IsUPeriodic() && aS->IsUClosed(); + const Standard_Boolean bIsVPeriodic = aS->IsVPeriodic() && aS->IsVClosed(); // - anUPeriod = bIsUPeriodic ? aS->UPeriod() : 0.; - anVPeriod = bIsVPeriodic ? aS->VPeriod() : 0.; - // - if (!bIsUPeriodic && !bIsVPeriodic) { - Standard_Boolean bIsUClosed, bIsVClosed; - Handle(Geom_BSplineSurface) aBS; - Handle(Geom_BezierSurface) aBZ; - Handle(Geom_RectangularTrimmedSurface) aRTS; - // - bIsUClosed=Standard_False; - bIsVClosed=Standard_False; - aBS=Handle(Geom_BSplineSurface)::DownCast(aS); - aBZ=Handle(Geom_BezierSurface) ::DownCast(aS); - aRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS); - // - if (!aBS.IsNull()) { - bIsUClosed=aBS->IsUClosed(); - bIsVClosed=aBS->IsVClosed(); - } - else if (!aBZ.IsNull()) { - bIsUClosed=aBZ->IsUClosed(); - bIsVClosed=aBZ->IsVClosed(); - } - else if (!aRTS.IsNull()) { - Handle(Geom_Surface) aSB; - // - aSB=aRTS->BasisSurface(); - bIsUPeriodic=aSB->IsUPeriodic(); - bIsVPeriodic=aSB->IsVPeriodic(); - // - if (!(bIsUPeriodic || bIsVPeriodic)) { - return; - } - anUPeriod = bIsUPeriodic ? aSB->UPeriod() : 0.; - anVPeriod = bIsVPeriodic ? aSB->VPeriod() : 0.; - } - // - if (aRTS.IsNull()) { - if (!bIsUClosed && !bIsVClosed) { - return; - } - // - if (bIsUClosed) { - anUPeriod=aUmax-aUmin; - } - if (bIsVClosed) { - anVPeriod=aVmax-aVmin; - } - } + if (!bIsUPeriodic && !bIsVPeriodic) + { + return; } + + const Standard_Real anUPeriod = bIsUPeriodic ? aS->UPeriod() : 0.; + const Standard_Real anVPeriod = bIsVPeriodic ? aS->VPeriod() : 0.; + // //--------------------------------------------------- C2D1=BRep_Tool::CurveOnSurface(aSp, aF, a, b); diff --git a/src/BRepAdaptor/BRepAdaptor_CompCurve.cxx b/src/BRepAdaptor/BRepAdaptor_CompCurve.cxx index e4068ac95c..551afef2e3 100644 --- a/src/BRepAdaptor/BRepAdaptor_CompCurve.cxx +++ b/src/BRepAdaptor/BRepAdaptor_CompCurve.cxx @@ -288,11 +288,6 @@ const TopoDS_Wire& BRepAdaptor_CompCurve::Wire() const { return Standard_False; -} - - Standard_Real BRepAdaptor_CompCurve::Period() const -{ - return (TLast - TFirst); } gp_Pnt BRepAdaptor_CompCurve::Value(const Standard_Real U) const diff --git a/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx b/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx index e009fea951..2426fff3f5 100644 --- a/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx +++ b/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx @@ -113,10 +113,9 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Always returns FALSE Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; - Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; - //! Computes the point of parameter U on the curve Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE; diff --git a/src/BRepAdaptor/BRepAdaptor_Curve.hxx b/src/BRepAdaptor/BRepAdaptor_Curve.hxx index 640505d6f7..c81f70f2d9 100644 --- a/src/BRepAdaptor/BRepAdaptor_Curve.hxx +++ b/src/BRepAdaptor/BRepAdaptor_Curve.hxx @@ -149,8 +149,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the curve is periodic Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns the period of the curve Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve diff --git a/src/BRepAdaptor/BRepAdaptor_Surface.hxx b/src/BRepAdaptor/BRepAdaptor_Surface.hxx index 70858bf8fa..ebc5bad8f6 100644 --- a/src/BRepAdaptor/BRepAdaptor_Surface.hxx +++ b/src/BRepAdaptor/BRepAdaptor_Surface.hxx @@ -145,12 +145,16 @@ public: Standard_Boolean IsVClosed() const Standard_OVERRIDE; + //! Returns TRUE if the surface is U-periodic Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; + //! Returns U period of the surface Standard_Real UPeriod() const Standard_OVERRIDE; + //! Returns TRUE if the surface is V-periodic Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns V period of the surface Standard_Real VPeriod() const Standard_OVERRIDE; //! Computes the point of parameters U,V on the surface. diff --git a/src/BRepAlgo/BRepAlgo.cxx b/src/BRepAlgo/BRepAlgo.cxx index 40a6277af9..b8648203e6 100644 --- a/src/BRepAlgo/BRepAlgo.cxx +++ b/src/BRepAlgo/BRepAlgo.cxx @@ -229,13 +229,13 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire) GeomAdaptor_Curve aGACurve(aCurve); GeomAbs_CurveType aType = aGACurve.GetType(); - Handle(Geom_Curve) aBasisCurve = aGACurve.Curve(); Standard_Boolean isFwd = (wexp.Orientation() != TopAbs_REVERSED); - if (aBasisCurve->IsPeriodic()) { - ElCLib::AdjustPeriodic - (aBasisCurve->FirstParameter(), aBasisCurve->LastParameter(), - Precision::PConfusion(), fpar, lpar); + if (aGACurve.IsPeriodic()) + { + const Handle(Geom_Curve) &aBasisCurve = aGACurve.Curve(); + ElCLib::AdjustPeriodic(aBasisCurve->FirstParameter(), aBasisCurve->LastParameter(), + Precision::PConfusion(), fpar, lpar); } if (CurveSeq.IsEmpty()) { @@ -353,9 +353,10 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire) if (isSameCurve) { const Standard_Boolean isSameDir = (isFwd == IsFwdSeq.Last()); - if (aBasisCurve->IsPeriodic()) { + if (aGACurve.IsPeriodic()) + { // Treat periodic curves. - const Standard_Real aPeriod = aBasisCurve->Period(); + const Standard_Real aPeriod = aGACurve.Period(); if (isSameDir) { // Check if first parameter is greater then the last one. diff --git a/src/BRepApprox/BRepApprox_SurfaceTool.hxx b/src/BRepApprox/BRepApprox_SurfaceTool.hxx index 0aa2504da2..3cafe74a45 100644 --- a/src/BRepApprox/BRepApprox_SurfaceTool.hxx +++ b/src/BRepApprox/BRepApprox_SurfaceTool.hxx @@ -81,13 +81,17 @@ public: static Standard_Boolean IsVClosed (const BRepAdaptor_Surface& S); - static Standard_Boolean IsUPeriodic (const BRepAdaptor_Surface& S); - - static Standard_Real UPeriod (const BRepAdaptor_Surface& S); + //! Returns TRUE if S is U-periodic + static Standard_Boolean IsUPeriodic (const BRepAdaptor_Surface& S); + + //! Returns U-period of S + static Standard_Real UPeriod (const BRepAdaptor_Surface& S); - static Standard_Boolean IsVPeriodic (const BRepAdaptor_Surface& S); + //! Returns TRUE if S is V-periodic + static Standard_Boolean IsVPeriodic (const BRepAdaptor_Surface& S); - static Standard_Real VPeriod (const BRepAdaptor_Surface& S); + //! Returns V-period of S + static Standard_Real VPeriod (const BRepAdaptor_Surface& S); static gp_Pnt Value (const BRepAdaptor_Surface& S, const Standard_Real u, const Standard_Real v); diff --git a/src/BRepBlend/BRepBlend_HCurve2dTool.hxx b/src/BRepBlend/BRepBlend_HCurve2dTool.hxx index bb4d60b3f2..0d87482bd5 100644 --- a/src/BRepBlend/BRepBlend_HCurve2dTool.hxx +++ b/src/BRepBlend/BRepBlend_HCurve2dTool.hxx @@ -71,9 +71,11 @@ public: static Standard_Boolean IsClosed (const Handle(Adaptor2d_HCurve2d)& C); - static Standard_Boolean IsPeriodic (const Handle(Adaptor2d_HCurve2d)& C); + //! Returns TRUE if C is periodic + static Standard_Boolean IsPeriodic (const Handle(Adaptor2d_HCurve2d)& C); - static Standard_Real Period (const Handle(Adaptor2d_HCurve2d)& C); + //! Returns the period of C + static Standard_Real Period (const Handle(Adaptor2d_HCurve2d)& C); //! Computes the point of parameter U on the curve. static gp_Pnt2d Value (const Handle(Adaptor2d_HCurve2d)& C, const Standard_Real U); diff --git a/src/BRepBlend/BRepBlend_HCurveTool.hxx b/src/BRepBlend/BRepBlend_HCurveTool.hxx index aed677ec7a..2d48700089 100644 --- a/src/BRepBlend/BRepBlend_HCurveTool.hxx +++ b/src/BRepBlend/BRepBlend_HCurveTool.hxx @@ -71,9 +71,11 @@ public: static Standard_Boolean IsClosed (const Handle(Adaptor3d_HCurve)& C); - static Standard_Boolean IsPeriodic (const Handle(Adaptor3d_HCurve)& C); + //! Returns TRUE if C is periodic + static Standard_Boolean IsPeriodic (const Handle(Adaptor3d_HCurve)& C); - static Standard_Real Period (const Handle(Adaptor3d_HCurve)& C); + //! Returns the period of C + static Standard_Real Period (const Handle(Adaptor3d_HCurve)& C); //! Computes the point of parameter U on the curve. static gp_Pnt Value (const Handle(Adaptor3d_HCurve)& C, const Standard_Real U); diff --git a/src/BRepBndLib/BRepBndLib.cxx b/src/BRepBndLib/BRepBndLib.cxx index 6aa8c2dd49..ca0491007b 100644 --- a/src/BRepBndLib/BRepBndLib.cxx +++ b/src/BRepBndLib/BRepBndLib.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,8 @@ #include #include #include +#include + // static Standard_Boolean CanUseEdges(const Adaptor3d_Surface& BS); // @@ -470,7 +473,6 @@ void FindExactUVBounds(const TopoDS_Face FF, umax = aBAS.LastUParameter(); vmin = aBAS.FirstVParameter(); vmax = aBAS.LastVParameter(); - Standard_Boolean isUperiodic = aBAS.IsUPeriodic(), isVperiodic = aBAS.IsVPeriodic(); Standard_Real aT1, aT2; Standard_Real TolU = Max(aBAS.UResolution(Tol), Precision::PConfusion()); Standard_Real TolV = Max(aBAS.VResolution(Tol), Precision::PConfusion()); @@ -502,13 +504,13 @@ void FindExactUVBounds(const TopoDS_Face FF, aV /= Sqrt(magn); } Standard_Real u = aP.X(), v = aP.Y(); - if(isUperiodic) + if (aBAS.IsUPeriodic()) { - ElCLib::InPeriod(u, umin, umax); + ElCLib::InPeriod(u, umin, umin + aBAS.UPeriod()); } - if(isVperiodic) + if (aBAS.IsVPeriodic()) { - ElCLib::InPeriod(v, vmin, vmax); + ElCLib::InPeriod(v, vmin, vmin + aBAS.VPeriod()); } // if(Abs(u - umin) <= TolU || Abs(u - umax) <= TolU) @@ -588,33 +590,33 @@ void FindExactUVBounds(const TopoDS_Face FF, Handle(Geom_Surface) aS = BRep_Tool::Surface(FF, aLoc); Standard_Real aUmin, aUmax, aVmin, aVmax; aS->Bounds(aUmin, aUmax, aVmin, aVmax); - if(!aS->IsUPeriodic()) + if (!GeomLib::IsUTrimAllowed(aBAS.Surface(), umin, umax)) { umin = Max(aUmin, umin); umax = Min(aUmax, umax); } else { - if(umax - umin > aS->UPeriod()) + const Standard_Real aDelta = (umax - umin - aBAS.UPeriod()) / 2.0; + if (aBAS.IsUPeriodic() && (aDelta > 0.0)) { - Standard_Real delta = umax - umin - aS->UPeriod(); - umin += delta/2.; - umax -= delta/2; + umin += aDelta; + umax -= aDelta; } } // - if(!aS->IsVPeriodic()) + if (!GeomLib::IsVTrimAllowed(aBAS.Surface(), vmin, vmax)) { vmin = Max(aVmin, vmin); vmax = Min(aVmax, vmax); } else { - if(vmax - vmin > aS->VPeriod()) + const Standard_Real aDelta = (vmax - vmin - aS->VPeriod()) / 2.0; + if (aBAS.IsVPeriodic() && (aDelta > 0.0)) { - Standard_Real delta = vmax - vmin - aS->VPeriod(); - vmin += delta/2.; - vmax -= delta/2; + vmin += aDelta; + vmax -= aDelta; } } } diff --git a/src/BRepCheck/BRepCheck_Edge.cxx b/src/BRepCheck/BRepCheck_Edge.cxx index 9bc292a9e4..f110d420d8 100644 --- a/src/BRepCheck/BRepCheck_Edge.cxx +++ b/src/BRepCheck/BRepCheck_Edge.cxx @@ -193,6 +193,8 @@ void BRepCheck_Edge::Minimum() Standard_Real f = C3d->FirstParameter(), l = C3d->LastParameter(); if (C3d->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) { + // E.g. see "boolean bopfuse_complex J6" test script + const Handle(Geom_Curve)& aC = Handle(Geom_TrimmedCurve)::DownCast (C3d)->BasisCurve(); f = aC->FirstParameter(); l = aC->LastParameter(); @@ -233,6 +235,8 @@ void BRepCheck_Edge::Minimum() Standard_Real f = PCref->FirstParameter(), l = PCref->LastParameter(); if (PCref->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) { + // E.g. see "boolean bopfuse_complex J6" test script + const Handle(Geom2d_Curve)& aC = Handle(Geom2d_TrimmedCurve)::DownCast (PCref)->BasisCurve(); f = aC->FirstParameter(); l = aC->LastParameter(); @@ -369,6 +373,8 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S) Standard_Real fp = pc->FirstParameter(), lp = pc->LastParameter(); if (pc->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) { + // E.g. see "boolean bopfuse_complex J6" test script + const Handle(Geom2d_Curve)& aC = Handle(Geom2d_TrimmedCurve)::DownCast (pc)->BasisCurve(); fp = aC->FirstParameter(); lp = aC->LastParameter(); diff --git a/src/BRepClass/BRepClass_Intersector.cxx b/src/BRepClass/BRepClass_Intersector.cxx index 847d877329..a47bb03a61 100644 --- a/src/BRepClass/BRepClass_Intersector.cxx +++ b/src/BRepClass/BRepClass_Intersector.cxx @@ -142,13 +142,6 @@ void BRepClass_Intersector::Perform(const gp_Lin2d& L, } IntRes2d_Domain DE(pdeb,deb,toldeb,pfin,fin,tolfin); - // temporary periodic domain - if (C.Curve()->IsPeriodic()) { - DE.SetEquivalentParameters(C.FirstParameter(), - C.FirstParameter() + - C.Curve()->LastParameter() - - C.Curve()->FirstParameter()); - } Handle(Geom2d_Line) GL= new Geom2d_Line(L); Geom2dAdaptor_Curve CGA(GL); diff --git a/src/BRepFeat/BRepFeat_Form.cxx b/src/BRepFeat/BRepFeat_Form.cxx index bfea093c05..75706173a8 100644 --- a/src/BRepFeat/BRepFeat_Form.cxx +++ b/src/BRepFeat/BRepFeat_Form.cxx @@ -153,6 +153,7 @@ static void Descendants(const TopoDS_Shape&, TopTools_ListIteratorOfListOfShape it,it2; Standard_Integer sens = 0; + // Almost all curves in scur are trimmed curve (e.g. see LocOpe_DPrism::Curves(...)) TColGeom_SequenceOfCurve scur; Curves(scur); diff --git a/src/BRepFill/BRepFill_MultiLine.cxx b/src/BRepFill/BRepFill_MultiLine.cxx index da087a47c3..9db5d15f40 100644 --- a/src/BRepFill/BRepFill_MultiLine.cxx +++ b/src/BRepFill/BRepFill_MultiLine.cxx @@ -213,15 +213,20 @@ BRepFill_MultiLine::BRepFill_MultiLine(const TopoDS_Face& Face1, // try duplication GeomAdaptor_Surface GAS1(S); - GeomAbs_SurfaceType Type1 = GAS1.GetType(); - if ( UU1->IsPeriodic()) { + if (UU1->IsPeriodic() && UU1->IsClosed()) + { + // Period will be equal to (UU1->LastParameter()-UU1->FirstParameter()). + // Therefore, UU1 must be closed ElCLib::AdjustPeriodic(UU1->FirstParameter(), UU1->LastParameter(), Precision::PConfusion(), Umin, Umax); } - if ( VV1->IsPeriodic()) { + if (VV1->IsPeriodic() && VV1->IsClosed()) + { + // Period will be equal to (VV1->LastParameter()-VV1->FirstParameter()). + // Therefore, VV1 must be closed ElCLib::AdjustPeriodic(VV1->FirstParameter(), VV1->LastParameter(), Precision::PConfusion(), @@ -319,15 +324,20 @@ BRepFill_MultiLine::BRepFill_MultiLine(const TopoDS_Face& Face1, // try duplication GeomAdaptor_Surface GAS2(S); - GeomAbs_SurfaceType Type2 = GAS2.GetType(); - if ( UU2->IsPeriodic()) { + if (UU2->IsPeriodic() && UU2->IsClosed()) + { + // Period will be equal to (UU2->LastParameter()-UU2->FirstParameter()). + // Therefore, UU2 must be U-closed ElCLib::AdjustPeriodic(UU2->FirstParameter(), UU2->LastParameter(), Precision::PConfusion(), Umin, Umax); } - if ( VV2->IsPeriodic()) { + if (VV2->IsPeriodic() && VV2->IsClosed()) + { + // Period will be equal to (VV1->LastParameter()-VV1->FirstParameter()). + // Therefore, VV2 must be closed ElCLib::AdjustPeriodic(VV2->FirstParameter(), VV2->LastParameter(), Precision::PConfusion(), @@ -368,7 +378,8 @@ BRepFill_MultiLine::BRepFill_MultiLine(const TopoDS_Face& Face1, if ( myKPart == 1) myCont = GeomAbs_G1; - if ( (Type1 == GeomAbs_Plane) && (Type2 == GeomAbs_Plane)) { + if ((GAS1.GetType() == GeomAbs_Plane) && (GAS2.GetType() == GeomAbs_Plane)) + { myKPart = 2; } } diff --git a/src/BRepFill/BRepFill_OffsetWire.cxx b/src/BRepFill/BRepFill_OffsetWire.cxx index 876501e15e..c9cf023a33 100644 --- a/src/BRepFill/BRepFill_OffsetWire.cxx +++ b/src/BRepFill/BRepFill_OffsetWire.cxx @@ -100,6 +100,7 @@ #include #include #include +#include #include #ifdef OCCT_DEBUG @@ -1292,14 +1293,8 @@ void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfSh TopoDS_Vertex V1,V2; const Handle(Geom2d_Curve)& Bis = Bisec.Value(); - Standard_Boolean ForceAdd = Standard_False; - Handle(Geom2d_TrimmedCurve) aTC = Handle(Geom2d_TrimmedCurve)::DownCast(Bis); - if(!aTC.IsNull() && aTC->BasisCurve()->IsPeriodic()) - { - gp_Pnt2d Pf = Bis->Value(Bis->FirstParameter()); - gp_Pnt2d Pl = Bis->Value(Bis->LastParameter()); - ForceAdd = Pf.Distance(Pl) <= Precision::Confusion(); - } + const Standard_Boolean ForceAdd = (Bis->IsPeriodic() && + GeomLib::IsClosed(Bis, Precision::Confusion())); U1 = Bis->FirstParameter(); diff --git a/src/BRepLib/BRepLib.cxx b/src/BRepLib/BRepLib.cxx index f6006c5d38..d6100e85df 100644 --- a/src/BRepLib/BRepLib.cxx +++ b/src/BRepLib/BRepLib.cxx @@ -1283,30 +1283,21 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, Geom2dAdaptor_Curve& GAC2d = HC2d->ChangeCurve2d(); GeomAdaptor_Surface& GAS = HS->ChangeSurface(); - // modified by NIZHNY-OCC486 Tue Aug 27 17:15:13 2002 : - Standard_Boolean m_TrimmedPeriodical = Standard_False; - Handle(Standard_Type) TheType = C3d->DynamicType(); - if( TheType == STANDARD_TYPE(Geom_TrimmedCurve)) + if (C3d->IsPeriodic()) { - Handle(Geom_Curve) gtC (Handle(Geom_TrimmedCurve)::DownCast (C3d)->BasisCurve()); - m_TrimmedPeriodical = gtC->IsPeriodic(); + // Range of the curve cannot be greater than period. + // If it is greater then it must be reduced. + const Standard_Real aDelta = Max(l3d - f3d - C3d->Period(), 0.0)/2.0; + f3d += aDelta; + l3d -= aDelta; } - // modified by NIZHNY-OCC486 Tue Aug 27 17:15:17 2002 . - - if(!C3d->IsPeriodic()) { - Standard_Real Udeb = C3d->FirstParameter(); - Standard_Real Ufin = C3d->LastParameter(); - // modified by NIZHNY-OCC486 Tue Aug 27 17:17:14 2002 : - //if (Udeb > f3d) f3d = Udeb; - //if (l3d > Ufin) l3d = Ufin; - if(!m_TrimmedPeriodical) - { - if (Udeb > f3d) f3d = Udeb; - if (l3d > Ufin) l3d = Ufin; - } - // modified by NIZHNY-OCC486 Tue Aug 27 17:17:55 2002 . + if (!GeomLib::IsTrimAllowed(C3d, f3d, l3d)) + { + if (C3d->FirstParameter() > f3d) f3d = C3d->FirstParameter(); + if (l3d > C3d->LastParameter()) l3d = C3d->LastParameter(); } + if(!L3d.IsIdentity()){ C3d = Handle(Geom_Curve)::DownCast(C3d->Transformed(L3d.Transformation())); } diff --git a/src/BRepLib/BRepLib_MakeEdge.cxx b/src/BRepLib/BRepLib_MakeEdge.cxx index 6a3d8d52d6..5f725fafc9 100644 --- a/src/BRepLib/BRepLib_MakeEdge.cxx +++ b/src/BRepLib/BRepLib_MakeEdge.cxx @@ -768,13 +768,9 @@ void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& CC, const Standard_Real pp1, const Standard_Real pp2) { - // kill trimmed curves - Handle(Geom_Curve) C = CC; - Handle(Geom_TrimmedCurve) CT = Handle(Geom_TrimmedCurve)::DownCast(C); - while (!CT.IsNull()) { - C = CT->BasisCurve(); - CT = Handle(Geom_TrimmedCurve)::DownCast(C); - } + // kill trimmed curves to obtain First/Last-parameters of basis curve + const Handle(Geom_Curve) C = (CC->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) ? + Handle(Geom_TrimmedCurve)::DownCast(CC)->BasisCurve() : CC; // check parameters Standard_Real p1 = pp1; @@ -782,18 +778,18 @@ void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& CC, Standard_Real cf = C->FirstParameter(); Standard_Real cl = C->LastParameter(); Standard_Real epsilon = Precision::PConfusion(); - Standard_Boolean periodic = C->IsPeriodic(); GeomAdaptor_Curve aCA(C); TopoDS_Vertex V1,V2; - if (periodic) { + if (C->IsPeriodic()) + { // adjust in period ElCLib::AdjustPeriodic(cf,cl,epsilon,p1,p2); V1 = VV1; V2 = VV2; } else { - // reordonate + // reordinate if (p1 < p2) { V1 = VV1; V2 = VV2; @@ -801,9 +797,7 @@ void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& CC, else { V2 = VV1; V1 = VV2; - Standard_Real x = p1; - p1 = p2; - p2 = x; + std::swap(p1, p2); } // check range diff --git a/src/BRepLib/BRepLib_MakeShell.cxx b/src/BRepLib/BRepLib_MakeShell.cxx index c866cb7105..4f72560af7 100644 --- a/src/BRepLib/BRepLib_MakeShell.cxx +++ b/src/BRepLib/BRepLib_MakeShell.cxx @@ -90,17 +90,11 @@ void BRepLib_MakeShell::Init(const Handle(Geom_Surface)& S, const Standard_Real VMax, const Standard_Boolean Segment) { - Handle(Geom_Surface) BS = S; - if ( S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { - Handle(Geom_RectangularTrimmedSurface) RTS = - Handle(Geom_RectangularTrimmedSurface)::DownCast(S); - BS = RTS->BasisSurface(); - } myError = BRepLib_EmptyShell; Standard_Real tol = Precision::Confusion(); // Make a shell from a surface - GeomAdaptor_Surface GS(BS,UMin,UMax,VMin,VMax); + GeomAdaptor_Surface GS(S,UMin,UMax,VMin,VMax); Standard_Integer nu = GS.NbUIntervals(GeomAbs_C2); Standard_Integer nv = GS.NbVIntervals(GeomAbs_C2); @@ -182,6 +176,8 @@ void BRepLib_MakeShell::Init(const Handle(Geom_Surface)& S, } } + Handle(Geom_Surface) SS = Handle(Geom_Surface)::DownCast(GS.Surface()->Copy()); + for (iv = 1; iv <= nv; iv++) { // compute the first edge and vertices of the line @@ -222,7 +218,6 @@ void BRepLib_MakeShell::Init(const Handle(Geom_Surface)& S, // create the face at iu, iv // the surface - Handle(Geom_Surface) SS = Handle(Geom_Surface)::DownCast(BS->Copy()); if (GS.GetType() == GeomAbs_BSplineSurface && Segment) { Handle(Geom_BSplineSurface)::DownCast(SS) ->Segment(upars(iu),upars(iu+1), diff --git a/src/BRepMesh/BRepMesh_CurveTessellator.cxx b/src/BRepMesh/BRepMesh_CurveTessellator.cxx index d7e73f0f26..4757a816a9 100644 --- a/src/BRepMesh/BRepMesh_CurveTessellator.cxx +++ b/src/BRepMesh/BRepMesh_CurveTessellator.cxx @@ -233,6 +233,8 @@ Standard_Boolean BRepMesh_CurveTessellator::Value ( aSurface->GetType() != GeomAbs_BezierSurface && aSurface->GetType() != GeomAbs_OtherSurface) { + // For trimmed cone/cylinder. + // Return independently of the fact whether the surface trimmed. return Standard_True; } diff --git a/src/BRepMesh/BRepMesh_DefaultRangeSplitter.cxx b/src/BRepMesh/BRepMesh_DefaultRangeSplitter.cxx index a3307f36e5..11092e71b8 100644 --- a/src/BRepMesh/BRepMesh_DefaultRangeSplitter.cxx +++ b/src/BRepMesh/BRepMesh_DefaultRangeSplitter.cxx @@ -53,7 +53,8 @@ void BRepMesh_DefaultRangeSplitter::AdjustRange() { const Handle(BRepAdaptor_HSurface)& aSurface = GetSurface(); updateRange(aSurface->FirstUParameter(), aSurface->LastUParameter(), - aSurface->IsUPeriodic(), myRangeU.first, myRangeU.second); + aSurface->IsUPeriodic() && aSurface->IsUClosed(), + myRangeU.first, myRangeU.second); if (myRangeU.second < myRangeU.first) { @@ -62,7 +63,8 @@ void BRepMesh_DefaultRangeSplitter::AdjustRange() } updateRange(aSurface->FirstVParameter(), aSurface->LastVParameter(), - aSurface->IsVPeriodic(), myRangeV.first, myRangeV.second); + aSurface->IsVPeriodic() && aSurface->IsVClosed(), + myRangeV.first, myRangeV.second); if (myRangeV.second < myRangeV.first) { diff --git a/src/BRepOffset/BRepOffset_Inter2d.cxx b/src/BRepOffset/BRepOffset_Inter2d.cxx index 8d4d0c83c3..f4edec3d1b 100644 --- a/src/BRepOffset/BRepOffset_Inter2d.cxx +++ b/src/BRepOffset/BRepOffset_Inter2d.cxx @@ -951,6 +951,9 @@ void BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E,TopoDS_Edge& NE, const if (theCurve->IsKind(STANDARD_TYPE(Geom2d_BoundedCurve)) && (FirstPar > anEf - a2Offset || LastPar < anEl + a2Offset)) { + // Trimmed curves or periodic B-spline curves are processed + // in this branch. + Handle(Geom2d_Curve) NewPCurve; if (ExtendPCurve(theCurve, anEf, anEl, a2Offset, NewPCurve)) { diff --git a/src/BRepOffset/BRepOffset_Tool.cxx b/src/BRepOffset/BRepOffset_Tool.cxx index e8965ecf71..62efc05461 100644 --- a/src/BRepOffset/BRepOffset_Tool.cxx +++ b/src/BRepOffset/BRepOffset_Tool.cxx @@ -252,11 +252,8 @@ static void PutInBounds (const TopoDS_Face& F, BRep_Tool::Range(E,f,l); TopLoc_Location L; // Recup S avec la location pour eviter la copie. - Handle (Geom_Surface) S = BRep_Tool::Surface(F,L); + const Handle (Geom_Surface) &S = BRep_Tool::Surface(F,L); - if (S->IsInstance(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { - S = Handle(Geom_RectangularTrimmedSurface)::DownCast (S)->BasisSurface(); - } //--------------- // Recadre en U. //--------------- @@ -908,7 +905,7 @@ static Standard_Boolean AreConnex(const TopoDS_Wire& W1, if (V11.IsSame(V21) || V11.IsSame(V22) || V12.IsSame(V21) || V12.IsSame(V22)) - return Standard_True; + return Standard_True; return Standard_False; } @@ -1248,8 +1245,8 @@ static TopoDS_Edge Glue(const TopoDS_Edge& E1, //======================================================================= static void CheckIntersFF(const BOPDS_PDS& pDS, - const TopoDS_Edge& RefEdge, - TopTools_IndexedMapOfShape& TrueEdges) + const TopoDS_Edge& RefEdge, + TopTools_IndexedMapOfShape& TrueEdges) { BOPDS_VectorOfInterfFF& aFFs = pDS->InterfFF(); Standard_Integer aNb = aFFs.Length(); @@ -1260,33 +1257,33 @@ static void CheckIntersFF(const BOPDS_PDS& pDS, BB.MakeCompound(Edges); for (i = 0; i < aNb; ++i) - { - BOPDS_InterfFF& aFFi=aFFs(i); - const BOPDS_VectorOfCurve& aBCurves=aFFi.Curves(); - Standard_Integer aNbCurves = aBCurves.Length(); - - for (j = 0; j < aNbCurves; ++j) { - const BOPDS_Curve& aBC=aBCurves(j); - const BOPDS_ListOfPaveBlock& aSectEdges = aBC.PaveBlocks(); - - BOPDS_ListIteratorOfListOfPaveBlock aPBIt; - aPBIt.Initialize(aSectEdges); + BOPDS_InterfFF& aFFi=aFFs(i); + const BOPDS_VectorOfCurve& aBCurves=aFFi.Curves(); + Standard_Integer aNbCurves = aBCurves.Length(); - for (; aPBIt.More(); aPBIt.Next()) - { - const Handle(BOPDS_PaveBlock)& aPB = aPBIt.Value(); - Standard_Integer nSect = aPB->Edge(); - const TopoDS_Edge& anEdge = *(TopoDS_Edge*)&pDS->Shape(nSect); + for (j = 0; j < aNbCurves; ++j) + { + const BOPDS_Curve& aBC=aBCurves(j); + const BOPDS_ListOfPaveBlock& aSectEdges = aBC.PaveBlocks(); + + BOPDS_ListIteratorOfListOfPaveBlock aPBIt; + aPBIt.Initialize(aSectEdges); + + for (; aPBIt.More(); aPBIt.Next()) + { + const Handle(BOPDS_PaveBlock)& aPB = aPBIt.Value(); + Standard_Integer nSect = aPB->Edge(); + const TopoDS_Edge& anEdge = *(TopoDS_Edge*)&pDS->Shape(nSect); BB.Add(Edges, anEdge); - nbe++; - } + nbe++; + } + } } - } if (nbe == 0) return; - + TopTools_ListOfShape CompList; BOPTools_AlgoTools::MakeConnexityBlocks(Edges, TopAbs_VERTEX, TopAbs_EDGE, CompList); @@ -1294,115 +1291,115 @@ static void CheckIntersFF(const BOPDS_PDS& pDS, if (CompList.Extent() == 1) NearestCompound = CompList.First(); else - { + { BRepAdaptor_Curve BAcurve(RefEdge); gp_Pnt Pref = BAcurve.Value((BAcurve.FirstParameter()+BAcurve.LastParameter())/2); TopoDS_Vertex Vref = BRepLib_MakeVertex(Pref); Standard_Real MinDist = RealLast(); TopTools_ListIteratorOfListOfShape itl(CompList); for (; itl.More(); itl.Next()) - { + { const TopoDS_Shape& aCompound = itl.Value(); - + BRepExtrema_DistShapeShape Projector(Vref, aCompound); if (!Projector.IsDone() || Projector.NbSolution() == 0) continue; - + Standard_Real aDist = Projector.Value(); if (aDist < MinDist) - { + { MinDist = aDist; NearestCompound = aCompound; } } - } + } TopExp::MapShapes(NearestCompound, TopAbs_EDGE, TrueEdges); -} - + } + //======================================================================= //function : AssembleEdge //purpose : //======================================================================= static TopoDS_Edge AssembleEdge(const BOPDS_PDS& pDS, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const Standard_Boolean addPCurve1, - const Standard_Boolean addPCurve2, - const TopTools_SequenceOfShape& EdgesForConcat) + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const Standard_Boolean addPCurve1, + const Standard_Boolean addPCurve2, + const TopTools_SequenceOfShape& EdgesForConcat) { TopoDS_Edge NullEdge; TopoDS_Edge CurEdge = TopoDS::Edge( EdgesForConcat(1) ); Standard_Real aGlueTol = Precision::Confusion(); for (Standard_Integer j = 2; j <= EdgesForConcat.Length(); j++) - { - TopoDS_Edge anEdge = TopoDS::Edge( EdgesForConcat(j) ); - Standard_Boolean After = Standard_False; - TopoDS_Vertex Vfirst, Vlast; + { + TopoDS_Edge anEdge = TopoDS::Edge( EdgesForConcat(j) ); + Standard_Boolean After = Standard_False; + TopoDS_Vertex Vfirst, Vlast; Standard_Boolean AreClosedWire = AreClosed( CurEdge, anEdge ); if (AreClosedWire) - { - TopoDS_Vertex V1, V2; - TopExp::Vertices( CurEdge, V1, V2 ); + { + TopoDS_Vertex V1, V2; + TopExp::Vertices( CurEdge, V1, V2 ); Standard_Boolean IsAutonomV1 = IsAutonomVertex( V1, pDS, F1, F2 ); Standard_Boolean IsAutonomV2 = IsAutonomVertex( V2, pDS, F1, F2 ); if (IsAutonomV1) - { - After = Standard_False; - Vfirst = Vlast = V2; - } + { + After = Standard_False; + Vfirst = Vlast = V2; + } else if (IsAutonomV2) - { - After = Standard_True; - Vfirst = Vlast = V1; - } + { + After = Standard_True; + Vfirst = Vlast = V1; + } else return NullEdge; - } - else - { - TopoDS_Vertex CV, V11, V12, V21, V22; - TopExp::CommonVertex( CurEdge, anEdge, CV ); + } + else + { + TopoDS_Vertex CV, V11, V12, V21, V22; + TopExp::CommonVertex( CurEdge, anEdge, CV ); Standard_Boolean IsAutonomCV = IsAutonomVertex( CV, pDS, F1, F2 ); if (IsAutonomCV) { - aGlueTol = BRep_Tool::Tolerance(CV); - TopExp::Vertices( CurEdge, V11, V12 ); - TopExp::Vertices( anEdge, V21, V22 ); - if (V11.IsSame(CV) && V21.IsSame(CV)) - { - Vfirst = V22; - Vlast = V12; - } - else if (V11.IsSame(CV) && V22.IsSame(CV)) - { - Vfirst = V21; - Vlast = V12; - } - else if (V12.IsSame(CV) && V21.IsSame(CV)) - { - Vfirst = V11; - Vlast = V22; - } - else - { - Vfirst = V11; - Vlast = V21; - } + aGlueTol = BRep_Tool::Tolerance(CV); + TopExp::Vertices( CurEdge, V11, V12 ); + TopExp::Vertices( anEdge, V21, V22 ); + if (V11.IsSame(CV) && V21.IsSame(CV)) + { + Vfirst = V22; + Vlast = V12; + } + else if (V11.IsSame(CV) && V22.IsSame(CV)) + { + Vfirst = V21; + Vlast = V12; + } + else if (V12.IsSame(CV) && V21.IsSame(CV)) + { + Vfirst = V11; + Vlast = V22; + } + else + { + Vfirst = V11; + Vlast = V21; + } } else return NullEdge; - } //end of else (open wire) - - TopoDS_Edge NewEdge = Glue(CurEdge, anEdge, Vfirst, Vlast, After, - F1, addPCurve1, F2, addPCurve2, aGlueTol); + } //end of else (open wire) + + TopoDS_Edge NewEdge = Glue(CurEdge, anEdge, Vfirst, Vlast, After, + F1, addPCurve1, F2, addPCurve2, aGlueTol); if (NewEdge.IsNull()) return NullEdge; else CurEdge = NewEdge; - } //end of for (Standard_Integer j = 2; j <= EdgesForConcat.Length(); j++) + } //end of for (Standard_Integer j = 2; j <= EdgesForConcat.Length(); j++) return CurEdge; } @@ -1500,24 +1497,14 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, Standard_Real f, l; const Handle(Geom_Curve)& aC3DE = BRep_Tool::Curve(anEdge, f, l); - Handle(Geom_TrimmedCurve) aC3DETrim; - if(!aC3DE.IsNull()) - aC3DETrim = new Geom_TrimmedCurve(aC3DE, f, l); - Standard_Real aTolEdge = BRep_Tool::Tolerance(anEdge); if (!BOPTools_AlgoTools2D::HasCurveOnSurface(anEdge, F1)) { Handle(Geom2d_Curve) aC2d = aBC.Curve().FirstCurve2d(); - if(!aC3DETrim.IsNull()) { + if (!aC3DE.IsNull()) { Handle(Geom2d_Curve) aC2dNew; - - if(aC3DE->IsPeriodic()) { BOPTools_AlgoTools2D::AdjustPCurveOnFace(F1, f, l, aC2d, aC2dNew, aContext); - } - else { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(F1, aC3DETrim, aC2d, aC2dNew, aContext); - } aC2d = aC2dNew; } BB.UpdateEdge(anEdge, aC2d, F1, aTolEdge); @@ -1525,15 +1512,9 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, if (!BOPTools_AlgoTools2D::HasCurveOnSurface(anEdge, F2)) { Handle(Geom2d_Curve) aC2d = aBC.Curve().SecondCurve2d(); - if(!aC3DETrim.IsNull()) { + if (!aC3DE.IsNull()) { Handle(Geom2d_Curve) aC2dNew; - - if(aC3DE->IsPeriodic()) { BOPTools_AlgoTools2D::AdjustPCurveOnFace(F2, f, l, aC2d, aC2dNew, aContext); - } - else { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(F2, aC3DETrim, aC2d, aC2dNew, aContext); - } aC2d = aC2dNew; } BB.UpdateEdge(anEdge, aC2d, F2, aTolEdge); @@ -1582,11 +1563,11 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, if (L1.Extent() > 1 && (!isEl1 || !isEl2)) { TopTools_SequenceOfShape eseq; TopTools_SequenceOfShape EdgesForConcat; - + if (!TrueEdges.IsEmpty()) - { - for (i = TrueEdges.Extent(); i >= 1; i--) - EdgesForConcat.Append( TrueEdges(i) ); + { + for (i = TrueEdges.Extent(); i >= 1; i--) + EdgesForConcat.Append( TrueEdges(i) ); TopoDS_Edge AssembledEdge = AssembleEdge( pDS, F1, F2, addPCurve1, addPCurve2, EdgesForConcat ); if (AssembledEdge.IsNull()) @@ -1594,145 +1575,145 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, eseq.Append( TrueEdges(i) ); else eseq.Append(AssembledEdge); - } + } else - { - TopTools_SequenceOfShape wseq; - TopTools_SequenceOfShape edges; - TopTools_ListIteratorOfListOfShape itl(L1); - for (; itl.More(); itl.Next()) - edges.Append( itl.Value() ); - while (!edges.IsEmpty()) { - TopoDS_Edge anEdge = TopoDS::Edge( edges.First() ); + TopTools_SequenceOfShape wseq; + TopTools_SequenceOfShape edges; + TopTools_ListIteratorOfListOfShape itl(L1); + for (; itl.More(); itl.Next()) + edges.Append( itl.Value() ); + while (!edges.IsEmpty()) + { + TopoDS_Edge anEdge = TopoDS::Edge( edges.First() ); TopoDS_Wire aWire, resWire; BB.MakeWire(aWire); BB.Add( aWire, anEdge ); - TColStd_SequenceOfInteger Candidates; - for (k = 1; k <= wseq.Length(); k++) - { - resWire = TopoDS::Wire(wseq(k)); + TColStd_SequenceOfInteger Candidates; + for (k = 1; k <= wseq.Length(); k++) + { + resWire = TopoDS::Wire(wseq(k)); if (AreConnex( resWire, aWire )) - { - Candidates.Append( 1 ); - break; - } - } - if (Candidates.IsEmpty()) - { - wseq.Append( aWire ); - edges.Remove(1); - } - else - { - for (j = 2; j <= edges.Length(); j++) - { - anEdge = TopoDS::Edge( edges(j) ); + { + Candidates.Append( 1 ); + break; + } + } + if (Candidates.IsEmpty()) + { + wseq.Append( aWire ); + edges.Remove(1); + } + else + { + for (j = 2; j <= edges.Length(); j++) + { + anEdge = TopoDS::Edge( edges(j) ); aWire.Nullify(); BB.MakeWire(aWire); BB.Add( aWire, anEdge ); if (AreConnex( resWire, aWire )) - Candidates.Append( j ); - } - Standard_Integer minind = 1; - if (Candidates.Length() > 1) - { - Standard_Real MinAngle = RealLast(); - for (j = 1; j <= Candidates.Length(); j++) - { - anEdge = TopoDS::Edge( edges(Candidates(j)) ); - Standard_Real anAngle = AngleWireEdge( resWire, anEdge ); - if (anAngle < MinAngle) - { - MinAngle = anAngle; - minind = j; - } - } - } + Candidates.Append( j ); + } + Standard_Integer minind = 1; + if (Candidates.Length() > 1) + { + Standard_Real MinAngle = RealLast(); + for (j = 1; j <= Candidates.Length(); j++) + { + anEdge = TopoDS::Edge( edges(Candidates(j)) ); + Standard_Real anAngle = AngleWireEdge( resWire, anEdge ); + if (anAngle < MinAngle) + { + MinAngle = anAngle; + minind = j; + } + } + } BB.Add( resWire, TopoDS::Edge(edges(Candidates(minind))) ); wseq(k) = resWire; - edges.Remove(Candidates(minind)); - } - } //end of while (!edges.IsEmpty()) - - for (i = 1; i <= wseq.Length(); i++) - { - TopoDS_Wire aWire = TopoDS::Wire(wseq(i)); - TopTools_SequenceOfShape aLocalEdgesForConcat; - if (aWire.Closed()) - { - TopoDS_Vertex StartVertex; - TopoDS_Edge StartEdge; - Standard_Boolean StartFound = Standard_False; - TopTools_ListOfShape Elist; - - TopoDS_Iterator itw(aWire); - for (; itw.More(); itw.Next()) - { - TopoDS_Edge anEdge = TopoDS::Edge(itw.Value()); - if (StartFound) - Elist.Append(anEdge); - else - { - TopoDS_Vertex V1, V2; - TopExp::Vertices( anEdge, V1, V2 ); - if (!IsAutonomVertex( V1, pDS )) - { - StartVertex = V2; - StartEdge = anEdge; - StartFound = Standard_True; - } - else if (!IsAutonomVertex( V2, pDS )) - { - StartVertex = V1; - StartEdge = anEdge; - StartFound = Standard_True; - } - else - Elist.Append(anEdge); - } - } //end of for (; itw.More(); itw.Next()) - if (!StartFound) - { - itl.Initialize(Elist); - StartEdge = TopoDS::Edge(itl.Value()); - Elist.Remove(itl); - TopoDS_Vertex V1, V2; - TopExp::Vertices( StartEdge, V1, V2 ); - StartVertex = V1; - } - aLocalEdgesForConcat.Append( StartEdge ); - while (!Elist.IsEmpty()) - { - for (itl.Initialize(Elist); itl.More(); itl.Next()) - { - TopoDS_Edge anEdge = TopoDS::Edge(itl.Value()); - TopoDS_Vertex V1, V2; - TopExp::Vertices( anEdge, V1, V2 ); - if (V1.IsSame(StartVertex)) - { - StartVertex = V2; - aLocalEdgesForConcat.Append( anEdge ); - Elist.Remove(itl); - break; - } - else if (V2.IsSame(StartVertex)) - { - StartVertex = V1; - aLocalEdgesForConcat.Append( anEdge ); - Elist.Remove(itl); - break; - } - } - } //end of while (!Elist.IsEmpty()) - } //end of if (aWire.Closed()) - else - { - BRepTools_WireExplorer Wexp( aWire ); - for (; Wexp.More(); Wexp.Next()) - aLocalEdgesForConcat.Append( Wexp.Current() ); - } + edges.Remove(Candidates(minind)); + } + } //end of while (!edges.IsEmpty()) + for (i = 1; i <= wseq.Length(); i++) + { + TopoDS_Wire aWire = TopoDS::Wire(wseq(i)); + TopTools_SequenceOfShape aLocalEdgesForConcat; + if (aWire.Closed()) + { + TopoDS_Vertex StartVertex; + TopoDS_Edge StartEdge; + Standard_Boolean StartFound = Standard_False; + TopTools_ListOfShape Elist; + + TopoDS_Iterator itw(aWire); + for (; itw.More(); itw.Next()) + { + TopoDS_Edge anEdge = TopoDS::Edge(itw.Value()); + if (StartFound) + Elist.Append(anEdge); + else + { + TopoDS_Vertex V1, V2; + TopExp::Vertices( anEdge, V1, V2 ); + if (!IsAutonomVertex( V1, pDS )) + { + StartVertex = V2; + StartEdge = anEdge; + StartFound = Standard_True; + } + else if (!IsAutonomVertex( V2, pDS )) + { + StartVertex = V1; + StartEdge = anEdge; + StartFound = Standard_True; + } + else + Elist.Append(anEdge); + } + } //end of for (; itw.More(); itw.Next()) + if (!StartFound) + { + itl.Initialize(Elist); + StartEdge = TopoDS::Edge(itl.Value()); + Elist.Remove(itl); + TopoDS_Vertex V1, V2; + TopExp::Vertices( StartEdge, V1, V2 ); + StartVertex = V1; + } + aLocalEdgesForConcat.Append( StartEdge ); + while (!Elist.IsEmpty()) + { + for (itl.Initialize(Elist); itl.More(); itl.Next()) + { + TopoDS_Edge anEdge = TopoDS::Edge(itl.Value()); + TopoDS_Vertex V1, V2; + TopExp::Vertices( anEdge, V1, V2 ); + if (V1.IsSame(StartVertex)) + { + StartVertex = V2; + aLocalEdgesForConcat.Append( anEdge ); + Elist.Remove(itl); + break; + } + else if (V2.IsSame(StartVertex)) + { + StartVertex = V1; + aLocalEdgesForConcat.Append( anEdge ); + Elist.Remove(itl); + break; + } + } + } //end of while (!Elist.IsEmpty()) + } //end of if (aWire.Closed()) + else + { + BRepTools_WireExplorer Wexp( aWire ); + for (; Wexp.More(); Wexp.Next()) + aLocalEdgesForConcat.Append( Wexp.Current() ); + } + TopoDS_Edge AssembledEdge = AssembleEdge( pDS, F1, F2, addPCurve1, addPCurve2, aLocalEdgesForConcat ); if (AssembledEdge.IsNull()) @@ -1740,56 +1721,56 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, eseq.Append( aLocalEdgesForConcat(j) ); else eseq.Append( AssembledEdge ); - } - } //end of else (when TrueEdges is empty) + } + } //end of else (when TrueEdges is empty) if (eseq.Length() < L1.Extent()) - { - L1.Clear(); - L2.Clear(); - for (i = 1; i <= eseq.Length(); i++) { + L1.Clear(); + L2.Clear(); + for (i = 1; i <= eseq.Length(); i++) + { TopoDS_Shape aShape = eseq(i); - TopoDS_Edge anEdge = TopoDS::Edge(eseq(i)); - BRepLib::SameParameter(anEdge, aSameParTol, Standard_True); - Standard_Real EdgeTol = BRep_Tool::Tolerance(anEdge); + TopoDS_Edge anEdge = TopoDS::Edge(eseq(i)); + BRepLib::SameParameter(anEdge, aSameParTol, Standard_True); + Standard_Real EdgeTol = BRep_Tool::Tolerance(anEdge); #ifdef OCCT_DEBUG - cout<<"Tolerance of glued E = "<BasisCurve(); IsPeriodic = aC->IsPeriodic(); fr = aC->FirstParameter(); diff --git a/src/BRepTools/BRepTools.cxx b/src/BRepTools/BRepTools.cxx index 7572bdc0e8..36aa90594a 100644 --- a/src/BRepTools/BRepTools.cxx +++ b/src/BRepTools/BRepTools.cxx @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -1020,12 +1021,32 @@ Standard_Real BRepTools::EvalAndUpdateTol(const TopoDS_Edge& theE, //Set first, last to avoid ErrosStatus = 2 because of //too strong checking of limits in class CheckCurveOnSurface // - if(!C3d->IsPeriodic()) + + if (C3d->IsPeriodic()) + { + // Range of the curve cannot be greater than period. + // If it is greater then it must be reduced. + const Standard_Real aDelta = Max(last - first - C3d->Period(), 0.0)/2.0; + first += aDelta; + last -= aDelta; + } + + if (C2d->IsPeriodic()) + { + // Range of the curve cannot be greater than period. + // If it is greater then it must be reduced. + const Standard_Real aDelta = Max(last - first - C2d->Period(), 0.0)/2.0; + first += aDelta; + last -= aDelta; + } + + if (!GeomLib::IsTrimAllowed(C3d, first, last)) { first = Max(first, C3d->FirstParameter()); last = Min(last, C3d->LastParameter()); } - if(!C2d->IsPeriodic()) + + if (!GeomLib::IsTrimAllowed(C2d, first, last)) { first = Max(first, C2d->FirstParameter()); last = Min(last, C2d->LastParameter()); diff --git a/src/BRepTools/BRepTools_NurbsConvertModification.cxx b/src/BRepTools/BRepTools_NurbsConvertModification.cxx index 1a8de56f7e..bf6fb26b5f 100644 --- a/src/BRepTools/BRepTools_NurbsConvertModification.cxx +++ b/src/BRepTools/BRepTools_NurbsConvertModification.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -386,9 +387,11 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d C2d = TC->BasisCurve(); } - Standard_Real fc = C2d->FirstParameter(), lc = C2d->LastParameter(); + const Standard_Real fc = C2d->FirstParameter(), + lc = C2d->LastParameter(); - if(!C2d->IsPeriodic()) { + if (!GeomLib::IsTrimAllowed(C2d, f2d, l2d)) + { if(fc - f2d > Precision::PConfusion()) f2d = fc; if(l2d - lc > Precision::PConfusion()) l2d = lc; } diff --git a/src/BRepTools/BRepTools_TrsfModification.cxx b/src/BRepTools/BRepTools_TrsfModification.cxx index 6bc92499cd..8e23cfa483 100644 --- a/src/BRepTools/BRepTools_TrsfModification.cxx +++ b/src/BRepTools/BRepTools_TrsfModification.cxx @@ -175,21 +175,22 @@ Standard_Boolean BRepTools_TrsfModification::NewCurve2d NewC = TC->BasisCurve(); } - Standard_Real fc = NewC->FirstParameter(), lc = NewC->LastParameter(); - - if(!NewC->IsPeriodic()) { + const Standard_Real fc = NewC->FirstParameter(), lc = NewC->LastParameter(); + if (!GeomLib::IsTrimAllowed(NewC, f, l)) + { if(fc - f > Precision::PConfusion()) f = fc; if(l - lc > Precision::PConfusion()) l = lc; - if(Abs(l - f) < Precision::PConfusion()) + } + + if (!NewC->IsPeriodic() && (Abs(l - f) < Precision::PConfusion())) + { + if(Abs(f - fc) < Precision::PConfusion()) + { + l = lc; + } + else { - if(Abs(f - fc) < Precision::PConfusion()) - { - l = lc; - } - else - { - f = fc; - } + f = fc; } } diff --git a/src/BiTgte/BiTgte_CurveOnEdge.cxx b/src/BiTgte/BiTgte_CurveOnEdge.cxx index e11288421e..a103010137 100644 --- a/src/BiTgte/BiTgte_CurveOnEdge.cxx +++ b/src/BiTgte/BiTgte_CurveOnEdge.cxx @@ -178,29 +178,6 @@ Standard_Boolean BiTgte_CurveOnEdge::IsClosed() const throw Standard_NotImplemented("BiTgte_CurveOnEdge"); } - -//======================================================================= -//function : -//purpose : -//======================================================================= - -Standard_Boolean BiTgte_CurveOnEdge::IsPeriodic() const -{ - throw Standard_NotImplemented("BiTgte_CurveOnEdge"); -} - - -//======================================================================= -//function : -//purpose : -//======================================================================= - -Standard_Real BiTgte_CurveOnEdge::Period() const -{ - throw Standard_NotImplemented("BiTgte_CurveOnEdge"); -} - - //======================================================================= //function : //purpose : diff --git a/src/BiTgte/BiTgte_CurveOnEdge.hxx b/src/BiTgte/BiTgte_CurveOnEdge.hxx index 2dd590986c..8f52b1e57f 100644 --- a/src/BiTgte/BiTgte_CurveOnEdge.hxx +++ b/src/BiTgte/BiTgte_CurveOnEdge.hxx @@ -87,10 +87,6 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; - //! Computes the point of parameter U on the curve. Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE; diff --git a/src/BiTgte/BiTgte_CurveOnVertex.cxx b/src/BiTgte/BiTgte_CurveOnVertex.cxx index 2bdf0a204e..60a57be547 100644 --- a/src/BiTgte/BiTgte_CurveOnVertex.cxx +++ b/src/BiTgte/BiTgte_CurveOnVertex.cxx @@ -151,29 +151,6 @@ Standard_Boolean BiTgte_CurveOnVertex::IsClosed() const throw Standard_NotImplemented("BiTgte_CurveOnVertex"); } - -//======================================================================= -//function : -//purpose : -//======================================================================= - -Standard_Boolean BiTgte_CurveOnVertex::IsPeriodic() const -{ - throw Standard_NotImplemented("BiTgte_CurveOnVertex"); -} - - -//======================================================================= -//function : -//purpose : -//======================================================================= - -Standard_Real BiTgte_CurveOnVertex::Period() const -{ - throw Standard_NotImplemented("BiTgte_CurveOnVertex"); -} - - //======================================================================= //function : //purpose : diff --git a/src/BiTgte/BiTgte_CurveOnVertex.hxx b/src/BiTgte/BiTgte_CurveOnVertex.hxx index 914bdd52a5..c703d974af 100644 --- a/src/BiTgte/BiTgte_CurveOnVertex.hxx +++ b/src/BiTgte/BiTgte_CurveOnVertex.hxx @@ -86,10 +86,6 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; - //! Computes the point of parameter U on the curve. Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE; diff --git a/src/BinTools/BinTools_Curve2dSet.cxx b/src/BinTools/BinTools_Curve2dSet.cxx index 0f34bf736c..1003ab6697 100644 --- a/src/BinTools/BinTools_Curve2dSet.cxx +++ b/src/BinTools/BinTools_Curve2dSet.cxx @@ -237,9 +237,9 @@ static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_B static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom2d_BSplineCurve)& B) { OS << (Standard_Byte)BSPLINE; - Standard_Boolean aRational = B->IsRational() ? 1:0; + Standard_Boolean aRational = B->IsRational() ? Standard_True : Standard_False; BinTools::PutBool(OS, aRational); //rational - Standard_Boolean aPeriodic = B->IsPeriodic() ? 1:0; + Standard_Boolean aPeriodic = B->IsPeriodic() ? Standard_True : Standard_False; BinTools::PutBool(OS, aPeriodic); //periodic // poles and weights Standard_Integer i,aDegree,aNbPoles,aNbKnots; diff --git a/src/BinTools/BinTools_CurveSet.cxx b/src/BinTools/BinTools_CurveSet.cxx index 7f89e62b0d..751af40c74 100644 --- a/src/BinTools/BinTools_CurveSet.cxx +++ b/src/BinTools/BinTools_CurveSet.cxx @@ -250,9 +250,9 @@ static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_Bez static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_BSplineCurve)& B) { OS << (Standard_Byte)BSPLINE; - Standard_Boolean aRational = B->IsRational() ? 1:0; + Standard_Boolean aRational = B->IsRational() ? Standard_True : Standard_False; BinTools::PutBool(OS, aRational); //rational - Standard_Boolean aPeriodic = B->IsPeriodic() ? 1:0; + Standard_Boolean aPeriodic = B->IsPeriodic() ? Standard_True : Standard_False; BinTools::PutBool(OS, aPeriodic); //periodic // poles and weights Standard_Integer i,aDegree,aNbPoles,aNbKnots; diff --git a/src/BinTools/BinTools_SurfaceSet.cxx b/src/BinTools/BinTools_SurfaceSet.cxx index c43fe79f79..c43e8b67ee 100644 --- a/src/BinTools/BinTools_SurfaceSet.cxx +++ b/src/BinTools/BinTools_SurfaceSet.cxx @@ -298,10 +298,10 @@ static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_Bez static Standard_OStream& operator <<(Standard_OStream& OS, const Handle(Geom_BSplineSurface)& S) { OS << (Standard_Byte)BSPLINE; - Standard_Boolean urational = S->IsURational() ? 1:0; - Standard_Boolean vrational = S->IsVRational() ? 1:0; - Standard_Boolean uperiodic = S->IsUPeriodic() ? 1:0; - Standard_Boolean vperiodic = S->IsVPeriodic() ? 1:0; + Standard_Boolean urational = S->IsURational() ? Standard_True : Standard_False; + Standard_Boolean vrational = S->IsVRational() ? Standard_True : Standard_False; + Standard_Boolean uperiodic = S->IsUPeriodic() ? Standard_True : Standard_False; + Standard_Boolean vperiodic = S->IsVPeriodic() ? Standard_True : Standard_False; BinTools::PutBool(OS, urational); BinTools::PutBool(OS, vrational); BinTools::PutBool(OS, uperiodic); diff --git a/src/Bisector/Bisector_BisecAna.cxx b/src/Bisector/Bisector_BisecAna.cxx index 6e5330d7ec..115521a308 100644 --- a/src/Bisector/Bisector_BisecAna.cxx +++ b/src/Bisector/Bisector_BisecAna.cxx @@ -1398,7 +1398,16 @@ Standard_Boolean Bisector_BisecAna::IsClosed() const //============================================================================= Standard_Boolean Bisector_BisecAna::IsPeriodic() const { - return thebisector->BasisCurve()->IsPeriodic(); + return thebisector->IsPeriodic(); +} + +//============================================================================= +//function : Period +//purpose : +//============================================================================= +Standard_Real Bisector_BisecAna::Period() const +{ + return thebisector->Period(); } //============================================================================= diff --git a/src/Bisector/Bisector_BisecAna.hxx b/src/Bisector/Bisector_BisecAna.hxx index fbc0b8a21d..0766593379 100644 --- a/src/Bisector/Bisector_BisecAna.hxx +++ b/src/Bisector/Bisector_BisecAna.hxx @@ -104,8 +104,12 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the curve is periodic Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns the value of the period + Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; + Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE; diff --git a/src/Bisector/Bisector_BisecCC.hxx b/src/Bisector/Bisector_BisecCC.hxx index 8340c0f76c..00bd8a39c2 100644 --- a/src/Bisector/Bisector_BisecCC.hxx +++ b/src/Bisector/Bisector_BisecCC.hxx @@ -127,6 +127,7 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns FALSE Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; //! Returns the point of parameter U. diff --git a/src/Bisector/Bisector_BisecPC.hxx b/src/Bisector/Bisector_BisecPC.hxx index a748e7e4f5..b3b02425d3 100644 --- a/src/Bisector/Bisector_BisecPC.hxx +++ b/src/Bisector/Bisector_BisecPC.hxx @@ -132,6 +132,7 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns FALSE Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; //! Returns the distance between the point of diff --git a/src/ChFi2d/ChFi2d_FilletAlgo.cxx b/src/ChFi2d/ChFi2d_FilletAlgo.cxx index 0eff8be730..ca439cecc6 100644 --- a/src/ChFi2d/ChFi2d_FilletAlgo.cxx +++ b/src/ChFi2d/ChFi2d_FilletAlgo.cxx @@ -122,10 +122,15 @@ void ChFi2d_FilletAlgo::Init(const TopoDS_Edge& theEdge1, myCurve1 = GeomProjLib::Curve2d(aCurve1, myStart1, myEnd1, myPlane); myCurve2 = GeomProjLib::Curve2d(aCurve2, myStart2, myEnd2, myPlane); - while (myCurve1->IsPeriodic() && myStart1 >= myEnd1) - myEnd1 += myCurve1->Period(); - while (myCurve2->IsPeriodic() && myStart2 >= myEnd2) - myEnd2 += myCurve2->Period(); + if(myCurve1->IsPeriodic() && myStart1 >= myEnd1) + { + myEnd1 = ElCLib::InPeriod(myEnd1, myStart1, myStart1 + myCurve1->Period()); + } + + if(myCurve2->IsPeriodic() && myStart2 >= myEnd2) + { + myEnd2 = ElCLib::InPeriod(myEnd2, myStart2, myStart2 + myCurve2->Period()); + } if (aBAC1.GetType() == aBAC2.GetType()) { @@ -267,8 +272,10 @@ void ChFi2d_FilletAlgo::FillPoint(FilletPoint* thePoint, const Standard_Real the // checking the right parameter Standard_Real aParamProj = aProj.Parameter(a); - while(myCurve2->IsPeriodic() && aParamProj < myStart2) - aParamProj += myCurve2->Period(); + if(myCurve2->IsPeriodic() && aParamProj < myStart2) + { + aParamProj = ElCLib::InPeriod(aParamProj, myStart2, myStart2 + myCurve2->Period()); + } const Standard_Real d = aProj.Distance(a); thePoint->appendValue(d * d - myRadius * myRadius, (aParamProj >= myStart2 && aParamProj <= myEnd2 && aValid2)); diff --git a/src/ChFi3d/ChFi3d_Builder_0.cxx b/src/ChFi3d/ChFi3d_Builder_0.cxx index 1d92766f8e..414d96ff52 100644 --- a/src/ChFi3d/ChFi3d_Builder_0.cxx +++ b/src/ChFi3d/ChFi3d_Builder_0.cxx @@ -585,10 +585,7 @@ void ChFi3d_BoundSrf(GeomAdaptor_Surface& S, const Standard_Boolean checknaturalbounds) { Standard_Real umin = uumin, umax = uumax, vmin = vvmin, vmax = vvmax; - Handle(Geom_Surface) surface = S.Surface(); - Handle(Geom_RectangularTrimmedSurface) - trs = Handle(Geom_RectangularTrimmedSurface)::DownCast(surface); - if(!trs.IsNull()) surface = trs->BasisSurface(); + const Handle(Geom_Surface) &surface = S.Surface(); Standard_Real u1,u2,v1,v2; surface->Bounds(u1,u2,v1,v2); Standard_Real peru=0, perv=0; @@ -620,8 +617,16 @@ void ChFi3d_BoundSrf(GeomAdaptor_Surface& S, Standard_Real vv1 = vmin - Stepv; Standard_Real vv2 = vmax + Stepv; if(checknaturalbounds) { - if(!S.IsUPeriodic()) {uu1 = Max(uu1,u1); uu2 = Min(uu2,u2);} - if(!S.IsVPeriodic()) {vv1 = Max(vv1,v1); vv2 = Min(vv2,v2);} + if (!GeomLib::IsUTrimAllowed(S, uu1, uu2)) + { + uu1 = Max(uu1,u1); + uu2 = Min(uu2,u2); + } + if (!GeomLib::IsVTrimAllowed(S, vv1, vv2)) + { + vv1 = Max(vv1, v1); + vv2 = Min(vv2, v2); + } } S.Load(surface,uu1,uu2,vv1,vv2); } @@ -984,12 +989,18 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, Handle(Geom2d_Curve) pcf1 = fd1->Interference(jf1).PCurveOnFace(); if(pcf1.IsNull()) return Standard_False; Standard_Boolean isper1 = pcf1->IsPeriodic(); - if(isper1) { + if(isper1) + { + // Extract basis curve to obtain its First and Last parameters. Handle(Geom2d_TrimmedCurve) tr1 = Handle(Geom2d_TrimmedCurve)::DownCast(pcf1); if(!tr1.IsNull()) pcf1 = tr1->BasisCurve(); C1.Load(pcf1); } - else C1.Load(pcf1,first-delta,last+delta); + else + { + C1.Load(pcf1, first - delta, last + delta); + } + Standard_Real first1 = pcf1->FirstParameter(), last1 = pcf1->LastParameter(); first = fd2->Interference(jf2).FirstParameter(); @@ -1000,12 +1011,18 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, Handle(Geom2d_Curve) pcf2 = fd2->Interference(jf2).PCurveOnFace(); if(pcf2.IsNull()) return Standard_False; Standard_Boolean isper2 = pcf2->IsPeriodic(); - if(isper2) { + if(isper2) + { + // Extract basis curve to obtain its First and Last parameters. Handle(Geom2d_TrimmedCurve) tr2 = Handle(Geom2d_TrimmedCurve)::DownCast(pcf2); if(!tr2.IsNull()) pcf2 = tr2->BasisCurve(); C2.Load(pcf2); } - else C2.Load(fd2->Interference(jf2).PCurveOnFace(),first-delta,last+delta); + else + { + C2.Load(pcf2, first - delta, last + delta); + } + Standard_Real first2 = pcf2->FirstParameter(), last2 = pcf2->LastParameter(); IntRes2d_IntersectionPoint int2d; @@ -1635,13 +1652,13 @@ void ChFi3d_ComputeArete(const ChFiDS_CommonPoint& P1, Parfin = C3d->ReversedParameter(Parfin); C3d->Reverse(); } - Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(C3d); - if(!tc.IsNull()) { - C3d = tc->BasisCurve(); - if (C3d->IsPeriodic()) { - ElCLib::AdjustPeriodic(C3d->FirstParameter(),C3d->LastParameter(), - tol2d,Pardeb,Parfin); - } + + if (C3d->IsPeriodic()) + { + Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(C3d); + if (!tc.IsNull()) C3d = tc->BasisCurve(); + ElCLib::AdjustPeriodic(C3d->FirstParameter(), C3d->LastParameter(), + tol2d, Pardeb, Parfin); } } if(IFlag != 1) { @@ -1665,13 +1682,13 @@ void ChFi3d_ComputeArete(const ChFiDS_CommonPoint& P1, Parfin = C3d->ReversedParameter(Parfin); C3d->Reverse(); } - Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(C3d); - if(!tc.IsNull()) { - C3d = tc->BasisCurve(); - if (C3d->IsPeriodic()) { - ElCLib::AdjustPeriodic(C3d->FirstParameter(),C3d->LastParameter(), - tol2d,Pardeb,Parfin); - } + + if (C3d->IsPeriodic()) + { + Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(C3d); + if (!tc.IsNull()) C3d = tc->BasisCurve(); + ElCLib::AdjustPeriodic(C3d->FirstParameter(), C3d->LastParameter(), + tol2d, Pardeb, Parfin); } } if(IFlag != 1) { @@ -2967,9 +2984,6 @@ Handle(Geom_Surface) trsfsurf(const Handle(Adaptor3d_HSurface)& HS, else if(!hgs.IsNull()) { res = hgs->ChangeSurface().Surface(); } - Handle(Geom_RectangularTrimmedSurface) - tr = Handle(Geom_RectangularTrimmedSurface)::DownCast(res); - if(!tr.IsNull()) res = tr->BasisSurface(); Standard_Real U1 = HS->FirstUParameter(), U2 = HS->LastUParameter(); Standard_Real V1 = HS->FirstVParameter(), V2 = HS->LastVParameter(); @@ -3979,7 +3993,7 @@ void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, tolpared = edc.Resolution(tol); Cv = BRep_Tool::Curve(E, First, Last); //Add vertex with tangent - if (ES.IsPeriodic()) + if (ES.IsPeriodic() && ES.IsClosed()) { Standard_Real ParForElSpine = (E.Orientation() == TopAbs_FORWARD)? First : Last; gp_Pnt PntForElSpine; @@ -4322,7 +4336,7 @@ void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, } } // elspine periodic => BSpline Periodic - if(ES.IsPeriodic()) { + if(ES.IsPeriodic() && ES.IsClosed()) { if(!BSpline->IsPeriodic()) { BSpline->SetPeriodic(); //modified by NIZNHY-PKV Fri Dec 10 12:20:22 2010ft diff --git a/src/ChFi3d/ChFi3d_Builder_C1.cxx b/src/ChFi3d/ChFi3d_Builder_C1.cxx index b63ad08337..a696a6dbfe 100644 --- a/src/ChFi3d/ChFi3d_Builder_C1.cxx +++ b/src/ChFi3d/ChFi3d_Builder_C1.cxx @@ -241,7 +241,8 @@ static Standard_Boolean Update(const Handle(Adaptor3d_HSurface)& fb, Standard_Real wbis = 0.; - Standard_Boolean isperiodic = ct->IsPeriodic(),recadrebis = Standard_False; + Standard_Boolean isperiodic = (ct->IsPeriodic() && ct->IsClosed()), + recadrebis = Standard_False; Intersection.Perform(ct,fb); if (Intersection.IsDone()) { Standard_Integer nbp = Intersection.NbPoints(),i,isol = 0,isolbis = 0; @@ -384,6 +385,7 @@ static Standard_Boolean Update(const Handle(Adaptor3d_HSurface)& face, if (!PConF.IsNull()) { Handle(Geom2d_TrimmedCurve) aTrCurve = Handle(Geom2d_TrimmedCurve)::DownCast(PConF); + // Extract basis curve to obtain its first/last parameters. if (!aTrCurve.IsNull()) PConF = aTrCurve->BasisCurve(); if (!PConF->IsPeriodic()) @@ -483,10 +485,7 @@ static void ChFi3d_Recale(BRepAdaptor_Surface& Bs, gp_Pnt2d& p2, const Standard_Boolean refon1) { - Handle(Geom_Surface) surf = Bs.ChangeSurface().Surface(); - Handle(Geom_RectangularTrimmedSurface) - ts = Handle(Geom_RectangularTrimmedSurface)::DownCast(surf); - if (!ts.IsNull()) surf = ts->BasisSurface(); + const Handle(Geom_Surface) &surf = Bs.ChangeSurface().Surface(); if (surf->IsUPeriodic()) { Standard_Real u1 = p1.X(), u2 = p2.X(); Standard_Real uper = surf->UPeriod(); @@ -2722,7 +2721,7 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index) DStr.SetNewSurface(Face[nb-1],Sfacemoins1); } //// for periodic 3d curves //// - if (cad.IsPeriodic()) + if (cad.IsPeriodic() && cad.IsClosed()) { gp_Pnt2d P2d = BRep_Tool::Parameters( Vtx, Face[0] ); Geom2dAPI_ProjectPointOnCurve Projector( P2d, C2dint1 ); diff --git a/src/ChFiDS/ChFiDS_ElSpine.cxx b/src/ChFiDS/ChFiDS_ElSpine.cxx index f5c0200cd4..dcd0efbe8d 100644 --- a/src/ChFiDS/ChFiDS_ElSpine.cxx +++ b/src/ChFiDS/ChFiDS_ElSpine.cxx @@ -161,6 +161,19 @@ Standard_Boolean ChFiDS_ElSpine::IsPeriodic() const return periodic; } +//======================================================================= +//function : IsClosed +//purpose : +//======================================================================= +Standard_Boolean ChFiDS_ElSpine::IsClosed() const +{ + if (curve.GetType() == GeomAbs_OtherCurve) + return IsPeriodic(); + + const Handle(Geom_Curve) &aC = curve.Curve(); + return curve.IsClosed() && + ((plast - pfirst - aC->LastParameter() + aC->FirstParameter()) < gp::Resolution()); +} //======================================================================= //function : SetPeriodic diff --git a/src/ChFiDS/ChFiDS_ElSpine.hxx b/src/ChFiDS/ChFiDS_ElSpine.hxx index e98953965a..f727ffc4d1 100644 --- a/src/ChFiDS/ChFiDS_ElSpine.hxx +++ b/src/ChFiDS/ChFiDS_ElSpine.hxx @@ -83,10 +83,15 @@ public: Standard_EXPORT virtual GeomAbs_CurveType GetType() const Standard_OVERRIDE; + //! Returns TRUE if *this has been set to periodic by calling SetPeriodic(...) method Standard_EXPORT virtual Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns TRUE if *this is closed + Standard_EXPORT virtual Standard_Boolean IsClosed() const Standard_OVERRIDE; + Standard_EXPORT void SetPeriodic (const Standard_Boolean I); + //! Returns the period of the periodic object Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE; Standard_EXPORT virtual gp_Pnt Value (const Standard_Real AbsC) const Standard_OVERRIDE; diff --git a/src/Contap/Contap_HCurve2dTool.hxx b/src/Contap/Contap_HCurve2dTool.hxx index ac027a79b2..c7a5bc732e 100644 --- a/src/Contap/Contap_HCurve2dTool.hxx +++ b/src/Contap/Contap_HCurve2dTool.hxx @@ -71,9 +71,11 @@ public: static Standard_Boolean IsClosed (const Handle(Adaptor2d_HCurve2d)& C); - static Standard_Boolean IsPeriodic (const Handle(Adaptor2d_HCurve2d)& C); + //! Returns TRUE if C is periodic + static Standard_Boolean IsPeriodic (const Handle(Adaptor2d_HCurve2d)& C); - static Standard_Real Period (const Handle(Adaptor2d_HCurve2d)& C); + //! Returns the period of C + static Standard_Real Period (const Handle(Adaptor2d_HCurve2d)& C); //! Computes the point of parameter U on the curve. static gp_Pnt2d Value (const Handle(Adaptor2d_HCurve2d)& C, const Standard_Real U); diff --git a/src/DBRep/DBRep_DrawableShape.cxx b/src/DBRep/DBRep_DrawableShape.cxx index 24b28a7585..460f31c734 100644 --- a/src/DBRep/DBRep_DrawableShape.cxx +++ b/src/DBRep/DBRep_DrawableShape.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -391,9 +392,14 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const Standard_Boolean restriction = Standard_False; if(aSurf->IsUPeriodic() || aSurf->IsVPeriodic()) { + Handle(Geom_Surface) aBS = aSurf; + if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { + aBS = Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf)->BasisSurface(); + } Standard_Real SU1 = 0., SU2 = 0., SV1 = 0., SV2 = 0.; Standard_Real FU1 = 0., FU2 = 0., FV1 = 0., FV2 = 0.; - aSurf->Bounds(SU1,SU2,SV1,SV2); + aBS->Bounds(SU1, SU2, SV1, SV2); BRepTools::UVBounds (F->Face(),FU1,FU2,FV1,FV2); if(aSurf->IsUPeriodic()) { if(FU1 < SU1 || FU1 > SU2) diff --git a/src/Draft/Draft_Modification.cxx b/src/Draft/Draft_Modification.cxx index 81a205a93a..27b01612e7 100644 --- a/src/Draft/Draft_Modification.cxx +++ b/src/Draft/Draft_Modification.cxx @@ -468,11 +468,6 @@ Standard_Boolean Draft_Modification::NewParameter(const TopoDS_Vertex& V, P = myVMap.ChangeFromKey(V).Parameter(E); Handle(Geom_Curve) GC = myEMap.FindFromKey(E).Geometry(); - Handle(Standard_Type) typc = GC->DynamicType(); - if (typc == STANDARD_TYPE(Geom_TrimmedCurve)) { - GC = Handle(Geom_TrimmedCurve)::DownCast(GC); - typc = GC->DynamicType(); - } if (GC->IsClosed()) { TopoDS_Vertex FV = TopExp::FirstVertex(E); diff --git a/src/Draft/Draft_Modification_1.cxx b/src/Draft/Draft_Modification_1.cxx index 9ff93c998c..5a3e98d4c7 100644 --- a/src/Draft/Draft_Modification_1.cxx +++ b/src/Draft/Draft_Modification_1.cxx @@ -2075,8 +2075,9 @@ static Standard_Real Parameter(const Handle(Geom_Curve)& C, } } - if (cbase->IsPeriodic()) { - Standard_Real Per = cbase->Period(); + if (C->IsPeriodic()) + { + Standard_Real Per = C->Period(); Standard_Real Tolp = Precision::Parametric(Precision::Confusion()); if (Abs(Per-param) <= Tolp) { param = 0.; diff --git a/src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx b/src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx index 814e3ebf9f..c2bee6ed1d 100644 --- a/src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx +++ b/src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx @@ -71,7 +71,7 @@ void DrawTrSurf_BSplineCurve2d::DrawOn (Draw_Display& dis) const for (Standard_Integer i = 2; i <= NbPoles; i++) { dis.DrawTo(CPoles(i)); } - if (C->IsPeriodic()) + if (C->IsPeriodic() && C->IsClosed()) dis.DrawTo(CPoles(1)); } diff --git a/src/Extrema/Extrema_CurveTool.cxx b/src/Extrema/Extrema_CurveTool.cxx index 995e311ce0..64aec13da2 100644 --- a/src/Extrema/Extrema_CurveTool.cxx +++ b/src/Extrema/Extrema_CurveTool.cxx @@ -29,12 +29,7 @@ //======================================================================= Standard_Boolean Extrema_CurveTool::IsPeriodic(const Adaptor3d_Curve& C) { - GeomAbs_CurveType aType = GetType(C); - if (aType == GeomAbs_Circle || - aType == GeomAbs_Ellipse) - return Standard_True; - else - return C.IsPeriodic(); + return C.IsPeriodic(); } //======================================================================= diff --git a/src/Extrema/Extrema_CurveTool.hxx b/src/Extrema/Extrema_CurveTool.hxx index 163b1550e9..ba449e02ba 100644 --- a/src/Extrema/Extrema_CurveTool.hxx +++ b/src/Extrema/Extrema_CurveTool.hxx @@ -72,9 +72,11 @@ public: //! Standard_EXPORT static Handle(TColStd_HArray1OfReal) DeflCurvIntervals(const Adaptor3d_Curve& C); - Standard_EXPORT static Standard_Boolean IsPeriodic (const Adaptor3d_Curve& C); - - static Standard_Real Period (const Adaptor3d_Curve& C); + //! Returns TRUE if C is periodic + Standard_EXPORT static Standard_Boolean IsPeriodic (const Adaptor3d_Curve& C); + + //! Returns the period of C + static Standard_Real Period (const Adaptor3d_Curve& C); static Standard_Real Resolution (const Adaptor3d_Curve& C, const Standard_Real R3d); diff --git a/src/Extrema/Extrema_ExtPExtS.cxx b/src/Extrema/Extrema_ExtPExtS.cxx index 969c8b64ce..f8c559b41c 100644 --- a/src/Extrema/Extrema_ExtPExtS.cxx +++ b/src/Extrema/Extrema_ExtPExtS.cxx @@ -313,7 +313,8 @@ void Extrema_ExtPExtS::Perform (const gp_Pnt& P) if (myC->IsPeriodic()) { Standard_Real U2 = U; - ElCLib::AdjustPeriodic(myuinf, myuinf + 2.*M_PI, Precision::PConfusion(), U, U2); + ElCLib::AdjustPeriodic(myuinf, myuinf + myC->Period(), + Precision::PConfusion(), U, U2); } ////////////////////////////////////////////////// gp_Pnt E = POC.Value(); diff --git a/src/Geom/Geom_BSplineCurve.cxx b/src/Geom/Geom_BSplineCurve.cxx index c2c07e7bcc..ec46687d98 100644 --- a/src/Geom/Geom_BSplineCurve.cxx +++ b/src/Geom/Geom_BSplineCurve.cxx @@ -1147,22 +1147,40 @@ void Geom_BSplineCurve::UpdateKnots() } //======================================================================= -//function : Normalizes the parameters if the curve is periodic -//purpose : that is compute the cache so that it is valid +//function : PeriodicNormalization +//purpose : Normalizes the parameters if the curve is periodic +// that is compute the cache so that it is valid +// (analog of ElCLib::InPeriod(...) method) //======================================================================= - -void Geom_BSplineCurve::PeriodicNormalization(Standard_Real& Parameter) const +void Geom_BSplineCurve::PeriodicNormalization(Standard_Real& theParameter) const { - Standard_Real Period ; + if (!periodic) + return; - if (periodic) { - Period = flatknots->Value(flatknots->Upper() - deg) - flatknots->Value (deg + 1) ; - while (Parameter > flatknots->Value(flatknots->Upper()-deg)) { - Parameter -= Period ; - } - while (Parameter < flatknots->Value((deg + 1))) { - Parameter += Period ; - } + const Standard_Real aPeriod = Period(); + const Standard_Real aFPar = FirstParameter(); + const Standard_Real aLPar = LastParameter(); + + if ((aFPar <= theParameter) && (theParameter <= aLPar)) + { + // Already normalized + return; } + + theParameter = Max(aFPar, theParameter + + aPeriod*Ceiling((aFPar - theParameter) / aPeriod)); } +//======================================================================= +//function : Period +//purpose : +//======================================================================= +Standard_Real Geom_BSplineCurve::Period() const +{ + if (!periodic) + throw Standard_NotImplemented("Geom_BSplineCurve::Period"); + + const Standard_Real aFPar = FirstParameter(); + const Standard_Real aLPar = LastParameter(); + return (aLPar - aFPar); +} diff --git a/src/Geom/Geom_BSplineCurve.hxx b/src/Geom/Geom_BSplineCurve.hxx index dc28c43f1b..a8c80cb624 100644 --- a/src/Geom/Geom_BSplineCurve.hxx +++ b/src/Geom/Geom_BSplineCurve.hxx @@ -464,6 +464,8 @@ public: //! Returns True if the curve is periodic. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns the period of this curve + Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Returns True if the weights are not identical. //! The tolerance criterion is Epsilon of the class Real. diff --git a/src/Geom/Geom_BSplineSurface.cxx b/src/Geom/Geom_BSplineSurface.cxx index 8bbd8cb76e..3e15b6c406 100644 --- a/src/Geom/Geom_BSplineSurface.cxx +++ b/src/Geom/Geom_BSplineSurface.cxx @@ -1444,3 +1444,32 @@ void Geom_BSplineSurface::SetWeightRow Rational(Weights, urational, vrational); } +//======================================================================= +//function : UPeriod +//purpose : +//======================================================================= +Standard_Real Geom_BSplineSurface::UPeriod() const +{ + if (!uperiodic) + throw Standard_NotImplemented("Geom_BSplineSurface::UPeriod"); + + const Standard_Real aFPar = ufknots->Value(udeg + 1); + const Standard_Real aLpar = ufknots->Value(ufknots->Upper() - udeg); + + return (aLpar - aFPar); +} + +//======================================================================= +//function : VPeriod +//purpose : +//======================================================================= +Standard_Real Geom_BSplineSurface::VPeriod() const +{ + if (!vperiodic) + throw Standard_NotImplemented("Geom_BSplineSurface::VPeriod"); + + const Standard_Real aFPar = vfknots->Value(vdeg + 1); + const Standard_Real aLpar = vfknots->Value(vfknots->Upper() - vdeg); + + return (aLpar - aFPar); +} diff --git a/src/Geom/Geom_BSplineSurface.hxx b/src/Geom/Geom_BSplineSurface.hxx index 9a54bf071d..d4d26d95d7 100644 --- a/src/Geom/Geom_BSplineSurface.hxx +++ b/src/Geom/Geom_BSplineSurface.hxx @@ -819,6 +819,11 @@ public: //! surface using the function SetVPeriodic. Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns U period of this surface + Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; + + //! Returns V-period of this surface + Standard_EXPORT Standard_Real VPeriod() const Standard_OVERRIDE; //! Returns False if for each column of weights all the weights //! are identical. diff --git a/src/Geom/Geom_BezierCurve.hxx b/src/Geom/Geom_BezierCurve.hxx index 38cf013566..2dee910166 100644 --- a/src/Geom/Geom_BezierCurve.hxx +++ b/src/Geom/Geom_BezierCurve.hxx @@ -229,8 +229,7 @@ public: Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE; - //! Returns True if the parametrization of a curve is periodic. - //! (P(u) = P(u + T) T = constante) + //! Always returns FALSE. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; diff --git a/src/Geom/Geom_Circle.hxx b/src/Geom/Geom_Circle.hxx index 4b75cb1f35..111a3a0a71 100644 --- a/src/Geom/Geom_Circle.hxx +++ b/src/Geom/Geom_Circle.hxx @@ -123,9 +123,15 @@ public: //! returns True. Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - //! returns True. + //! Returns TRUE. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; - + + //! Returns 2*PI + Standard_Real Period() const Standard_OVERRIDE + { + return (M_PI + M_PI); + } + //! Returns in P the point of parameter U. //! P = C + R * Cos (U) * XDir + R * Sin (U) * YDir //! where C is the center of the circle , XDir the XDirection and diff --git a/src/Geom/Geom_ConicalSurface.cxx b/src/Geom/Geom_ConicalSurface.cxx index 5dd0e7029b..646596c1c2 100644 --- a/src/Geom/Geom_ConicalSurface.cxx +++ b/src/Geom/Geom_ConicalSurface.cxx @@ -230,12 +230,16 @@ void Geom_ConicalSurface::SetSemiAngle (const Standard_Real Ang) { //purpose : //======================================================================= -Pnt Geom_ConicalSurface::Apex () const +Pnt Geom_ConicalSurface::Apex(Standard_Real* const theVParametr) const { XYZ Coord = Position().Direction().XYZ(); Coord.Multiply (-radius / Tan (semiAngle)); Coord.Add (Position().Location().XYZ()); + + if (theVParametr) + *theVParametr = -radius / Sin(semiAngle); + return Pnt (Coord); } diff --git a/src/Geom/Geom_ConicalSurface.hxx b/src/Geom/Geom_ConicalSurface.hxx index 5db22203b8..41bae8d764 100644 --- a/src/Geom/Geom_ConicalSurface.hxx +++ b/src/Geom/Geom_ConicalSurface.hxx @@ -182,7 +182,9 @@ public: //! side of the axis of revolution of this cone if the //! half-angle at the apex is positive, and on the positive //! side of the "main Axis" if the half-angle is negative. - Standard_EXPORT gp_Pnt Apex() const; + //! If theVParametr != 0 (points on the real variable) then it will store + //! the V-parameter of the apex. + Standard_EXPORT gp_Pnt Apex(Standard_Real* const theVParametr = 0) const; //! The conical surface is infinite in the V direction so @@ -225,6 +227,12 @@ public: //! Returns False. Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns 2*PI + Standard_Real UPeriod() const Standard_OVERRIDE + { + return (M_PI + M_PI); + }; + //! Builds the U isoparametric line of this cone. The //! origin of this line is on the reference plane of this //! cone (i.e. the plane defined by the origin, "X Direction" diff --git a/src/Geom/Geom_Curve.cxx b/src/Geom/Geom_Curve.cxx index 6f0ba329a5..dffd630661 100644 --- a/src/Geom/Geom_Curve.cxx +++ b/src/Geom/Geom_Curve.cxx @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -49,10 +49,7 @@ Handle(Geom_Curve) Geom_Curve::Reversed () const Standard_Real Geom_Curve::Period() const { - Standard_NoSuchObject_Raise_if - ( !IsPeriodic(),"Geom_Curve::Period"); - - return ( LastParameter() - FirstParameter()); + throw Standard_NotImplemented("Geom_Curve::Period"); } //======================================================================= diff --git a/src/Geom/Geom_Curve.hxx b/src/Geom/Geom_Curve.hxx index 4cacecc422..2bd5cb8ec4 100644 --- a/src/Geom/Geom_Curve.hxx +++ b/src/Geom/Geom_Curve.hxx @@ -137,29 +137,14 @@ public: //! Some Curves such as OffsetCurve can be closed or not. These curves //! are considered as closed if the distance between the first point //! and the last point of the curve is lower or equal to the Resolution - //! from package gp wich is a fixed criterion independant of the + //! from package gp, which is a fixed criterion independent of the //! application. Standard_EXPORT virtual Standard_Boolean IsClosed() const = 0; - //! Is the parametrization of the curve periodic ? - //! It is possible only if the curve is closed and if the - //! following relation is satisfied : - //! for each parametric value U the distance between the point - //! P(u) and the point P (u + T) is lower or equal to Resolution - //! from package gp, T is the period and must be a constant. - //! There are three possibilities : - //! . the curve is never periodic by definition (SegmentLine) - //! . the curve is always periodic by definition (Circle) - //! . the curve can be defined as periodic (BSpline). In this case - //! a function SetPeriodic allows you to give the shape of the - //! curve. The general rule for this case is : if a curve can be - //! periodic or not the default periodicity set is non periodic - //! and you have to turn (explicitly) the curve into a periodic - //! curve if you want the curve to be periodic. + //! Returns true if the curve is periodic Standard_EXPORT virtual Standard_Boolean IsPeriodic() const = 0; - //! Returns the period of this curve. - //! Exceptions Standard_NoSuchObject if this curve is not periodic. + //! Returns the period of the curve. Standard_EXPORT virtual Standard_Real Period() const; //! It is the global continuity of the curve diff --git a/src/Geom/Geom_CylindricalSurface.hxx b/src/Geom/Geom_CylindricalSurface.hxx index 8f4ae4dabc..f776ad22de 100644 --- a/src/Geom/Geom_CylindricalSurface.hxx +++ b/src/Geom/Geom_CylindricalSurface.hxx @@ -164,6 +164,11 @@ public: //! Returns False. Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns 2*PI + Standard_Real UPeriod() const Standard_OVERRIDE + { + return (M_PI + M_PI); + }; //! The UIso curve is a Line. The location point of this line is //! on the placement plane (XAxis, YAxis) of the surface. diff --git a/src/Geom/Geom_Ellipse.hxx b/src/Geom/Geom_Ellipse.hxx index 845c1a76b6..59d28e6313 100644 --- a/src/Geom/Geom_Ellipse.hxx +++ b/src/Geom/Geom_Ellipse.hxx @@ -188,9 +188,15 @@ public: //! return True. Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - //! return True. + //! Returns TRUE. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns 2*PI + Standard_Real Period() const Standard_OVERRIDE + { + return (M_PI + M_PI); + } + //! Returns in P the point of parameter U. //! P = C + MajorRadius * Cos (U) * XDir + MinorRadius * Sin (U) * YDir //! where C is the center of the ellipse , XDir the direction of diff --git a/src/Geom/Geom_Hyperbola.hxx b/src/Geom/Geom_Hyperbola.hxx index 19023092b0..ac50d85b0c 100644 --- a/src/Geom/Geom_Hyperbola.hxx +++ b/src/Geom/Geom_Hyperbola.hxx @@ -151,7 +151,7 @@ public: //! Returns False. Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - //! return False for an hyperbola. + //! Returns FALSE Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; diff --git a/src/Geom/Geom_Line.hxx b/src/Geom/Geom_Line.hxx index 77355dbec8..5e080f3288 100644 --- a/src/Geom/Geom_Line.hxx +++ b/src/Geom/Geom_Line.hxx @@ -113,7 +113,7 @@ public: //! returns False Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - //! returns False + //! returns FALSE Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; //! Returns GeomAbs_CN, which is the global continuity of any line. diff --git a/src/Geom/Geom_OffsetCurve.cxx b/src/Geom/Geom_OffsetCurve.cxx index 5bdffddbf0..31a1e5414e 100644 --- a/src/Geom/Geom_OffsetCurve.cxx +++ b/src/Geom/Geom_OffsetCurve.cxx @@ -139,6 +139,9 @@ void Geom_OffsetCurve::SetOffsetValue (const Standard_Real D) Standard_Boolean Geom_OffsetCurve::IsPeriodic () const { + if (basisCurve->Continuity() == GeomAbs_C0) + return Standard_False; + return basisCurve->IsPeriodic(); } @@ -149,6 +152,9 @@ Standard_Boolean Geom_OffsetCurve::IsPeriodic () const Standard_Real Geom_OffsetCurve::Period () const { + if (!IsPeriodic()) + throw Standard_NotImplemented("Geom_OffsetCurve::Period"); + return basisCurve->Period(); } diff --git a/src/Geom/Geom_OffsetCurve.hxx b/src/Geom/Geom_OffsetCurve.hxx index a195a85e92..4280c4803b 100644 --- a/src/Geom/Geom_OffsetCurve.hxx +++ b/src/Geom/Geom_OffsetCurve.hxx @@ -243,14 +243,12 @@ public: //! Raised if N < 0. Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE; - //! Returns true if this offset curve is periodic, i.e. if the - //! basis curve of this offset curve is periodic. + //! Returns TRUE if the basis curve is periodic. Otherwise, returns FALSE. + //! Moreover, the basis curve must have continuity greater than C0. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; //! Returns the period of this offset curve, i.e. the period //! of the basis curve of this offset curve. - //! Exceptions - //! Standard_NoSuchObject if the basis curve is not periodic. Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE; //! Applies the transformation T to this offset curve. diff --git a/src/Geom/Geom_OffsetSurface.cxx b/src/Geom/Geom_OffsetSurface.cxx index 207deca32d..c57b90771e 100644 --- a/src/Geom/Geom_OffsetSurface.cxx +++ b/src/Geom/Geom_OffsetSurface.cxx @@ -639,6 +639,13 @@ Standard_Boolean Geom_OffsetSurface::IsCNv (const Standard_Integer N) const Standard_Boolean Geom_OffsetSurface::IsUPeriodic () const { + //Indeed, the basis surface must have continuity greater than C0 + //in U-direction. + //However (but currently, continuity in both direction is checked) + + if (basisSurf->Continuity() == GeomAbs_C0) + return Standard_False; + return basisSurf->IsUPeriodic(); } @@ -659,6 +666,13 @@ Standard_Real Geom_OffsetSurface::UPeriod() const Standard_Boolean Geom_OffsetSurface::IsVPeriodic () const { + //Indeed, the basis surface must have continuity greater than C0 + //in U-direction. + //However (but currently, continuity in both direction is checked) + + if (basisSurf->Continuity() == GeomAbs_C0) + return Standard_False; + return basisSurf->IsVPeriodic(); } diff --git a/src/Geom/Geom_OffsetSurface.hxx b/src/Geom/Geom_OffsetSurface.hxx index c568f3abac..b1d5ca888a 100644 --- a/src/Geom/Geom_OffsetSurface.hxx +++ b/src/Geom/Geom_OffsetSurface.hxx @@ -209,24 +209,26 @@ public: //! Returns true if this offset surface is periodic in the u //! parametric direction, i.e. if the basis //! surface of this offset surface is periodic in this direction. + //! Moreover, the basis surface must have continuity greater than C0 + //! in U-direction (but currently, continuity in both direction is checked). Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; //! Returns the period of this offset surface in the u //! parametric direction respectively, i.e. the period of the //! basis surface of this offset surface in this parametric direction. - //! raises if the surface is not uperiodic. Standard_EXPORT virtual Standard_Real UPeriod() const Standard_OVERRIDE; //! Returns true if this offset surface is periodic in the v //! parametric direction, i.e. if the basis //! surface of this offset surface is periodic in this direction. + //! Moreover, the basis surface must have continuity greater than C0 + //! in V-direction (but currently, continuity in both direction is checked). Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; //! Returns the period of this offset surface in the v //! parametric direction respectively, i.e. the period of the //! basis surface of this offset surface in this parametric direction. - //! raises if the surface is not vperiodic. Standard_EXPORT virtual Standard_Real VPeriod() const Standard_OVERRIDE; //! Computes the U isoparametric curve. diff --git a/src/Geom/Geom_RectangularTrimmedSurface.cxx b/src/Geom/Geom_RectangularTrimmedSurface.cxx index eec0b8aeca..aa94480c86 100644 --- a/src/Geom/Geom_RectangularTrimmedSurface.cxx +++ b/src/Geom/Geom_RectangularTrimmedSurface.cxx @@ -237,7 +237,7 @@ void Geom_RectangularTrimmedSurface::SetTrim(const Standard_Real U1, if ( U1 == U2) throw Standard_ConstructionError("Geom_RectangularTrimmedSurface::U1==U2"); - if (basisSurf->IsUPeriodic()) { + if (IsUPeriodic()) { UsameSense = USense; // set uTrim1 in the range Udeb , Ufin @@ -277,7 +277,7 @@ void Geom_RectangularTrimmedSurface::SetTrim(const Standard_Real U1, if ( V1 == V2) throw Standard_ConstructionError("Geom_RectangularTrimmedSurface::V1==V2"); - if (basisSurf->IsVPeriodic()) { + if (IsVPeriodic()) { VsameSense = VSense; // set vTrim1 in the range Vdeb , Vfin @@ -561,9 +561,7 @@ void Geom_RectangularTrimmedSurface::Transform (const Trsf& T) Standard_Boolean Geom_RectangularTrimmedSurface::IsUPeriodic () const { - if (basisSurf->IsUPeriodic() && !isutrimmed) - return Standard_True; - return Standard_False; + return basisSurf->IsUPeriodic(); } @@ -585,9 +583,7 @@ Standard_Real Geom_RectangularTrimmedSurface::UPeriod() const Standard_Boolean Geom_RectangularTrimmedSurface::IsVPeriodic () const { - if (basisSurf->IsVPeriodic() && !isvtrimmed) - return Standard_True; - return Standard_False; + return basisSurf->IsVPeriodic(); } @@ -607,12 +603,18 @@ Standard_Real Geom_RectangularTrimmedSurface::VPeriod() const //purpose : //======================================================================= -Standard_Boolean Geom_RectangularTrimmedSurface::IsUClosed () const { - - if (isutrimmed) +Standard_Boolean Geom_RectangularTrimmedSurface::IsUClosed() const +{ + if (!basisSurf->IsUClosed()) return Standard_False; - else - return basisSurf->IsUClosed(); + + if (!isutrimmed) + return Standard_True; + + Standard_Real aU1 = 0.0, aU2 = 0.0, aV1 = 0.0, aV2 = 0.0; + basisSurf->Bounds(aU1, aU2, aV1, aV2); + + return (Abs((utrim2 + aU1) - (utrim1 + aU2)) < Precision::PConfusion()); } @@ -621,12 +623,18 @@ Standard_Boolean Geom_RectangularTrimmedSurface::IsUClosed () const { //purpose : //======================================================================= -Standard_Boolean Geom_RectangularTrimmedSurface::IsVClosed () const { - - if (isvtrimmed) +Standard_Boolean Geom_RectangularTrimmedSurface::IsVClosed() const +{ + if (!basisSurf->IsVClosed()) return Standard_False; - else - return basisSurf->IsVClosed(); + + if (!isvtrimmed) + return Standard_True; + + Standard_Real aU1 = 0.0, aU2 = 0.0, aV1 = 0.0, aV2 = 0.0; + basisSurf->Bounds(aU1, aU2, aV1, aV2); + + return (Abs((vtrim2 + aV1) - (vtrim1 + aV2)) < Precision::PConfusion()); } //======================================================================= diff --git a/src/Geom/Geom_RectangularTrimmedSurface.hxx b/src/Geom/Geom_RectangularTrimmedSurface.hxx index 857797370b..51ca2d893d 100644 --- a/src/Geom/Geom_RectangularTrimmedSurface.hxx +++ b/src/Geom/Geom_RectangularTrimmedSurface.hxx @@ -205,24 +205,19 @@ public: //! Raised if N < 0. Standard_EXPORT Standard_Boolean IsCNv (const Standard_Integer N) const Standard_OVERRIDE; - //! Returns true if this patch is periodic and not trimmed in the given - //! parametric direction. + //! Returns true if the basis surface is periodic in U-direction Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; - //! Returns the period of this patch in the u + //! Returns the period of the basis surface in the u //! parametric direction. - //! raises if the surface is not uperiodic. Standard_EXPORT virtual Standard_Real UPeriod() const Standard_OVERRIDE; - //! Returns true if this patch is periodic and not trimmed in the given - //! parametric direction. + //! Returns true if the basis surface is periodic in V-direction Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; - //! Returns the period of this patch in the v + //! Returns the period of the basis surface in the v //! parametric direction. - //! raises if the surface is not vperiodic. - //! value and derivatives Standard_EXPORT virtual Standard_Real VPeriod() const Standard_OVERRIDE; //! computes the U isoparametric curve. diff --git a/src/Geom/Geom_SphericalSurface.hxx b/src/Geom/Geom_SphericalSurface.hxx index 827a468673..b73e6503ea 100644 --- a/src/Geom/Geom_SphericalSurface.hxx +++ b/src/Geom/Geom_SphericalSurface.hxx @@ -164,6 +164,12 @@ public: //! Returns False. Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns 2*PI + Standard_Real UPeriod() const Standard_OVERRIDE + { + return (M_PI + M_PI); + }; + //! Computes the U isoparametric curve. //! The U isoparametric curves of the surface are defined by the //! section of the spherical surface with plane obtained by rotation diff --git a/src/Geom/Geom_Surface.cxx b/src/Geom/Geom_Surface.cxx index d01f1a9979..d58d0bc302 100644 --- a/src/Geom/Geom_Surface.cxx +++ b/src/Geom/Geom_Surface.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -86,12 +86,7 @@ gp_GTrsf2d Geom_Surface::ParametricTransformation(const gp_Trsf&) const Standard_Real Geom_Surface::UPeriod() const { - Standard_NoSuchObject_Raise_if - ( !IsUPeriodic(),"Geom_Surface::UPeriod"); - - Standard_Real U1, U2, V1, V2; - Bounds(U1,U2,V1,V2); - return ( U2 - U1); + throw Standard_NotImplemented("Geom_Surface::UPeriod"); } @@ -102,12 +97,7 @@ Standard_Real Geom_Surface::UPeriod() const Standard_Real Geom_Surface::VPeriod() const { - Standard_NoSuchObject_Raise_if - ( !IsVPeriodic(),"Geom_Surface::VPeriod"); - - Standard_Real U1, U2, V1, V2; - Bounds(U1,U2,V1,V2); - return ( V2 - V1); + throw Standard_NotImplemented("Geom_Surface::VPeriod"); } //======================================================================= diff --git a/src/Geom/Geom_Surface.hxx b/src/Geom/Geom_Surface.hxx index 187c3b47d9..885bb1f4cc 100644 --- a/src/Geom/Geom_Surface.hxx +++ b/src/Geom/Geom_Surface.hxx @@ -175,33 +175,16 @@ public: //! or equal to gp::Resolution(). Standard_EXPORT virtual Standard_Boolean IsVClosed() const = 0; - //! Checks if this surface is periodic in the u - //! parametric direction. Returns true if: - //! - this surface is closed in the u parametric direction, and - //! - there is a constant T such that the distance - //! between the points P (u, v) and P (u + T, - //! v) (or the points P (u, v) and P (u, v + - //! T)) is less than or equal to gp::Resolution(). - //! Note: T is the parametric period in the u parametric direction. + //! Returns true if the surface is U periodic Standard_EXPORT virtual Standard_Boolean IsUPeriodic() const = 0; - //! Returns the period of this surface in the u - //! parametric direction. - //! raises if the surface is not uperiodic. + //! Returns U period of the surface Standard_EXPORT virtual Standard_Real UPeriod() const; - //! Checks if this surface is periodic in the v - //! parametric direction. Returns true if: - //! - this surface is closed in the v parametric direction, and - //! - there is a constant T such that the distance - //! between the points P (u, v) and P (u + T, - //! v) (or the points P (u, v) and P (u, v + - //! T)) is less than or equal to gp::Resolution(). - //! Note: T is the parametric period in the v parametric direction. + //! Returns true if the surface is V periodic Standard_EXPORT virtual Standard_Boolean IsVPeriodic() const = 0; - //! Returns the period of this surface in the v parametric direction. - //! raises if the surface is not vperiodic. + //! Returns V period of the surface Standard_EXPORT virtual Standard_Real VPeriod() const; //! Computes the U isoparametric curve. diff --git a/src/Geom/Geom_SurfaceOfLinearExtrusion.cxx b/src/Geom/Geom_SurfaceOfLinearExtrusion.cxx index 62d816d994..3ece3c8efb 100644 --- a/src/Geom/Geom_SurfaceOfLinearExtrusion.cxx +++ b/src/Geom/Geom_SurfaceOfLinearExtrusion.cxx @@ -338,6 +338,15 @@ Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsUPeriodic () const { return basisCurve->IsPeriodic (); } +//======================================================================= +//function : UPeriod +//purpose : +//======================================================================= +Standard_Real Geom_SurfaceOfLinearExtrusion::UPeriod() const +{ + return basisCurve->Period(); +} + //======================================================================= //function : IsVClosed //purpose : diff --git a/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx b/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx index e0fb9d2f2f..bb3f5ee4fc 100644 --- a/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx +++ b/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx @@ -157,9 +157,12 @@ public: //! surface of linear extrusion is periodic. Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; - //! IsVPeriodic always returns false. + //! Always returns FALSE. Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns the period of the basis curve + Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; + //! Computes the U isoparametric curve of this surface //! of linear extrusion. This is the line parallel to the //! direction of extrusion, passing through the point of diff --git a/src/Geom/Geom_SurfaceOfRevolution.cxx b/src/Geom/Geom_SurfaceOfRevolution.cxx index d1b86e43e9..48877b019c 100644 --- a/src/Geom/Geom_SurfaceOfRevolution.cxx +++ b/src/Geom/Geom_SurfaceOfRevolution.cxx @@ -151,8 +151,8 @@ const gp_Pnt& Geom_SurfaceOfRevolution::Location () const { //purpose : //======================================================================= -Standard_Boolean Geom_SurfaceOfRevolution::IsUPeriodic () const { - +Standard_Boolean Geom_SurfaceOfRevolution::IsUPeriodic () const +{ return Standard_True; } @@ -213,12 +213,20 @@ Standard_Boolean Geom_SurfaceOfRevolution::IsVClosed () const //function : IsVPeriodic //purpose : //======================================================================= +Standard_Boolean Geom_SurfaceOfRevolution::IsVPeriodic() const +{ -Standard_Boolean Geom_SurfaceOfRevolution::IsVPeriodic () const { - - return basisCurve->IsPeriodic(); + return (basisCurve->IsPeriodic() && basisCurve->IsClosed()); } +//======================================================================= +//function : VPeriod +//purpose : +//======================================================================= +Standard_Real Geom_SurfaceOfRevolution::VPeriod() const +{ + return basisCurve->Period(); +} //======================================================================= //function : SetAxis diff --git a/src/Geom/Geom_SurfaceOfRevolution.hxx b/src/Geom/Geom_SurfaceOfRevolution.hxx index e83528e732..ea19537b37 100644 --- a/src/Geom/Geom_SurfaceOfRevolution.hxx +++ b/src/Geom/Geom_SurfaceOfRevolution.hxx @@ -247,9 +247,18 @@ public: Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; //! IsVPeriodic returns true if the meridian of this - //! surface of revolution is periodic. + //! surface of revolution is periodic and is closed. Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns 2*PI + Standard_Real UPeriod() const Standard_OVERRIDE + { + return (M_PI + M_PI); + }; + + //! Returns the period of the basis curve + Standard_EXPORT virtual Standard_Real VPeriod() const Standard_OVERRIDE; + //! Computes the U isoparametric curve of this surface //! of revolution. It is the curve obtained by rotating the //! meridian through an angle U about the axis of revolution. diff --git a/src/Geom/Geom_ToroidalSurface.hxx b/src/Geom/Geom_ToroidalSurface.hxx index 6c22fcafdb..3766ef8e90 100644 --- a/src/Geom/Geom_ToroidalSurface.hxx +++ b/src/Geom/Geom_ToroidalSurface.hxx @@ -188,6 +188,18 @@ public: //! Returns True. Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns 2*PI + Standard_Real UPeriod() const Standard_OVERRIDE + { + return (M_PI + M_PI); + }; + + //! Returns 2*PI + Standard_Real VPeriod() const Standard_OVERRIDE + { + return (M_PI + M_PI); + } + //! Computes the U isoparametric curve. //! //! For a toroidal surface the UIso curve is a circle. diff --git a/src/Geom/Geom_TrimmedCurve.cxx b/src/Geom/Geom_TrimmedCurve.cxx index 7fc934707b..9d31075204 100644 --- a/src/Geom/Geom_TrimmedCurve.cxx +++ b/src/Geom/Geom_TrimmedCurve.cxx @@ -126,7 +126,7 @@ void Geom_TrimmedCurve::SetTrim (const Standard_Real U1, Standard_Real Udeb = basisCurve->FirstParameter(); Standard_Real Ufin = basisCurve->LastParameter(); - if (basisCurve->IsPeriodic()) { + if (IsPeriodic()) { sameSense = Sense; // set uTrim1 in the range Udeb , Ufin @@ -170,7 +170,7 @@ void Geom_TrimmedCurve::SetTrim (const Standard_Real U1, Standard_Boolean Geom_TrimmedCurve::IsClosed () const { - return ( StartPoint().Distance(EndPoint()) <= gp::Resolution()); + return ( StartPoint().SquareDistance(EndPoint()) <= gp::Resolution()); } //======================================================================= @@ -180,8 +180,7 @@ Standard_Boolean Geom_TrimmedCurve::IsClosed () const Standard_Boolean Geom_TrimmedCurve::IsPeriodic () const { - //return basisCurve->IsPeriodic(); - return Standard_False; + return basisCurve->IsPeriodic(); } diff --git a/src/Geom/Geom_TrimmedCurve.hxx b/src/Geom/Geom_TrimmedCurve.hxx index 7656908070..50887635d5 100644 --- a/src/Geom/Geom_TrimmedCurve.hxx +++ b/src/Geom/Geom_TrimmedCurve.hxx @@ -173,12 +173,10 @@ public: //! the EndPoint is lower or equal to Resolution from package gp. Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - //! Always returns FALSE (independently of the type of basis curve). + //! Returns TRUE if the basis curve is periodic. Otherwise, returns FALSE. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; //! Returns the period of the basis curve of this trimmed curve. - //! Exceptions - //! Standard_NoSuchObject if the basis curve is not periodic. Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE; diff --git a/src/Geom2d/Geom2d_BSplineCurve.cxx b/src/Geom2d/Geom2d_BSplineCurve.cxx index b4cc7df96e..c89bfb0faf 100644 --- a/src/Geom2d/Geom2d_BSplineCurve.cxx +++ b/src/Geom2d/Geom2d_BSplineCurve.cxx @@ -1265,22 +1265,40 @@ void Geom2d_BSplineCurve::UpdateKnots() } //======================================================================= -//function : Normalizes the parameters if the curve is periodic -//purpose : that is compute the cache so that it is valid +//function : PeriodicNormalization +//purpose : Normalizes the parameters if the curve is periodic +// that is compute the cache so that it is valid +// (analog of ElCLib::InPeriod(...) method) //======================================================================= - -void Geom2d_BSplineCurve::PeriodicNormalization(Standard_Real& Parameter) const +void Geom2d_BSplineCurve::PeriodicNormalization(Standard_Real& theParameter) const { - Standard_Real Period ; + if (!periodic) + return; - if (periodic) { - Period = flatknots->Value(flatknots->Upper() - deg) - flatknots->Value (deg + 1) ; - while (Parameter > flatknots->Value(flatknots->Upper()-deg)) { - Parameter -= Period ; - } - while (Parameter < flatknots->Value((deg + 1))) { - Parameter += Period ; - } + const Standard_Real aPeriod = Period(); + const Standard_Real aFPar = FirstParameter(); + const Standard_Real aLPar = LastParameter(); + + if ((aFPar <= theParameter) && (theParameter <= aLPar)) + { + // Already normalized + return; } + + theParameter = Max(aFPar, theParameter + + aPeriod*Ceiling((aFPar - theParameter) / aPeriod)); } +//======================================================================= +//function : Period +//purpose : +//======================================================================= +Standard_Real Geom2d_BSplineCurve::Period() const +{ + if (!periodic) + throw Standard_NotImplemented("Geom2d_BSplineCurve::Period"); + + const Standard_Real aFPar = FirstParameter(); + const Standard_Real aLPar = LastParameter(); + return (aLPar - aFPar); +} diff --git a/src/Geom2d/Geom2d_BSplineCurve.hxx b/src/Geom2d/Geom2d_BSplineCurve.hxx index 948a01f849..c502016125 100644 --- a/src/Geom2d/Geom2d_BSplineCurve.hxx +++ b/src/Geom2d/Geom2d_BSplineCurve.hxx @@ -539,6 +539,9 @@ public: //! Returns True if the curve is periodic. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns the period of this curve + Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; + //! Returns True if the weights are not identical. //! The tolerance criterion is Epsilon of the class Real. diff --git a/src/Geom2d/Geom2d_BezierCurve.hxx b/src/Geom2d/Geom2d_BezierCurve.hxx index 0d61dc4b45..cc33547542 100644 --- a/src/Geom2d/Geom2d_BezierCurve.hxx +++ b/src/Geom2d/Geom2d_BezierCurve.hxx @@ -214,8 +214,7 @@ public: Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE; - //! Returns False. A BezierCurve cannot be periodic in this - //! package + //! Returns FALSE. A BezierCurve cannot be periodic. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; diff --git a/src/Geom2d/Geom2d_Circle.hxx b/src/Geom2d/Geom2d_Circle.hxx index 76e55766e4..4279b15ffc 100644 --- a/src/Geom2d/Geom2d_Circle.hxx +++ b/src/Geom2d/Geom2d_Circle.hxx @@ -121,9 +121,15 @@ public: //! returns True. Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - //! returns True. The period of a circle is 2.*Pi. + //! Returns TRUE. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; - + + //! Returns 2*PI + Standard_Real Period() const Standard_OVERRIDE + { + return (M_PI + M_PI); + } + //! Returns in P the point of parameter U. //! P = C + R * Cos (U) * XDir + R * Sin (U) * YDir //! where C is the center of the circle , XDir the XDirection and diff --git a/src/Geom2d/Geom2d_Curve.cxx b/src/Geom2d/Geom2d_Curve.cxx index 59ed0848eb..17a56a1875 100644 --- a/src/Geom2d/Geom2d_Curve.cxx +++ b/src/Geom2d/Geom2d_Curve.cxx @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -70,10 +70,7 @@ Standard_Real Geom2d_Curve::ParametricTransformation(const gp_Trsf2d& ) const Standard_Real Geom2d_Curve::Period() const { - Standard_NoSuchObject_Raise_if - ( !IsPeriodic(),"Geom2d_Curve::Period"); - - return ( LastParameter() - FirstParameter()); + throw Standard_NotImplemented("Geom2d_Curve::Period"); } diff --git a/src/Geom2d/Geom2d_Curve.hxx b/src/Geom2d/Geom2d_Curve.hxx index 844993b2bb..1099fc5c13 100644 --- a/src/Geom2d/Geom2d_Curve.hxx +++ b/src/Geom2d/Geom2d_Curve.hxx @@ -136,25 +136,10 @@ public: Standard_EXPORT virtual Standard_Boolean IsClosed() const = 0; - //! Returns true if the parameter of the curve is periodic. - //! It is possible only if the curve is closed and if the - //! following relation is satisfied : - //! for each parametric value U the distance between the point - //! P(u) and the point P (u + T) is lower or equal to Resolution - //! from package gp, T is the period and must be a constant. - //! There are three possibilities : - //! . the curve is never periodic by definition (SegmentLine) - //! . the curve is always periodic by definition (Circle) - //! . the curve can be defined as periodic (BSpline). In this case - //! a function SetPeriodic allows you to give the shape of the - //! curve. The general rule for this case is : if a curve can be - //! periodic or not the default periodicity set is non periodic - //! and you have to turn (explicitly) the curve into a periodic - //! curve if you want the curve to be periodic. + //! Returns true if the curve is periodic Standard_EXPORT virtual Standard_Boolean IsPeriodic() const = 0; - //! Returns thne period of this curve. - //! raises if the curve is not periodic + //! Returns the period of the curve Standard_EXPORT virtual Standard_Real Period() const; diff --git a/src/Geom2d/Geom2d_Ellipse.hxx b/src/Geom2d/Geom2d_Ellipse.hxx index 78ff674e61..c24a374b91 100644 --- a/src/Geom2d/Geom2d_Ellipse.hxx +++ b/src/Geom2d/Geom2d_Ellipse.hxx @@ -209,9 +209,15 @@ public: //! return True. Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - //! return True. + //! Returns TRUE. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns 2*PI + Standard_Real Period() const Standard_OVERRIDE + { + return (M_PI + M_PI); + } + //! Returns in P the point of parameter U. //! P = C + MajorRadius * Cos (U) * XDir + MinorRadius * Sin (U) * YDir //! where C is the center of the ellipse , XDir the direction of diff --git a/src/Geom2d/Geom2d_OffsetCurve.cxx b/src/Geom2d/Geom2d_OffsetCurve.cxx index 2c4ea9536c..a2f762d49b 100644 --- a/src/Geom2d/Geom2d_OffsetCurve.cxx +++ b/src/Geom2d/Geom2d_OffsetCurve.cxx @@ -332,6 +332,9 @@ Standard_Boolean Geom2d_OffsetCurve::IsCN (const Standard_Integer N) const Standard_Boolean Geom2d_OffsetCurve::IsPeriodic () const { + if (basisCurve->Continuity() == GeomAbs_C0) + return Standard_False; + return basisCurve->IsPeriodic(); } @@ -342,6 +345,9 @@ Standard_Boolean Geom2d_OffsetCurve::IsPeriodic () const Standard_Real Geom2d_OffsetCurve::Period() const { + if (!IsPeriodic()) + throw Standard_NotImplemented("Geom2d_OffsetCurve::Period"); + return basisCurve->Period(); } diff --git a/src/Geom2d/Geom2d_OffsetCurve.hxx b/src/Geom2d/Geom2d_OffsetCurve.hxx index 0886f46baa..27e6650eb0 100644 --- a/src/Geom2d/Geom2d_OffsetCurve.hxx +++ b/src/Geom2d/Geom2d_OffsetCurve.hxx @@ -238,16 +238,12 @@ public: //! Raised if N < 0. Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE; - //! Is the parametrization of a curve is periodic ? - //! If the basis curve is a circle or an ellipse the corresponding - //! OffsetCurve is periodic. If the basis curve can't be periodic - //! (for example BezierCurve) the OffsetCurve can't be periodic. + //! Returns TRUE if the basis curve is periodic. Returns FALSE otherwise. + //! Moreover, the basis curve must have continuity greater than C0. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; //! Returns the period of this offset curve, i.e. the period //! of the basis curve of this offset curve. - //! Exceptions - //! Standard_NoSuchObject if the basis curve is not periodic. Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE; //! Applies the transformation T to this offset curve. diff --git a/src/Geom2d/Geom2d_TrimmedCurve.cxx b/src/Geom2d/Geom2d_TrimmedCurve.cxx index 9cbfa69858..348978a1c6 100644 --- a/src/Geom2d/Geom2d_TrimmedCurve.cxx +++ b/src/Geom2d/Geom2d_TrimmedCurve.cxx @@ -123,7 +123,7 @@ void Geom2d_TrimmedCurve::SetTrim (const Standard_Real U1, Standard_Real Udeb = basisCurve->FirstParameter(); Standard_Real Ufin = basisCurve->LastParameter(); - if (basisCurve->IsPeriodic()) { + if (IsPeriodic()) { sameSense = Sense; // set uTrim1 in the range Udeb , Ufin @@ -209,12 +209,10 @@ Standard_Real Geom2d_TrimmedCurve::FirstParameter () const { return uTrim1 //function : IsClosed //purpose : //======================================================================= - -Standard_Boolean Geom2d_TrimmedCurve::IsClosed () const +Standard_Boolean Geom2d_TrimmedCurve::IsClosed() const { - Standard_Real Dist = - Value(FirstParameter()).Distance(Value(LastParameter())); - return ( Dist <= gp::Resolution()); + return + (Value(FirstParameter()).SquareDistance(Value(LastParameter())) < gp::Resolution()); } //======================================================================= @@ -222,10 +220,9 @@ Standard_Boolean Geom2d_TrimmedCurve::IsClosed () const //purpose : //======================================================================= -Standard_Boolean Geom2d_TrimmedCurve::IsPeriodic () const +Standard_Boolean Geom2d_TrimmedCurve::IsPeriodic() const { - //return basisCurve->IsPeriodic(); - return Standard_False; + return basisCurve->IsPeriodic(); } //======================================================================= diff --git a/src/Geom2d/Geom2d_TrimmedCurve.hxx b/src/Geom2d/Geom2d_TrimmedCurve.hxx index 57e905fb25..8c3dc86d41 100644 --- a/src/Geom2d/Geom2d_TrimmedCurve.hxx +++ b/src/Geom2d/Geom2d_TrimmedCurve.hxx @@ -172,12 +172,10 @@ public: //! gp. Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; - //! Always returns FALSE (independently of the type of basis curve). + //! Returns TRUE if the basis curve is periodic. Returns FALSE otherwise. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; //! Returns the period of the basis curve of this trimmed curve. - //! Exceptions - //! Standard_NoSuchObject if the basis curve is not periodic. Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE; diff --git a/src/Geom2dAdaptor/Geom2dAdaptor_Curve.hxx b/src/Geom2dAdaptor/Geom2dAdaptor_Curve.hxx index a230c342f6..9e0827f91c 100644 --- a/src/Geom2dAdaptor/Geom2dAdaptor_Curve.hxx +++ b/src/Geom2dAdaptor/Geom2dAdaptor_Curve.hxx @@ -105,8 +105,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the curve is periodic Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns the period of the curve Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve @@ -177,12 +179,6 @@ public: protected: - - - - -private: - Standard_EXPORT GeomAbs_Shape LocalContinuity (const Standard_Real U1, const Standard_Real U2) const; Standard_EXPORT void load (const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast); @@ -195,6 +191,12 @@ private: void RebuildCache (const Standard_Real theParameter) const; + + +private: + + + Handle(Geom2d_Curve) myCurve; GeomAbs_CurveType myTypeCurve; Standard_Real myFirst; diff --git a/src/Geom2dConvert/Geom2dConvert.cxx b/src/Geom2dConvert/Geom2dConvert.cxx index 84bd040e18..9922cfe852 100644 --- a/src/Geom2dConvert/Geom2dConvert.cxx +++ b/src/Geom2dConvert/Geom2dConvert.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -207,7 +208,8 @@ const Convert_ParameterisationType Parameterisation) // Si la courbe n'est pas vraiment restreinte, on ne risque pas // le Raise dans le BS->Segment. - if (!Curv->IsPeriodic()) { + if (!GeomLib::IsTrimAllowed(Curv, U1, U2)) + { if (U1 < Curv->FirstParameter()) U1 = Curv->FirstParameter(); if (U2 > Curv->LastParameter()) diff --git a/src/GeomAdaptor/GeomAdaptor_Curve.hxx b/src/GeomAdaptor/GeomAdaptor_Curve.hxx index 6e138872a6..3d94c7fe70 100644 --- a/src/GeomAdaptor/GeomAdaptor_Curve.hxx +++ b/src/GeomAdaptor/GeomAdaptor_Curve.hxx @@ -109,8 +109,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the curve is periodic Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! returns the period of the curve Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve diff --git a/src/GeomAdaptor/GeomAdaptor_Surface.hxx b/src/GeomAdaptor/GeomAdaptor_Surface.hxx index 2f0d4838c3..99d733f675 100644 --- a/src/GeomAdaptor/GeomAdaptor_Surface.hxx +++ b/src/GeomAdaptor/GeomAdaptor_Surface.hxx @@ -124,12 +124,16 @@ public: Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE; + //! Returns TRUE if the surface is U-periodic Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; + //! Returns U period of the surface Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; + //! Returns TRUE if the surface is V-periodic Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns V period of the surface Standard_EXPORT Standard_Real VPeriod() const Standard_OVERRIDE; //! Computes the point of parameters U,V on the surface. diff --git a/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx index 9c64c3c1eb..2c948fca3e 100644 --- a/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx @@ -267,16 +267,6 @@ Standard_Boolean GeomAdaptor_SurfaceOfLinearExtrusion::IsVPeriodic() const return Standard_False; } -//======================================================================= -//function : VPeriod -//purpose : -//======================================================================= - -Standard_Real GeomAdaptor_SurfaceOfLinearExtrusion::VPeriod() const -{ - throw Standard_DomainError("GeomAdaptor_SurfaceOfLinearExtrusion::VPeriod"); -} - //======================================================================= //function : UResolution //purpose : diff --git a/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx index c67e10f8e9..a1ede0392e 100644 --- a/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx @@ -116,14 +116,16 @@ public: Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE; + //! IsUPeriodic returns true if the "basis curve" of this + //! surface of linear extrusion is periodic. Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; + //! Returns the period of the basis curve Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; + //! Always returns FALSE Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; - Standard_EXPORT Standard_Real VPeriod() const Standard_OVERRIDE; - //! Returns the parametric U resolution corresponding //! to the real space resolution . Standard_EXPORT Standard_Real UResolution (const Standard_Real R3d) const Standard_OVERRIDE; diff --git a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx index d8fdd70710..01a70aeff4 100644 --- a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx @@ -347,7 +347,7 @@ Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsUPeriodic() const Standard_Real GeomAdaptor_SurfaceOfRevolution::UPeriod() const { - return 2*M_PI; + return (M_PI*M_PI); } //======================================================================= @@ -357,7 +357,7 @@ Standard_Real GeomAdaptor_SurfaceOfRevolution::UPeriod() const Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsVPeriodic() const { - return myBasisCurve->IsPeriodic(); + return (myBasisCurve->IsPeriodic() && myBasisCurve->IsClosed()); } //======================================================================= diff --git a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx index 405d1a94af..887bf81c45 100644 --- a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx @@ -129,12 +129,17 @@ public: Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE; + //! Always returns TRUE Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; + //! Returns 2*PI Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; + //! IsVPeriodic returns true if the meridian of this + //! surface of revolution is periodic and is closed. Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns the period of the basis curve Standard_EXPORT Standard_Real VPeriod() const Standard_OVERRIDE; //! Returns the parametric U resolution corresponding diff --git a/src/GeomConvert/GeomConvert.cxx b/src/GeomConvert/GeomConvert.cxx index ff694b0386..1501f9fff1 100644 --- a/src/GeomConvert/GeomConvert.cxx +++ b/src/GeomConvert/GeomConvert.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -194,7 +195,8 @@ Handle(Geom_BSplineCurve) GeomConvert::CurveToBSplineCurve // Si la courbe n'est pas vraiment restreinte, on ne risque pas // le Raise dans le BS->Segment. - if (!Curv->IsPeriodic()) { + if (!GeomLib::IsTrimAllowed(Curv, U1, U2)) + { if (U1 < Curv->FirstParameter()) U1 = Curv->FirstParameter(); if (U2 > Curv->LastParameter()) diff --git a/src/GeomFill/GeomFill_GuideTrihedronPlan.cxx b/src/GeomFill/GeomFill_GuideTrihedronPlan.cxx index 557a7b7f75..fb0457e759 100644 --- a/src/GeomFill/GeomFill_GuideTrihedronPlan.cxx +++ b/src/GeomFill/GeomFill_GuideTrihedronPlan.cxx @@ -644,7 +644,7 @@ void GeomFill_GuideTrihedronPlan::InitX(const Standard_Real Param) X(1) = (Pole->Value(1, Ideb).Coord(2) + Pole->Value(1, Ifin).Coord(2)) / 2; } - if (myGuide->IsPeriodic()) { + if (myGuide->IsPeriodic() && myGuide->IsClosed()) { X(1) = ElCLib::InPeriod(X(1), myGuide->FirstParameter(), myGuide->LastParameter()); } diff --git a/src/GeomFill/GeomFill_LocationGuide.cxx b/src/GeomFill/GeomFill_LocationGuide.cxx index d18a957d76..f5cef1c32e 100644 --- a/src/GeomFill/GeomFill_LocationGuide.cxx +++ b/src/GeomFill/GeomFill_LocationGuide.cxx @@ -1436,7 +1436,7 @@ void GeomFill_LocationGuide::InitX(const Standard_Real Param) const X(3) = (P1.Coord(2) + P2.Coord(2)) /2; } - if (myGuide->IsPeriodic()) { + if (myGuide->IsPeriodic() && myGuide->IsClosed()) { X(1) = ElCLib::InPeriod(X(1), myGuide->FirstParameter(), myGuide->LastParameter()); } diff --git a/src/GeomFill/GeomFill_NSections.cxx b/src/GeomFill/GeomFill_NSections.cxx index 07a69e3c66..e3e07b3cf3 100644 --- a/src/GeomFill/GeomFill_NSections.cxx +++ b/src/GeomFill/GeomFill_NSections.cxx @@ -1000,18 +1000,15 @@ void GeomFill_NSections::GetMinimalWeight(TColStd_Array1OfReal& Weights) const gp_Circ C2 = AC2.Circle(); Standard_Real p1 = myParams(1), p2 = myParams(myParams.Length()); - Standard_Real radius = ( C2.Radius() - C1.Radius() ) * (V - p1) / (p2 - p1) - + C1.Radius(); + Standard_Real radius = (C2.Radius() - C1.Radius()) * (V - p1) / (p2 - p1) + C1.Radius(); C1.SetRadius(radius); Handle(Geom_Curve) C = new (Geom_Circle) (C1); - const Standard_Real aParF = AC1.FirstParameter(); - const Standard_Real aParL = AC1.LastParameter(); - const Standard_Real aPeriod = AC1.IsPeriodic() ? AC1.Period() : 0.0; - - if ((aPeriod == 0.0) || (Abs(aParL - aParF - aPeriod) > Precision::PConfusion())) + if (!AC1.IsClosed() || !AC1.IsPeriodic()) { + const Standard_Real aParF = AC1.FirstParameter(); + const Standard_Real aParL = AC1.LastParameter(); Handle(Geom_Curve) Cbis = new Geom_TrimmedCurve(C, aParF, aParL); C = Cbis; } diff --git a/src/GeomFill/GeomFill_SnglrFunc.cxx b/src/GeomFill/GeomFill_SnglrFunc.cxx index 07ecd327cf..6d7fba49b3 100644 --- a/src/GeomFill/GeomFill_SnglrFunc.cxx +++ b/src/GeomFill/GeomFill_SnglrFunc.cxx @@ -90,6 +90,10 @@ void GeomFill_SnglrFunc::SetRatio(const Standard_Real Ratio) return myHCurve->Period(); } +Standard_Boolean GeomFill_SnglrFunc::IsClosed() const +{ + return myHCurve->IsClosed(); +} gp_Pnt GeomFill_SnglrFunc::Value(const Standard_Real U) const { diff --git a/src/GeomFill/GeomFill_SnglrFunc.hxx b/src/GeomFill/GeomFill_SnglrFunc.hxx index 3de3e68e3f..f14fb51dc8 100644 --- a/src/GeomFill/GeomFill_SnglrFunc.hxx +++ b/src/GeomFill/GeomFill_SnglrFunc.hxx @@ -65,8 +65,13 @@ public: //! Computes the point of parameter U on the curve. Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE; + //! This method is overridden from the basis class + Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + + //! Returns TRUE if the curve is periodic Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! returns the period of the curve Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve. diff --git a/src/GeomLib/GeomLib.cxx b/src/GeomLib/GeomLib.cxx index 4d004faca3..5dd1920612 100644 --- a/src/GeomLib/GeomLib.cxx +++ b/src/GeomLib/GeomLib.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -74,16 +75,19 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -962,14 +966,7 @@ void GeomLib::SameRange(const Standard_Real Tolerance, else { // On segmente le resultat Handle(Geom2d_TrimmedCurve) TC; - Handle(Geom2d_Curve) aCCheck = CurvePtr; - - if(aCCheck->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) - { - aCCheck = Handle(Geom2d_TrimmedCurve)::DownCast(aCCheck)->BasisCurve(); - } - - if(aCCheck->IsPeriodic()) + if (CurvePtr->IsPeriodic()) { if(Abs(LastOnCurve - FirstOnCurve) > Precision::PConfusion()) { @@ -2751,12 +2748,148 @@ Standard_Boolean GeomLib::IsBzVClosed (const Handle(Geom_BezierSurface)& S, return CompareWeightPoles(aPF, 0, aPL, 0, Tol2); } +//======================================================================= +//function : IsUTrimAllowed +//purpose : +//======================================================================= +Standard_Boolean GeomLib::IsUTrimAllowed(const GeomAdaptor_Surface& theS, + const Standard_Real theNewUFirst, + const Standard_Real theNewULast) +{ + const Handle(Geom_Surface) &aSurf = theS.Surface(); + + Standard_Real anIsoParameter = theS.FirstVParameter(); + if (Precision::IsInfinite(anIsoParameter)) + anIsoParameter = theS.LastVParameter(); + + if (Precision::IsInfinite(anIsoParameter)) + anIsoParameter = 0.0; + + Handle(Geom_Curve) aC = aSurf->VIso(anIsoParameter); + + if (aC->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) + { + // In order to obtain the default curve's work range + aC = Handle(Geom_TrimmedCurve)::DownCast(aC)->BasisCurve(); + } + + return (IsTrimAllowed(aC, theNewUFirst, theNewULast)); +} + +//======================================================================= +//function : IsVTrimAllowed +//purpose : +//======================================================================= +Standard_Boolean GeomLib::IsVTrimAllowed(const GeomAdaptor_Surface& theS, + const Standard_Real theNewVFirst, + const Standard_Real theNewVLast) +{ + const GeomAbs_SurfaceType aSType = theS.GetType(); + + const Handle(Geom_Surface) &aSurf = theS.Surface(); + + if (aSType == GeomAbs_OffsetSurface) + { + const Handle(Geom_OffsetSurface) aOS = Handle(Geom_OffsetSurface)::DownCast(aSurf); + return IsVTrimAllowed(GeomAdaptor_Surface(aOS->BasisSurface()), + theNewVFirst, theNewVLast); + } + + Standard_Real anIsoParameter = theS.FirstUParameter(); + if (Precision::IsInfinite(anIsoParameter)) + anIsoParameter = theS.LastUParameter(); + + if (Precision::IsInfinite(anIsoParameter)) + anIsoParameter = 0.0; + + Handle(Geom_Curve) aC = aSurf->UIso(anIsoParameter); + + if (aC.IsNull()) + return Standard_False; + + if (aC->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) + { + // In order to obtain the default curve's work range + aC = Handle(Geom_TrimmedCurve)::DownCast(aC)->BasisCurve(); + } + + if (!IsTrimAllowed(aC, theNewVFirst, theNewVLast)) + return Standard_False; + + switch (aSType) + { + case GeomAbs_OtherSurface: + return Standard_True; + case GeomAbs_Sphere: + { + if ((theNewVFirst < -M_PI_2) || (theNewVLast > M_PI_2)) + { + // After extending, the surface isoline will go + // through the sphere pole + return Standard_False; + } + } + break; + case GeomAbs_Cone: + { + const Handle(Geom_ConicalSurface) aCone = Handle(Geom_ConicalSurface)::DownCast(aSurf); + Standard_Real anApexPrm = 0.0; + aCone->Apex(&anApexPrm); + + if ((anApexPrm - theNewVFirst)*(theNewVLast - anApexPrm) > 0.0) + { + // The new boundaries intersect the cone apex + return Standard_False; + } + } + break; + case GeomAbs_SurfaceOfRevolution: + { + const Handle(Adaptor3d_HCurve) aCurv = theS.BasisCurve(); + + const Standard_Real aParTol = aCurv->Resolution(Precision::Confusion()); + + const Standard_Real aParF = theNewVFirst + aParTol, + aParL = theNewVLast - aParTol; + + const Handle(Geom_Line) aL = new Geom_Line(theS.AxeOfRevolution()); + const GeomAdaptor_Curve aLin(aL); + + Extrema_ECC anExtr(aCurv->Curve(), aLin); + anExtr.Perform(); + if (anExtr.IsDone() && anExtr.NbExt() > 0) + { + Extrema_POnCurv aP1, aP2; + for (Standard_Integer i = 1; i <= anExtr.NbExt(); i++) + { + if (anExtr.SquareDistance(i) > Precision::SquareConfusion()) + continue; + + anExtr.Points(i, aP1, aP2); + if ((aParF < aP1.Parameter()) && (aP1.Parameter() < aParL)) + { + // After extending, the surface isoline will go + // through the pole (singular point like pole of sphere) + + return Standard_False; + } + } + } + } + break; + default: + break; + } + + return Standard_True; +} + //======================================================================= //function : CompareWeightPoles //purpose : Checks if thePoles1(i)*theW1(i) is equal to thePoles2(i)*theW2(i) // with tolerance theTol. // It is necessary for not rational B-splines and Bezier curves -// to set theW1 and theW2 adresses to zero. +// to set theW1 and theW2 addresses to zero. //======================================================================= static Standard_Boolean CompareWeightPoles(const TColgp_Array1OfPnt& thePoles1, const TColStd_Array1OfReal* const theW1, diff --git a/src/GeomLib/GeomLib.hxx b/src/GeomLib/GeomLib.hxx index b51028d2fc..f08af33cec 100644 --- a/src/GeomLib/GeomLib.hxx +++ b/src/GeomLib/GeomLib.hxx @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,7 @@ class gp_Ax2; class Geom2d_Curve; class gp_GTrsf2d; class Adaptor3d_CurveOnSurface; +class GeomAdaptor_Surface; class Geom_BoundedCurve; class gp_Pnt; class gp_Vec; @@ -54,7 +56,6 @@ class GeomLib_Tool; class GeomLib_PolyFunc; class GeomLib_LogSample; - //! Geom Library. This package provides an //! implementation of functions for basic computation //! on geometric entity from packages Geom and Geom2d. @@ -193,6 +194,71 @@ public: Standard_EXPORT static void IsClosed(const Handle(Geom_Surface)& S, const Standard_Real Tol, Standard_Boolean& isUClosed, Standard_Boolean& isVClosed); + //! This method determines if the ends of the given curve are + //! coincided with given tolerance. + //! This is a template-method. Therefore, it can be applied to + //! 2D- and 3D-curve and to Adaptor-HCurve. + template + Standard_EXPORT static Standard_Boolean IsClosed(const Handle(TypeCurve)& theCurve, + const Standard_Real theTol) + { + const Standard_Real aFPar = theCurve->FirstParameter(), + aLPar = theCurve->LastParameter(); + + if (Precision::IsInfinite(aFPar) || Precision::IsInfinite(aLPar)) + return Standard_False; + + return (theCurve->Value(aFPar).SquareDistance(theCurve->Value(aLPar)) < theTol*theTol); + } + + //! Returns TRUE if theCurve will keep its validity for OCCT-algorithms + //! after its trimming in range [theNewFPar, theNewLPar]. + //! This is a template-method. Therefore, it can be applied to + //! 2D- and 3D-curve. + //! Using trimmed curves or Adaptor_HCurves is possible but undesirable + //! because theCurve must be parametrized in its default work-range + //! in order for this method to work correctly. + template + Standard_EXPORT static Standard_Boolean IsTrimAllowed(const Handle(TypeCurve)& theCurve, + const Standard_Real theNewFPar, + const Standard_Real theNewLPar) + { + Standard_Real aFPar = theCurve->FirstParameter(), + aLPar = theCurve->LastParameter(); + + if ((aFPar <= theNewFPar) && (theNewLPar <= aLPar) && (theNewFPar < theNewLPar)) + { + //New boundaries are in the current ones + return Standard_True; + } + + if (!theCurve->IsPeriodic()) + { + return Standard_False; + } + + const Standard_Real aPeriod = theCurve->Period(); + + if ((theNewLPar - theNewFPar - aPeriod) > Epsilon(aPeriod)) + return Standard_False; + + return Standard_True; + } + + //! Returns TRUE if theS will keep its validity for OCCT-algorithms + //! after its trimming in range [theNewUFirst, theNewULast] along U-direction + Standard_EXPORT static Standard_Boolean + IsUTrimAllowed(const GeomAdaptor_Surface& theS, + const Standard_Real theNewUFirst, + const Standard_Real theNewULast); + + //! Returns TRUE if theS will keep its validity for OCCT-algorithms + //! after its trimming in range [theNewVFirst, theNewVLast] along V-direction + Standard_EXPORT static Standard_Boolean + IsVTrimAllowed(const GeomAdaptor_Surface& theS, + const Standard_Real theNewVFirst, + const Standard_Real theNewVLast); + //! Returns true if the poles of U1 isoline and the poles of //! U2 isoline of surface are identical according to tolerance criterion. //! For rational surfaces Weights(i)*Poles(i) are checked. diff --git a/src/GeomPlate/GeomPlate_Surface.cxx b/src/GeomPlate/GeomPlate_Surface.cxx index 89f8219728..bbec677f67 100644 --- a/src/GeomPlate/GeomPlate_Surface.cxx +++ b/src/GeomPlate/GeomPlate_Surface.cxx @@ -162,18 +162,6 @@ Standard_Boolean GeomPlate_Surface::IsUPeriodic() const return Standard_False; } - -//======================================================================= -//function : UPeriod -//purpose : -//======================================================================= - -Standard_Real GeomPlate_Surface::UPeriod() const -{ - return Standard_False; -} - - //======================================================================= //function : IsVPeriodic //purpose : @@ -184,18 +172,6 @@ Standard_Boolean GeomPlate_Surface::IsVPeriodic() const return Standard_False; } - -//======================================================================= -//function : VPeriod -//purpose : -//======================================================================= - -Standard_Real GeomPlate_Surface::VPeriod() const -{ - return Standard_False; -} - - //======================================================================= //function : UIso //purpose : diff --git a/src/GeomPlate/GeomPlate_Surface.hxx b/src/GeomPlate/GeomPlate_Surface.hxx index 86dc118282..2823d738fc 100644 --- a/src/GeomPlate/GeomPlate_Surface.hxx +++ b/src/GeomPlate/GeomPlate_Surface.hxx @@ -149,37 +149,12 @@ public: Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE; - //! Is the parametrization of a surface periodic in the - //! direction U ? - //! It is possible only if the surface is closed in this - //! parametric direction and if the following relation is - //! satisfied : - //! for each parameter V the distance between the point - //! P (U, V) and the point P (U + T, V) is lower or equal - //! to Resolution from package gp. T is the parametric period - //! and must be a constant. + //! Always returns FALSE Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; - //! returns the Uperiod. - //! raises if the surface is not uperiodic. - Standard_EXPORT virtual Standard_Real UPeriod() const Standard_OVERRIDE; - - - //! Is the parametrization of a surface periodic in the - //! direction U ? - //! It is possible only if the surface is closed in this - //! parametric direction and if the following relation is - //! satisfied : - //! for each parameter V the distance between the point - //! P (U, V) and the point P (U + T, V) is lower or equal - //! to Resolution from package gp. T is the parametric period - //! and must be a constant. + //! Always returns FALSE Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; - //! returns the Vperiod. - //! raises if the surface is not vperiodic. - Standard_EXPORT virtual Standard_Real VPeriod() const Standard_OVERRIDE; - //! Computes the U isoparametric curve. Standard_EXPORT Handle(Geom_Curve) UIso (const Standard_Real U) const Standard_OVERRIDE; diff --git a/src/GeomProjLib/GeomProjLib.cxx b/src/GeomProjLib/GeomProjLib.cxx index d8c61cd84a..3a6eb432c7 100644 --- a/src/GeomProjLib/GeomProjLib.cxx +++ b/src/GeomProjLib/GeomProjLib.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -144,15 +145,16 @@ Handle(Geom2d_Curve) GeomProjLib::Curve2d(const Handle(Geom_Curve)& C, return G2dC; } - if ( C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)) ) { - Handle(Geom_TrimmedCurve) CTrim = Handle(Geom_TrimmedCurve)::DownCast(C); - Standard_Real U1 = CTrim->FirstParameter(); - Standard_Real U2 = CTrim->LastParameter(); - if (!G2dC->IsPeriodic()) + if (C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) + { + Standard_Real U1 = C->FirstParameter(); + Standard_Real U2 = C->LastParameter(); + if (!GeomLib::IsTrimAllowed(G2dC, U1, U2)) { U1 = Max(U1, G2dC->FirstParameter()); U2 = Min(U2, G2dC->LastParameter()); } + G2dC = new Geom2d_TrimmedCurve( G2dC, U1, U2); } diff --git a/src/GeometryTest/GeometryTest_CurveCommands.cxx b/src/GeometryTest/GeometryTest_CurveCommands.cxx index 5e6ad444c7..c9fa762360 100644 --- a/src/GeometryTest/GeometryTest_CurveCommands.cxx +++ b/src/GeometryTest/GeometryTest_CurveCommands.cxx @@ -1771,6 +1771,57 @@ static Standard_Integer GetCurveContinuity( Draw_Interpretor& theDI, return 0; } +//======================================================================= +//function : IsPeriodic +//purpose : Checks if the curve is periodic and returns the period +//======================================================================= +static Standard_Integer IsPeriodic(Draw_Interpretor& theDI, + Standard_Integer theNArg, + const char** theArgv) +{ + if (theNArg != 2) + { + theDI << "Use: " << theArgv[0] << " {curve or 2dcurve} \n"; + return 1; + } + + Handle(Geom2d_Curve) aGC2d; + Handle(Geom_Curve) aGC3d = DrawTrSurf::GetCurve(theArgv[1]); + if (aGC3d.IsNull()) + { + aGC2d = DrawTrSurf::GetCurve2d(theArgv[1]); + if (aGC2d.IsNull()) + { + theDI << "Argument is not a 2D or 3D curve!\n"; + return 1; + } + else + { + if (aGC2d->IsPeriodic()) + { + theDI << theArgv[1] << " is periodic with the period " << aGC2d->Period() << "\n"; + } + else + { + theDI << theArgv[1] << " is not periodic\n"; + } + } + } + else + { + if (aGC3d->IsPeriodic()) + { + theDI << theArgv[1] << " is periodic with the period " << aGC3d->Period() << "\n"; + } + else + { + theDI << theArgv[1] << " is not periodic\n"; + } + } + + return 0; +} + //======================================================================= //function : CurveCommands //purpose : @@ -1878,6 +1929,11 @@ void GeometryTest::CurveCommands(Draw_Interpretor& theCommands) __FILE__, GetCurveContinuity,g); + theCommands.Add("curveperiod", + "curveperiod {curve or 2dcurve}: \n\tReturns the period of the curve (or the information about not-periodic state)", + __FILE__, + IsPeriodic, g); + } diff --git a/src/GeometryTest/GeometryTest_SurfaceCommands.cxx b/src/GeometryTest/GeometryTest_SurfaceCommands.cxx index 5b5636ffa9..569bad5823 100644 --- a/src/GeometryTest/GeometryTest_SurfaceCommands.cxx +++ b/src/GeometryTest/GeometryTest_SurfaceCommands.cxx @@ -371,6 +371,47 @@ static Standard_Integer GetSurfaceContinuity( Draw_Interpretor& theDI, return 0; } +//======================================================================= +//function : IsPeriodic +//purpose : Checks if the surface is periodic and returns the period +//======================================================================= +static Standard_Integer IsPeriodic(Draw_Interpretor& theDI, + Standard_Integer theNArg, + const char** theArgv) +{ + if (theNArg != 2) + { + theDI << "Use: " << theArgv[0] << " surface \n"; + return 1; + } + + Handle(Geom_Surface) aGS1 = DrawTrSurf::GetSurface(theArgv[1]); + if (aGS1.IsNull()) + { + theDI << "Argument is not a surface!\n"; + return 1; + } + + if (aGS1->IsUPeriodic()) + { + theDI << theArgv[1] << " is U-periodic with U-period " << aGS1->UPeriod() << "\n"; + } + else + { + theDI << theArgv[1] << " is not U-periodic\n"; + } + + if (aGS1->IsVPeriodic()) + { + theDI << theArgv[1] << " is V-periodic with V-period " << aGS1->VPeriod() << "\n"; + } + else + { + theDI << theArgv[1] << " is not V-periodic\n"; + } + + return 0; +} //======================================================================= //function : SurfaceCommands @@ -425,6 +466,10 @@ void GeometryTest::SurfaceCommands(Draw_Interpretor& theCommands) __FILE__, GetSurfaceContinuity,g); + theCommands.Add("surfaceperiod", + "surfaceperiod surface: \n\tReturns the period of the surface (or the information about not-periodic state)", + __FILE__, + IsPeriodic, g); } diff --git a/src/GeomliteTest/FILES b/src/GeomliteTest/FILES index 0c17d289a7..0a2681e0ee 100755 --- a/src/GeomliteTest/FILES +++ b/src/GeomliteTest/FILES @@ -5,3 +5,4 @@ GeomliteTest_ApproxCommands.cxx GeomliteTest_CurveCommands.cxx GeomliteTest_ModificationCommands.cxx GeomliteTest_SurfaceCommands.cxx +GeomliteTest_AdaptorCommands.cxx \ No newline at end of file diff --git a/src/GeomliteTest/GeomliteTest.cxx b/src/GeomliteTest/GeomliteTest.cxx index c7a11e366a..17f535f419 100644 --- a/src/GeomliteTest/GeomliteTest.cxx +++ b/src/GeomliteTest/GeomliteTest.cxx @@ -31,6 +31,7 @@ void GeomliteTest::AllCommands(Draw_Interpretor& theCommands) GeomliteTest::ApproxCommands(theCommands); GeomliteTest::API2dCommands(theCommands); GeomliteTest::ModificationCommands(theCommands); + GeomliteTest::AdaptorCommands(theCommands); // define the TCL variable Draw_GEOMETRY //char* com = "set Draw_GEOMETRY 1"; diff --git a/src/GeomliteTest/GeomliteTest.hxx b/src/GeomliteTest/GeomliteTest.hxx index c9395e27d6..65b670fc0d 100644 --- a/src/GeomliteTest/GeomliteTest.hxx +++ b/src/GeomliteTest/GeomliteTest.hxx @@ -57,6 +57,8 @@ public: //! - Surface extension by length Standard_EXPORT static void ModificationCommands (Draw_Interpretor& I); + //! Defines commands to work with 3d/2d adapters of curve or surface. + Standard_EXPORT static void AdaptorCommands(Draw_Interpretor& theCommands); diff --git a/src/GeomliteTest/GeomliteTest_AdaptorCommands.cxx b/src/GeomliteTest/GeomliteTest_AdaptorCommands.cxx new file mode 100644 index 0000000000..74e6fb10fc --- /dev/null +++ b/src/GeomliteTest/GeomliteTest_AdaptorCommands.cxx @@ -0,0 +1,472 @@ +// Created on: 2018-03-26 +// Created by: Nikolai BUKHALOV +// Copyright (c) 1999-2018 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. + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace AdaptorTypes +{ + static Handle(Adaptor2d_HCurve2d) anAHC2d; + static Handle(Adaptor3d_HCurve) anAHC3d; + static Handle(Adaptor3d_HSurface) anAHS3d; +} + +//======================================================================= +//function : NulifyAdaptors +//purpose : +//======================================================================= +static void NulifyAdaptors() +{ + AdaptorTypes::anAHC2d.Nullify(); + AdaptorTypes::anAHC3d.Nullify(); + AdaptorTypes::anAHS3d.Nullify(); +} + +//======================================================================= +//function : MakeGeneralAdaptor +//purpose : +//======================================================================= +static Standard_Integer Nulify(Draw_Interpretor& theDI, + Standard_Integer /*theNArg*/, + const char** /*theArgVal*/) +{ + try + { + NulifyAdaptors(); + } + catch (Standard_Failure) + { + theDI << "Error: not all adapters have been nullified.\n"; + } + + theDI << "All adapters have been nullified successful.\n"; + + return 0; +} + +//======================================================================= +//function : MakeGeneralAdaptor +//purpose : +//======================================================================= +static Standard_Integer MakeGeneralAdaptor(Draw_Interpretor& theDI, + Standard_Integer theNArg, + const char** theArgVal) +{ + if (theNArg < 2) + { + theDI << "Use: " << theArgVal[0] << " \n"; + theDI << " * -- - argument for adapter creation. It can be:\n"; + theDI << " - 3D/2D-curve;\n" + " - Surface;\n" + " - Edge;\n" + " - Face;\n" + " - Compound of edge+face (the edge must have 2D-curve on the face)\n"; + return 1; + } + + TopoDS_Edge anE; + TopoDS_Face aF; + const Handle(Geom_Geometry) aG = DrawTrSurf::Get(theArgVal[1]); + const Handle(Geom2d_Curve) aC2d = DrawTrSurf::GetCurve2d(theArgVal[1]); + + if (aG.IsNull() && aC2d.IsNull()) + { + TopoDS_Shape aShape = DBRep::Get(theArgVal[1]); + if (aShape.IsNull()) + { + theDI << "Error: Please set arguments (curve, surface or shape) to adapter creation.\n"; + return 1; + } + + TopExp_Explorer anExp(aShape, TopAbs_FACE); + if (anExp.More()) + { + aF = TopoDS::Face(anExp.Current()); + } + + anExp.Init(aShape, TopAbs_EDGE, TopAbs_FACE); + if (anExp.More()) + { + anE = TopoDS::Edge(anExp.Current()); + } + } + + if (!aC2d.IsNull() || (!aF.IsNull() && !anE.IsNull())) + { + if (!aC2d.IsNull()) + { + AdaptorTypes::anAHC2d = new Geom2dAdaptor_HCurve(aC2d); + if (AdaptorTypes::anAHC2d) + { + theDI << "OK: Adaptor2d_Curve2d has been created.\n"; + } + else + { + theDI << "Error: Wrong type of adapter.\n"; + return 1; + } + } + else + { + AdaptorTypes::anAHC2d = new BRepAdaptor_HCurve2d(BRepAdaptor_Curve2d(anE, aF)); + if (AdaptorTypes::anAHC2d) + { + theDI << "OK: Adaptor2d_Curve2d has been created.\n"; + } + else + { + theDI << "Error: Wrong type of adapter.\n"; + return 1; + } + } + + return 0; + } + + if (!aG.IsNull()) + { + const Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast(aG); + if (!aC.IsNull()) + { + AdaptorTypes::anAHC3d = new GeomAdaptor_HCurve(aC); + if (AdaptorTypes::anAHC3d) + { + theDI << "OK: Adaptor3d_Curve has been created.\n"; + } + else + { + theDI << "Error: Wrong type of adapter.\n"; + return 1; + } + } + else + { + const Handle(Geom_Surface) aS = Handle(Geom_Surface)::DownCast(aG); + if (!aS.IsNull()) + { + AdaptorTypes::anAHS3d = new GeomAdaptor_HSurface(aS); + if (AdaptorTypes::anAHS3d) + { + theDI << "OK: Adaptor3d_Surface has been created.\n"; + } + else + { + theDI << "Error: Wrong type of adapter.\n"; + return 1; + } + } + else + { + theDI << "Error: Please set arguments (curve, surface or shape) to adapter creation.\n"; + return 1; + } + } + } + else //if(aG.IsNull()) + { + if (!anE.IsNull()) + { + if (!aF.IsNull()) + { + AdaptorTypes::anAHC3d = new BRepAdaptor_HCurve(BRepAdaptor_Curve(anE, aF)); + } + else + { + AdaptorTypes::anAHC3d = new BRepAdaptor_HCurve(BRepAdaptor_Curve(anE)); + } + + if (AdaptorTypes::anAHC3d) + { + theDI << "OK: Adaptor3d_Curve has been created.\n"; + } + else + { + theDI << "Error: Wrong type of adapter.\n"; + return 1; + } + } + else + { + AdaptorTypes::anAHS3d = new BRepAdaptor_HSurface(BRepAdaptor_Surface(aF)); + if (AdaptorTypes::anAHS3d) + { + theDI << "OK: Adaptor3d_Surface has been created.\n"; + } + else + { + theDI << "Error: Wrong type of adapter.\n"; + return 1; + } + } + } + + return 0; +} + +//======================================================================= +//function : CheckPeriodic +//purpose : +//======================================================================= +void CheckPeriodic(Draw_Interpretor& theDI) +{ + if (!AdaptorTypes::anAHC2d.IsNull()) + { + if (AdaptorTypes::anAHC2d->IsPeriodic()) + { + theDI << "Adaptor2d_Curve2d is periodic with period " << AdaptorTypes::anAHC2d->Period() << "\n"; + } + else + { + theDI << "Adaptor2d_Curve2d is not periodic\n"; + } + + return; + } + + if (!AdaptorTypes::anAHC3d.IsNull()) + { + if (AdaptorTypes::anAHC3d->IsPeriodic()) + { + theDI << "Adaptor3d_Curve is periodic with period " << AdaptorTypes::anAHC3d->Period() << "\n"; + } + else + { + theDI << "Adaptor3d_Curve is not periodic\n"; + } + + return; + } + + if (AdaptorTypes::anAHS3d->IsUPeriodic()) + { + theDI << "Adaptor3d_Surface is U-periodic with U-period " << AdaptorTypes::anAHS3d->UPeriod() << "\n"; + } + else + { + theDI << "Adaptor3d_Surface is not U-periodic\n"; + } + + if (AdaptorTypes::anAHS3d->IsVPeriodic()) + { + theDI << "Adaptor3d_Surface is U-periodic with V-period " << AdaptorTypes::anAHS3d->VPeriod() << "\n"; + } + else + { + theDI << "Adaptor3d_Surface is not V-periodic\n"; + } +} + +//======================================================================= +//function : CheckPeriodic +//purpose : +//======================================================================= +void CheckClosed(Draw_Interpretor& theDI) +{ + if (!AdaptorTypes::anAHC2d.IsNull()) + { + if (AdaptorTypes::anAHC2d->IsClosed()) + { + theDI << "Adaptor2d_Curve2d is closed\n"; + } + else + { + theDI << "Adaptor2d_Curve2d is not closed\n"; + } + + return; + } + + if (!AdaptorTypes::anAHC3d.IsNull()) + { + if (AdaptorTypes::anAHC3d->IsClosed()) + { + theDI << "Adaptor3d_Curve is closed\n"; + } + else + { + theDI << "Adaptor3d_Curve is not closed\n"; + } + + return; + } + + if (AdaptorTypes::anAHS3d->IsUClosed()) + { + theDI << "Adaptor3d_Surface is U-closed\n"; + } + else + { + theDI << "Adaptor3d_Surface is not U-closed\n"; + } + + if (AdaptorTypes::anAHS3d->IsVClosed()) + { + theDI << "Adaptor3d_Surface is V-closed\n"; + } + else + { + theDI << "Adaptor3d_Surface is not V-closed\n"; + } +} + +//======================================================================= +//function : GetResolution +//purpose : +//======================================================================= +void GetResolution(Draw_Interpretor& theDI, Standard_Real theValue) +{ + if (!AdaptorTypes::anAHC2d.IsNull()) + { + theDI << "Adaptor2d_Curve2d::Resolution = " << + AdaptorTypes::anAHC2d->Resolution(theValue) << "\n"; + return; + } + + if (!AdaptorTypes::anAHC3d.IsNull()) + { + theDI << "Adaptor3d_Curve::Resolution = " << + AdaptorTypes::anAHC3d->Resolution(theValue) << "\n"; + + return; + } + + const Standard_Real aUR = AdaptorTypes::anAHS3d->UResolution(theValue); + const Standard_Real aVR = AdaptorTypes::anAHS3d->VResolution(theValue); + + theDI << "Adaptor3d_Surface: UResolution = " << aUR << "; VResolution = " << aVR << "\n"; +} + +//======================================================================= +//function : GetAdaptorProperty +//purpose : +//======================================================================= +static Standard_Integer GetAdaptorProperty(Draw_Interpretor& theDI, + Standard_Integer theNArg, + const char** theArgVal) +{ + if (theNArg == 1) + { + theDI << "Use: " << theArgVal[0] << " \n"; + theDI << " -isperiodic - Returns IsPeriodic() property and the period;\n"; + theDI << " -isclosed - Returns Adaptor::IsClosed();\n"; + theDI << " -resolution - Returns a value of resolution;\n"; + + return 1; + } + + if (AdaptorTypes::anAHC2d.IsNull() && + AdaptorTypes::anAHC3d.IsNull() && + AdaptorTypes::anAHS3d.IsNull()) + { + theDI << "Adapter is not initialized. Use \"makeadaptor\"-DRAW-command.\n"; + return 1; + } + + for (Standard_Integer i = 1; i < theNArg; i++) + { + if (theArgVal[i][0] != '-') + { + theDI << "Error: " << theArgVal[i] << " is not an option\n"; + return 1; + } + + Standard_Boolean isFound = Standard_False; + + if (!strcmp("-isperiodic", theArgVal[i])) + { + CheckPeriodic(theDI); + isFound = Standard_True; + } + + if (!strcmp("-isclosed", theArgVal[i])) + { + CheckClosed(theDI); + isFound = Standard_True; + } + + if (!strcmp("-resolution", theArgVal[i])) + { + const Standard_Real aT = Draw::Atof(theArgVal[++i]); + GetResolution(theDI, aT); + isFound = Standard_True; + } + + if (isFound) + continue; + + theDI << "Error: Unknown option " << theArgVal[i] << "\n"; + return 1; + } + + return 0; +} + +//======================================================================= +//function : AdaptorCommands +//purpose : +//======================================================================= +void GeomliteTest::AdaptorCommands(Draw_Interpretor& theCommands) +{ + static Standard_Boolean loaded = Standard_False; + if (loaded) return; + loaded = Standard_True; + + const char* g; + + g = "Work with adapters"; + + theCommands.Add("makeadaptor", + "use \"makeadaptor\" w/o any arguments to get help", + __FILE__, + MakeGeneralAdaptor, g); + + theCommands.Add("nulifyadaptors", + "Use: nulifyadaptors", + __FILE__, + Nulify, g); + + theCommands.Add("adaptorproperties", + "Use: \"adaptorproperties\" ", + __FILE__, + GetAdaptorProperty, g); + +} + + + diff --git a/src/HLRBRep/HLRBRep_BCurveTool.hxx b/src/HLRBRep/HLRBRep_BCurveTool.hxx index 5d3a3e3ca8..fdff604e93 100644 --- a/src/HLRBRep/HLRBRep_BCurveTool.hxx +++ b/src/HLRBRep/HLRBRep_BCurveTool.hxx @@ -72,9 +72,15 @@ public: static Standard_Boolean IsClosed (const BRepAdaptor_Curve& C); - static Standard_Boolean IsPeriodic (const BRepAdaptor_Curve& C); - - static Standard_Real Period (const BRepAdaptor_Curve& C); + //! Returns true if the curve is periodic + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). + static Standard_Boolean IsPeriodic (const BRepAdaptor_Curve& C); + + //! Returns the period of the periodic curve. + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). + static Standard_Real Period (const BRepAdaptor_Curve& C); //! Computes the point of parameter U on the curve. static gp_Pnt Value (const BRepAdaptor_Curve& C, const Standard_Real U); diff --git a/src/HLRBRep/HLRBRep_BSurfaceTool.hxx b/src/HLRBRep/HLRBRep_BSurfaceTool.hxx index 47c5168a8e..ba9e06863b 100644 --- a/src/HLRBRep/HLRBRep_BSurfaceTool.hxx +++ b/src/HLRBRep/HLRBRep_BSurfaceTool.hxx @@ -81,13 +81,17 @@ public: static Standard_Boolean IsVClosed (const BRepAdaptor_Surface& S); - static Standard_Boolean IsUPeriodic (const BRepAdaptor_Surface& S); - - static Standard_Real UPeriod (const BRepAdaptor_Surface& S); + //! Returns TRUE if S is U-periodic + static Standard_Boolean IsUPeriodic (const BRepAdaptor_Surface& S); + + //! Returns U-period of S + static Standard_Real UPeriod (const BRepAdaptor_Surface& S); - static Standard_Boolean IsVPeriodic (const BRepAdaptor_Surface& S); + //! Returns TRUE if S is V-periodic + static Standard_Boolean IsVPeriodic (const BRepAdaptor_Surface& S); - static Standard_Real VPeriod (const BRepAdaptor_Surface& S); + //! Returns V-period of S + static Standard_Real VPeriod (const BRepAdaptor_Surface& S); static gp_Pnt Value (const BRepAdaptor_Surface& S, const Standard_Real u, const Standard_Real v); diff --git a/src/HLRBRep/HLRBRep_Curve.hxx b/src/HLRBRep/HLRBRep_Curve.hxx index b457dfd13e..964e620f20 100644 --- a/src/HLRBRep/HLRBRep_Curve.hxx +++ b/src/HLRBRep/HLRBRep_Curve.hxx @@ -133,8 +133,14 @@ public: Standard_Boolean IsClosed() const; + //! Returns true if the curve is periodic + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). Standard_Boolean IsPeriodic() const; + //! Returns the period of the periodic curve. + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). Standard_Real Period() const; //! Computes the point of parameter U on the curve. diff --git a/src/HLRBRep/HLRBRep_CurveTool.hxx b/src/HLRBRep/HLRBRep_CurveTool.hxx index ff54a4169a..4a113e727d 100644 --- a/src/HLRBRep/HLRBRep_CurveTool.hxx +++ b/src/HLRBRep/HLRBRep_CurveTool.hxx @@ -75,9 +75,11 @@ public: static Standard_Boolean IsClosed (const Standard_Address C); - static Standard_Boolean IsPeriodic (const Standard_Address C); + //! Returns TRUE if C is periodic + static Standard_Boolean IsPeriodic (const Standard_Address C); - static Standard_Real Period (const Standard_Address C); + //! Returns the period of C + static Standard_Real Period (const Standard_Address C); //! Computes the point of parameter U on the curve. static gp_Pnt2d Value (const Standard_Address C, const Standard_Real U); diff --git a/src/HLRBRep/HLRBRep_LineTool.hxx b/src/HLRBRep/HLRBRep_LineTool.hxx index a265bc0bd9..b0328f2394 100644 --- a/src/HLRBRep/HLRBRep_LineTool.hxx +++ b/src/HLRBRep/HLRBRep_LineTool.hxx @@ -82,9 +82,11 @@ public: static Standard_Boolean IsClosed (const gp_Lin& C); - static Standard_Boolean IsPeriodic (const gp_Lin& C); + //! Returns TRUE if C is periodic + static Standard_Boolean IsPeriodic (const gp_Lin& C); - static Standard_Real Period (const gp_Lin& C); + //! Always returns 0 + static Standard_Real Period (const gp_Lin& C); //! Computes the point of parameter U on the line. static gp_Pnt Value (const gp_Lin& C, const Standard_Real U); diff --git a/src/HLRBRep/HLRBRep_Surface.hxx b/src/HLRBRep/HLRBRep_Surface.hxx index 5aa2933854..83c2e66f46 100644 --- a/src/HLRBRep/HLRBRep_Surface.hxx +++ b/src/HLRBRep/HLRBRep_Surface.hxx @@ -103,13 +103,26 @@ public: Standard_Boolean IsVClosed() const; - Standard_Boolean IsUPeriodic() const; - - Standard_Real UPeriod() const; - - Standard_Boolean IsVPeriodic() const; - - Standard_Real VPeriod() const; + //! Returns true if the surface is U-periodic + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). + Standard_Boolean IsUPeriodic() const; + + //! Returns the period of this surface in the u + //! parametric direction. + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). + Standard_Real UPeriod() const; + + //! Returns true if the surface is V-periodic + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). + Standard_Boolean IsVPeriodic() const; + + //! Returns the period of this surface in the v parametric direction. + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). + Standard_Real VPeriod() const; //! Computes the point of parameters U,V on the surface. Standard_EXPORT gp_Pnt Value (const Standard_Real U, const Standard_Real V) const; diff --git a/src/HLRBRep/HLRBRep_SurfaceTool.hxx b/src/HLRBRep/HLRBRep_SurfaceTool.hxx index 117842d08d..70e9029aa9 100644 --- a/src/HLRBRep/HLRBRep_SurfaceTool.hxx +++ b/src/HLRBRep/HLRBRep_SurfaceTool.hxx @@ -81,13 +81,17 @@ public: static Standard_Boolean IsVClosed (const Standard_Address S); - static Standard_Boolean IsUPeriodic (const Standard_Address S); + //! Returns TRUE if S is U-periodic + static Standard_Boolean IsUPeriodic (const Standard_Address S); - static Standard_Real UPeriod (const Standard_Address S); + //! Returns U-period of S + static Standard_Real UPeriod (const Standard_Address S); - static Standard_Boolean IsVPeriodic (const Standard_Address S); + //! Returns TRUE if S is V-periodic + static Standard_Boolean IsVPeriodic (const Standard_Address S); - static Standard_Real VPeriod (const Standard_Address S); + //! Returns V-period of S + static Standard_Real VPeriod (const Standard_Address S); static gp_Pnt Value (const Standard_Address S, const Standard_Real u, const Standard_Real v); diff --git a/src/IntCurveSurface/IntCurveSurface_Inter.gxx b/src/IntCurveSurface/IntCurveSurface_Inter.gxx index 02da392539..d942204367 100644 --- a/src/IntCurveSurface/IntCurveSurface_Inter.gxx +++ b/src/IntCurveSurface/IntCurveSurface_Inter.gxx @@ -229,8 +229,10 @@ void IntCurveSurface_Inter::DoNewBounds( Bounds.SetValue(3,v0); Bounds.SetValue(4,v1); - Standard_Boolean isUClosed = (TheSurfaceTool::IsUClosed(surface) || TheSurfaceTool::IsUPeriodic(surface)); - Standard_Boolean isVClosed = (TheSurfaceTool::IsVClosed(surface) || TheSurfaceTool::IsVPeriodic(surface)); + Standard_Boolean isUClosed = (TheSurfaceTool::IsUClosed(surface) || + TheSurfaceTool::IsUPeriodic(surface)); + Standard_Boolean isVClosed = (TheSurfaceTool::IsVClosed(surface) || + TheSurfaceTool::IsVPeriodic(surface)); Standard_Boolean checkU = (isUClosed) ? Standard_False : Standard_True; Standard_Boolean checkV = (isVClosed) ? Standard_False : Standard_True; @@ -291,6 +293,7 @@ void IntCurveSurface_Inter::DoNewBounds( VSmax += 1.5*dV; if(VSmax > v1) VSmax = v1; + // We take full range in case of closed or periodic surface if(checkU) { Bounds.SetValue(1,USmin); Bounds.SetValue(2,USmax); @@ -1292,21 +1295,13 @@ void IntCurveSurface_Inter::AppendPoint(const TheCurve& curve, //-- Test si la courbe est periodique Standard_Real w = lw, u = su, v = sv; - GeomAbs_CurveType aCType = TheCurveTool::GetType(curve); - - if(TheCurveTool::IsPeriodic(curve) - || aCType == GeomAbs_Circle - || aCType == GeomAbs_Ellipse) { + if(TheCurveTool::IsPeriodic(curve)) { w = ElCLib::InPeriod(w, W0, W0 + TheCurveTool::Period(curve)); } if((W0 - w) >= TOLTANGENCY || (w - W1) >= TOLTANGENCY) return; - GeomAbs_SurfaceType aSType = TheSurfaceTool::GetType(surface); - if (TheSurfaceTool::IsUPeriodic(surface) - || aSType == GeomAbs_Cylinder - || aSType == GeomAbs_Cone - || aSType == GeomAbs_Sphere) { + if (TheSurfaceTool::IsUPeriodic(surface)) { u = ElCLib::InPeriod(u, U0, U0 + TheSurfaceTool::UPeriod(surface)); } diff --git a/src/IntCurveSurface/IntCurveSurface_TheHCurveTool.hxx b/src/IntCurveSurface/IntCurveSurface_TheHCurveTool.hxx index ed954b5a09..835d70a7ad 100644 --- a/src/IntCurveSurface/IntCurveSurface_TheHCurveTool.hxx +++ b/src/IntCurveSurface/IntCurveSurface_TheHCurveTool.hxx @@ -72,9 +72,11 @@ public: static Standard_Boolean IsClosed (const Handle(Adaptor3d_HCurve)& C); - static Standard_Boolean IsPeriodic (const Handle(Adaptor3d_HCurve)& C); + //! Returns TRUE if C is periodic + static Standard_Boolean IsPeriodic (const Handle(Adaptor3d_HCurve)& C); - static Standard_Real Period (const Handle(Adaptor3d_HCurve)& C); + //! Returns the period of C + static Standard_Real Period (const Handle(Adaptor3d_HCurve)& C); //! Computes the point of parameter U on the curve. static gp_Pnt Value (const Handle(Adaptor3d_HCurve)& C, const Standard_Real U); diff --git a/src/IntPatch/IntPatch_HCurve2dTool.hxx b/src/IntPatch/IntPatch_HCurve2dTool.hxx index 7c75083ce2..7c6bf0bd85 100644 --- a/src/IntPatch/IntPatch_HCurve2dTool.hxx +++ b/src/IntPatch/IntPatch_HCurve2dTool.hxx @@ -71,9 +71,11 @@ public: static Standard_Boolean IsClosed (const Handle(Adaptor2d_HCurve2d)& C); - static Standard_Boolean IsPeriodic (const Handle(Adaptor2d_HCurve2d)& C); + //! Returns TRUE if C is periodic + static Standard_Boolean IsPeriodic (const Handle(Adaptor2d_HCurve2d)& C); - static Standard_Real Period (const Handle(Adaptor2d_HCurve2d)& C); + //! Returns the period of C + static Standard_Real Period (const Handle(Adaptor2d_HCurve2d)& C); //! Computes the point of parameter U on the curve. static gp_Pnt2d Value (const Handle(Adaptor2d_HCurve2d)& C, const Standard_Real U); diff --git a/src/IntPatch/IntPatch_Intersection.cxx b/src/IntPatch/IntPatch_Intersection.cxx index f749781335..77f7fc3835 100644 --- a/src/IntPatch/IntPatch_Intersection.cxx +++ b/src/IntPatch/IntPatch_Intersection.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -1429,11 +1430,8 @@ void IntPatch_Intersection::GeomGeomPerfom(const Handle(Adaptor3d_HSurface)& the aBx1.Enlarge(Precision::PConfusion()); aBx2.Enlarge(Precision::PConfusion()); - const Standard_Real - anArrOfPeriod[4] = {theS1->IsUPeriodic()? theS1->UPeriod() : 0.0, - theS1->IsVPeriodic()? theS1->VPeriod() : 0.0, - theS2->IsUPeriodic()? theS2->UPeriod() : 0.0, - theS2->IsVPeriodic()? theS2->VPeriod() : 0.0}; + Standard_Real anArrOfPeriod[4]; + IntSurf::SetPeriod(theS1, theS2, anArrOfPeriod); NCollection_List aListOfCriticalPoints; diff --git a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx index 054467b1eb..2fa30d5617 100644 --- a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx +++ b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1587,10 +1588,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& VmaxLig2 = Surf2->LastVParameter(); Standard_Real Periods [4]; - Periods[0] = (Surf1->IsUPeriodic())? Surf1->UPeriod() : 0.; - Periods[1] = (Surf1->IsVPeriodic())? Surf1->VPeriod() : 0.; - Periods[2] = (Surf2->IsUPeriodic())? Surf2->UPeriod() : 0.; - Periods[3] = (Surf2->IsVPeriodic())? Surf2->VPeriod() : 0.; + IntSurf::SetPeriod(Surf1, Surf2, Periods); IntSurf_ListIteratorOfListOfPntOn2S IterLOP1(LOfPnts); if (Surf1->IsUClosed() || Surf1->IsVClosed() || @@ -1996,33 +1994,13 @@ void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1, const Handle(Adaptor3d_HSurface)& Surf2, IntPatch_SequenceOfLine& aSLin) { - Standard_Boolean bIsPeriodic[4], bModified, bIsNull, bIsPeriod; + Standard_Boolean bModified, bIsNull, bIsPeriod; Standard_Integer i, j, k, aNbLines, aNbPx, aIndx, aIndq; Standard_Real aPeriod[4], dPeriod[4], ux[4], uq[4], aEps, du; // aEps=Precision::Confusion(); // - for (k=0; k<4; ++k) { - aPeriod[k]=0.; - } - // - bIsPeriodic[0]=Surf1->IsUPeriodic(); - bIsPeriodic[1]=Surf1->IsVPeriodic(); - bIsPeriodic[2]=Surf2->IsUPeriodic(); - bIsPeriodic[3]=Surf2->IsVPeriodic(); - // - if (bIsPeriodic[0]){ - aPeriod[0]=Surf1->UPeriod(); - } - if (bIsPeriodic[1]){ - aPeriod[1]=Surf1->VPeriod(); - } - if (bIsPeriodic[2]){ - aPeriod[2]=Surf2->UPeriod(); - } - if (bIsPeriodic[3]){ - aPeriod[3]=Surf2->VPeriod(); - } + IntSurf::SetPeriod(Surf1, Surf2, aPeriod); // for (k=0; k<4; ++k) { dPeriod[k]=0.25*aPeriod[k]; @@ -2057,7 +2035,8 @@ void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1, bIsNull=Standard_False; bIsPeriod=Standard_False; // - if (!bIsPeriodic[k]) { + if(aPeriod[k] == 0.0) + { continue; } // @@ -2162,10 +2141,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur D2->VParameters(aVpars2); Standard_Real Periods [4]; - Periods[0] = (Surf1->IsUPeriodic())? Surf1->UPeriod() : 0.; - Periods[1] = (Surf1->IsVPeriodic())? Surf1->VPeriod() : 0.; - Periods[2] = (Surf2->IsUPeriodic())? Surf2->UPeriod() : 0.; - Periods[3] = (Surf2->IsVPeriodic())? Surf2->VPeriod() : 0.; + IntSurf::SetPeriod(Surf1, Surf2, Periods); //--------------------------------------------- if((NbU1*NbV1<=Limit && NbV2*NbU2<=Limit)) diff --git a/src/IntPatch/IntPatch_RstInt.cxx b/src/IntPatch/IntPatch_RstInt.cxx index 0475179b24..bd3588d662 100644 --- a/src/IntPatch/IntPatch_RstInt.cxx +++ b/src/IntPatch/IntPatch_RstInt.cxx @@ -1002,90 +1002,9 @@ void IntPatch_RstInt::PutVertexOnLine (const Handle(IntPatch_Line)& L, //-- On reprend la ligne et on recale les parametres des vertex. //-- if (typL == IntPatch_Walking) { - Standard_Real pu1,pv1,pu2,pv2; - pu1=pv1=pu2=pv2=0.0; - switch(TypeS1) { - case GeomAbs_Cylinder: - case GeomAbs_Cone: - case GeomAbs_Sphere: - pu1=M_PI+M_PI; - break; - case GeomAbs_Torus: - pu1=pv1=M_PI+M_PI; - break; - default: - { - if( Surf1->IsUPeriodic()) { - pu1=Surf1->UPeriod(); - } - else if(Surf1->IsUClosed()) { - pu1=Surf1->LastUParameter() - Surf1->FirstUParameter(); - //cout<<" UClosed1 "<IsVPeriodic()) { - pv1=Surf1->VPeriod(); - } - else if(Surf1->IsVClosed()) { - pv1=Surf1->LastVParameter() - Surf1->FirstVParameter(); - //cout<<" VClosed1 "<IsUPeriodic()) { - pu2=Surf2->UPeriod(); - } - else if(Surf2->IsUClosed()) { - pu2=Surf2->LastUParameter() - Surf2->FirstUParameter(); - //cout<<" UClosed2 "<IsVPeriodic()) { - pv2=Surf2->VPeriod(); - } - else if(Surf2->IsVClosed()) { - pv2=Surf2->LastVParameter() - Surf2->FirstVParameter(); - //cout<<" VClosed2 "<LastUParameter() - Surf1->FirstUParameter(); - pu1+=pu1; - } - if(pu2==0) { - pu2=Surf2->LastUParameter() - Surf2->FirstUParameter(); - pu2+=pu2; - } - if(pv1==0) { - pv1=Surf1->LastVParameter() - Surf1->FirstVParameter(); - pv1+=pv1; - } - if(pv2==0) { - pv2=Surf2->LastVParameter() - Surf2->FirstVParameter(); - pv2+=pv2; - } -*/ - - wlin->SetPeriod(pu1,pv1,pu2,pv2); + Standard_Real aPeriods[4]; + IntSurf::SetPeriod(Surf1, Surf2, aPeriods); + wlin->SetPeriod(aPeriods[0], aPeriods[1], aPeriods[2], aPeriods[3]); wlin->ComputeVertexParameters(Tol); } else { diff --git a/src/IntPatch/IntPatch_SpecialPoints.cxx b/src/IntPatch/IntPatch_SpecialPoints.cxx index 7cda071df3..fafe28e9fb 100644 --- a/src/IntPatch/IntPatch_SpecialPoints.cxx +++ b/src/IntPatch/IntPatch_SpecialPoints.cxx @@ -1020,16 +1020,19 @@ Standard_Boolean IntPatch_SpecialPoints:: // with step greater than PI/4. const Standard_Real aPeriod = (theSPType == IntPatch_SPntPole)? M_PI_2 : 2.0*M_PI; - - const Standard_Real aUpPeriod = thePSurf->IsUPeriodic() ? thePSurf->UPeriod() : 0.0; - const Standard_Real aUqPeriod = theQSurf->IsUPeriodic() ? aPeriod : 0.0; - const Standard_Real aVpPeriod = thePSurf->IsVPeriodic() ? thePSurf->VPeriod() : 0.0; - const Standard_Real aVqPeriod = theQSurf->IsVPeriodic() ? aPeriod : 0.0; - - const Standard_Real anArrOfPeriod[4] = {theIsReversed? aUpPeriod : aUqPeriod, - theIsReversed? aVpPeriod : aVqPeriod, - theIsReversed? aUqPeriod : aUpPeriod, - theIsReversed? aVqPeriod : aVpPeriod}; + Standard_Real anArrOfPeriod[4]; + if(theIsReversed) + { + IntSurf::SetPeriod(thePSurf, theQSurf, anArrOfPeriod); + if(anArrOfPeriod[2] > 0.0) anArrOfPeriod[2] = aPeriod; + if(anArrOfPeriod[3] > 0.0) anArrOfPeriod[3] = aPeriod; + } + else + { + IntSurf::SetPeriod(theQSurf, thePSurf, anArrOfPeriod); + if(anArrOfPeriod[0] > 0.0) anArrOfPeriod[0] = aPeriod; + if(anArrOfPeriod[1] > 0.0) anArrOfPeriod[1] = aPeriod; + } AdjustPointAndVertex(theRefPt, anArrOfPeriod, theNewPoint); return Standard_True; diff --git a/src/IntPatch/IntPatch_WLineTool.cxx b/src/IntPatch/IntPatch_WLineTool.cxx index f3200190ac..60b339f548 100644 --- a/src/IntPatch/IntPatch_WLineTool.cxx +++ b/src/IntPatch/IntPatch_WLineTool.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -1466,10 +1467,8 @@ void IntPatch_WLineTool::JoinWLines(IntPatch_SequenceOfLine& theSlin, const Standard_Real aMinRad = 1.0e-3*Min(theS1->Cylinder().Radius(), theS2->Cylinder().Radius()); - const Standard_Real anArrPeriods[4] = {theS1->IsUPeriodic() ? theS1->UPeriod() : 0.0, - theS1->IsVPeriodic() ? theS1->VPeriod() : 0.0, - theS2->IsUPeriodic() ? theS2->UPeriod() : 0.0, - theS2->IsVPeriodic() ? theS2->VPeriod() : 0.0}; + Standard_Real anArrPeriods[4]; + IntSurf::SetPeriod(theS1, theS2, anArrPeriods); const Standard_Real anArrFBonds[4] = {theS1->FirstUParameter(), theS1->FirstVParameter(), theS2->FirstUParameter(), theS2->FirstVParameter()}; diff --git a/src/IntTools/IntTools_FaceFace.cxx b/src/IntTools/IntTools_FaceFace.cxx index 759e5dda91..5c18df924d 100644 --- a/src/IntTools/IntTools_FaceFace.cxx +++ b/src/IntTools/IntTools_FaceFace.cxx @@ -1879,8 +1879,8 @@ Handle(Geom_Curve) MakeBSpline (const Handle(IntPatch_WLine)& WL, } } // - isuperiodic = anAdaptorSurface.IsUPeriodic(); - isvperiodic = anAdaptorSurface.IsVPeriodic(); + isuperiodic = (anAdaptorSurface.IsUPeriodic() && anAdaptorSurface.IsUClosed()); + isvperiodic = (anAdaptorSurface.IsVPeriodic() && anAdaptorSurface.IsVClosed()); // aType=anAdaptorSurface.GetType(); if((aType==GeomAbs_BezierSurface) || @@ -1891,6 +1891,9 @@ Handle(Geom_Curve) MakeBSpline (const Handle(IntPatch_WLine)& WL, enlarge=Standard_True; } // + + Standard_Real aPar1 = theumin, aPar2 = theumax; + if(!isuperiodic && enlarge) { if(!Precision::IsInfinite(theumin) && @@ -1906,6 +1909,25 @@ Handle(Geom_Curve) MakeBSpline (const Handle(IntPatch_WLine)& WL, else theumax = usup; } + + if (theumin > theumax) + { + // It is possible if the face is out + // of the surface's domain. E.g. + // uinf == 0, usup == 1 and initial values + // theumin == -0.5 and theumax == -0.2. + // "delta" is a small value (~ 1.0e-7) + // + // After this correction, + // theumin == 0, theumax = -0.2. + // + //See testgrid bugs modalg_4 bug6272* + + theumin = aPar1; + theumax = aPar2; + } + // + aPar1 = thevmin, aPar2 = thevmax; // if(!isvperiodic && enlarge) { if(!Precision::IsInfinite(thevmin) && @@ -1923,6 +1945,23 @@ Handle(Geom_Curve) MakeBSpline (const Handle(IntPatch_WLine)& WL, thevmax = vsup; } } + + if (thevmin > thevmax) + { + // It is possible if the face is out + // of the surface's domain. E.g. + // uinf == 0, usup == 1 and initial values + // theumin == -0.5 and theumax == -0.2. + // "delta" is a small value (~ 1.0e-7) + // + // After this correction, + // theumin == 0, theumax = -0.2. + // + //See testgrid bugs modalg_4 bug6272* + + thevmin = aPar1; + thevmax = aPar2; + } // if(isuperiodic || isvperiodic) { Standard_Boolean correct = Standard_False; @@ -2719,10 +2758,7 @@ Standard_Real MaxDistance(const Handle(Geom_Curve)& theC, // adjust domain for periodic surfaces TopLoc_Location aLoc; - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace, aLoc); - if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { - aSurf = (Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf))->BasisSurface(); - } + const Handle(Geom_Surface) &aSurf = BRep_Tool::Surface(aFace, aLoc); gp_Pnt2d pnt = aPC->Value((fp+lp)/2); Standard_Real u,v; pnt.Coord(u,v); diff --git a/src/IntTools/IntTools_Tools.cxx b/src/IntTools/IntTools_Tools.cxx index 46c891d395..5e34b45e87 100644 --- a/src/IntTools/IntTools_Tools.cxx +++ b/src/IntTools/IntTools_Tools.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -83,37 +84,6 @@ static return !bFlag; } -//======================================================================= -//function : IsClosed -//purpose : -//======================================================================= - Standard_Boolean IntTools_Tools::IsClosed (const Handle(Geom_Curve)& aC3D) -{ - Standard_Boolean bRet; - Standard_Real aF, aL, aDist, aPC; - gp_Pnt aP1, aP2; - - Handle (Geom_BoundedCurve) aGBC= - Handle (Geom_BoundedCurve)::DownCast(aC3D); - if (aGBC.IsNull()) { - return Standard_False; - } - - aF=aC3D->FirstParameter(); - aL=aC3D-> LastParameter(); - - aC3D->D0(aF, aP1); - aC3D->D0(aL, aP2); - - - // - aPC=Precision::Confusion(); - aPC=aPC*aPC; - aDist=aP1.SquareDistance(aP2); - bRet=aDist0.0001*pasuv[3]) ResoV2=0.00001*pasuv[3]; - if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro1)==Standard_False) { - //UM1+=KELARG*pasuv[0]; Um1-=KELARG*pasuv[0]; - } - else { + if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro1)) { Standard_Real t = UM1-Um1; if(t dumax && adSurf.IsUPeriodic()) { Standard_Real aX1 = aPBound2d.X(); - Standard_Real aShift = ShapeAnalysis::AdjustToPeriod(aX1, adSurf.FirstUParameter(), adSurf.LastUParameter()); + Standard_Real aShift = + ShapeAnalysis::AdjustToPeriod(aX1, adSurf.FirstUParameter(), + adSurf.FirstUParameter() + adSurf.UPeriod()); aX1 += aShift; aPBound2d.SetX(aX1); Standard_Real aX2 = p2d.X(); - aShift = ShapeAnalysis::AdjustToPeriod(aX2, adSurf.FirstUParameter(), adSurf.LastUParameter()); + aShift = ShapeAnalysis::AdjustToPeriod(aX2, adSurf.FirstUParameter(), + adSurf.FirstUParameter() + adSurf.UPeriod()); aX2 += aShift; dumin = Abs(aX2 - aX1); if (dumin > dumax && (Abs(dumin - adSurf.UPeriod()) < Precision::PConfusion()) ) @@ -637,11 +640,14 @@ Standard_Boolean Project(const TopoDS_Vertex& V, if (dvmin > dvmax && adSurf.IsVPeriodic()) { Standard_Real aY1 = aPBound2d.Y(); - Standard_Real aShift = ShapeAnalysis::AdjustToPeriod(aY1, adSurf.FirstVParameter(), adSurf.LastVParameter()); + Standard_Real aShift = + ShapeAnalysis::AdjustToPeriod(aY1, adSurf.FirstVParameter(), + adSurf.FirstUParameter() + adSurf.VPeriod()); aY1 += aShift; aPBound2d.SetY(aY1); Standard_Real aY2 = p2d.Y(); - aShift = ShapeAnalysis::AdjustToPeriod(aY2, adSurf.FirstVParameter(), adSurf.LastVParameter()); + aShift = ShapeAnalysis::AdjustToPeriod(aY2, adSurf.FirstVParameter(), + adSurf.FirstUParameter() + adSurf.VPeriod()); aY2 += aShift; dvmin = Abs(aY1 - aY2); if (dvmin > dvmax && ( Abs(dvmin - adSurf.VPeriod()) < Precision::Confusion()) ) diff --git a/src/MAT2d/MAT2d_Tool2d.cxx b/src/MAT2d/MAT2d_Tool2d.cxx index eb5b68352e..c08f9d3971 100644 --- a/src/MAT2d/MAT2d_Tool2d.cxx +++ b/src/MAT2d/MAT2d_Tool2d.cxx @@ -506,8 +506,8 @@ Standard_Boolean MAT2d_Tool2d::TrimBisector Handle(Geom2d_TrimmedCurve) bisector = ChangeGeomBis(abisector->BisectorNumber()).ChangeValue(); - if(bisector->BasisCurve()->IsPeriodic() && param == Precision::Infinite()) { - param = bisector->FirstParameter() + 2*M_PI; + if(bisector->IsPeriodic()) { + param = Min(bisector->FirstParameter() + bisector->Period(), param); } if (param > bisector->BasisCurve()->LastParameter()) { param = bisector->BasisCurve()->LastParameter(); @@ -527,8 +527,8 @@ Standard_Boolean MAT2d_Tool2d::TrimBisector const Standard_Integer apoint) { Standard_Real Param; - Handle(Geom2d_TrimmedCurve) Bisector = - ChangeGeomBis(abisector->BisectorNumber()).ChangeValue(); + const Handle(Geom2d_TrimmedCurve) &Bisector = + ChangeGeomBis(abisector->BisectorNumber()).ChangeValue(); Handle(Bisector_Curve) Bis = Handle(Bisector_Curve):: DownCast(Bisector->BasisCurve()); @@ -536,8 +536,8 @@ Standard_Boolean MAT2d_Tool2d::TrimBisector // Param = ParameterOnCurve(Bisector,theGeomPnts.Value(apoint)); Param = Bis->Parameter(GeomPnt (apoint)); - if (Bisector->BasisCurve()->IsPeriodic()) { - if (Bisector->FirstParameter() > Param) Param = Param + 2*M_PI; + if (Bisector->IsPeriodic()) { + if (Bisector->FirstParameter() > Param) Param += Bisector->Period(); } if(Bisector->FirstParameter() >= Param)return Standard_False; if(Bisector->LastParameter() < Param)return Standard_False; @@ -587,7 +587,7 @@ Standard_Boolean MAT2d_Tool2d::Projection (const Standard_Integer IEdge , INext = (IEdge == theCircuit->NumberOfItems()) ? 1 : (IEdge + 1); if (theCircuit->ConnexionOn(INext)) { ParamMax = theCircuit->Connexion(INext)->ParameterOnFirst(); - if (Curve->BasisCurve()->IsPeriodic()){ + if (Curve->IsPeriodic()){ ElCLib::AdjustPeriodic(0.,2*M_PI,Eps,ParamMin,ParamMax); } } @@ -1316,7 +1316,7 @@ IntRes2d_Domain Domain(const Handle(Geom2d_TrimmedCurve)& Bisector1, IntRes2d_Domain Domain1(Bisector1->Value(Param1),Param1,Tolerance, Bisector1->Value(Param2),Param2,Tolerance); - if(Bisector1->BasisCurve()->IsPeriodic()) { + if(Bisector1->IsPeriodic()) { Domain1.SetEquivalentParameters(0.,2.*M_PI); } return Domain1; diff --git a/src/ProjLib/ProjLib_ComputeApprox.cxx b/src/ProjLib/ProjLib_ComputeApprox.cxx index 5090998187..913751706a 100644 --- a/src/ProjLib/ProjLib_ComputeApprox.cxx +++ b/src/ProjLib/ProjLib_ComputeApprox.cxx @@ -315,11 +315,13 @@ static void Function_SetUVBounds(Standard_Real& myU1, Step = Function_ComputeStep(myCurve, R); } // - Standard_Boolean isclandper = (!(myCurve->IsClosed()) && !(myCurve->IsPeriodic())); + Standard_Boolean isclandper = !(myCurve->IsClosed() || myCurve->IsPeriodic()); Standard_Boolean isFirst = Standard_True; for(Standard_Real par = W1 + Step; par <= W2; par += Step) { - if(!isclandper) par += Step; + if(myCurve->IsPeriodic()) + par += Step; + P = myCurve->Value(par); ElSLib::Parameters( Cone, P, U, V); U += Delta; @@ -839,7 +841,7 @@ static void Function_SetUVBounds(Standard_Real& myU1, // // //======================================================================= -//classn : ProjLib_Function +//class : ProjLib_Function //purpose : //======================================================================= class ProjLib_Function : public AppCont_Function @@ -848,25 +850,25 @@ class ProjLib_Function : public AppCont_Function Handle(Adaptor3d_HSurface) mySurface; Standard_Boolean myIsPeriodic[2]; Standard_Real myPeriod[2]; - public : +public: - Standard_Real myU1,myU2,myV1,myV2; - Standard_Boolean UCouture,VCouture; + Standard_Real myU1, myU2, myV1, myV2; + Standard_Boolean UCouture, VCouture; - ProjLib_Function(const Handle(Adaptor3d_HCurve)& C, + ProjLib_Function(const Handle(Adaptor3d_HCurve)& C, const Handle(Adaptor3d_HSurface)& S) -: myCurve(C), - mySurface(S), - myU1(0.0), - myU2(0.0), - myV1(0.0), - myV2(0.0), - UCouture(Standard_False), - VCouture(Standard_False) + : myCurve(C), + mySurface(S), + myU1(0.0), + myU2(0.0), + myV1(0.0), + myV2(0.0), + UCouture(Standard_False), + VCouture(Standard_False) { myNbPnt = 0; myNbPnt2d = 1; - Function_SetUVBounds(myU1,myU2,myV1,myV2,UCouture,VCouture,myCurve,mySurface); + Function_SetUVBounds(myU1, myU2, myV1, myV2, UCouture, VCouture, myCurve, mySurface); myIsPeriodic[0] = mySurface->IsUPeriodic(); myIsPeriodic[1] = mySurface->IsVPeriodic(); @@ -881,27 +883,27 @@ class ProjLib_Function : public AppCont_Function myPeriod[1] = 0.0; } - void PeriodInformation(const Standard_Integer theDimIdx, - Standard_Boolean& IsPeriodic, - Standard_Real& thePeriod) const + virtual void PeriodInformation(const Standard_Integer theDimIdx, + Standard_Boolean& IsPeriodic, + Standard_Real& thePeriod) const Standard_OVERRIDE { IsPeriodic = myIsPeriodic[theDimIdx - 1]; thePeriod = myPeriod[theDimIdx - 1]; } - Standard_Real FirstParameter() const + virtual Standard_Real FirstParameter() const Standard_OVERRIDE { return (myCurve->FirstParameter()); } - Standard_Real LastParameter() const + virtual Standard_Real LastParameter() const Standard_OVERRIDE { return (myCurve->LastParameter()); } - Standard_Boolean Value(const Standard_Real theT, - NCollection_Array1& thePnt2d, - NCollection_Array1& /*thePnt*/) const + virtual Standard_Boolean Value(const Standard_Real theT, + NCollection_Array1& thePnt2d, + NCollection_Array1& /*thePnt*/) const Standard_OVERRIDE { thePnt2d(1) = Function_Value(theT, myCurve, mySurface, myU1, myU2, myV1, myV2, UCouture, VCouture); return Standard_True; @@ -912,13 +914,13 @@ class ProjLib_Function : public AppCont_Function return Function_Value(theT, myCurve, mySurface, myU1, myU2, myV1, myV2, UCouture, VCouture); } - Standard_Boolean D1(const Standard_Real theT, - NCollection_Array1& theVec2d, - NCollection_Array1& /*theVec*/) const + virtual Standard_Boolean D1(const Standard_Real theT, + NCollection_Array1& theVec2d, + NCollection_Array1& /*theVec*/) const Standard_OVERRIDE { gp_Pnt2d aPnt2d; gp_Vec2d aVec2d; - Standard_Boolean isOk = Function_D1(theT, aPnt2d,aVec2d, myCurve, mySurface, myU1, myU2, myV1, myV2, UCouture, VCouture); + Standard_Boolean isOk = Function_D1(theT, aPnt2d, aVec2d, myCurve, mySurface, myU1, myU2, myV1, myV2, UCouture, VCouture); theVec2d(1) = aVec2d; return isOk; } diff --git a/src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx b/src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx index c104aa09ee..6f164b9ffe 100644 --- a/src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx +++ b/src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx @@ -93,65 +93,6 @@ struct aFuncStruct Standard_Real myPeriod[2]; // U and V period correspondingly. }; -//======================================================================= -//function : computePeriodicity -//purpose : Compute period information on adaptor. -//======================================================================= -static void computePeriodicity(const Handle(Adaptor3d_HSurface)& theSurf, - Standard_Real &theUPeriod, - Standard_Real &theVPeriod) -{ - theUPeriod = 0.0; - theVPeriod = 0.0; - - // Compute once information about periodicity. - // Param space may be reduced in case of rectangular trimmed surface, - // in this case really trimmed bounds should be set as unperiodic. - Standard_Real aTrimF, aTrimL, aBaseF, aBaseL, aDummyF, aDummyL; - Handle(Geom_Surface) aS = GeomAdaptor::MakeSurface(theSurf->Surface(), Standard_False); // Not trim. - // U param space. - if (theSurf->IsUPeriodic()) - { - theUPeriod = theSurf->UPeriod(); - } - else if(theSurf->IsUClosed()) - { - theUPeriod = theSurf->LastUParameter() - theSurf->FirstUParameter(); - } - if (theUPeriod != 0.0) - { - aTrimF = theSurf->FirstUParameter(); // Trimmed first - aTrimL = theSurf->LastUParameter(); // Trimmed last - aS->Bounds(aBaseF, aBaseL, aDummyF, aDummyL); // Non-trimmed values. - if (Abs (aBaseF - aTrimF) + Abs (aBaseL - aTrimL) > Precision::PConfusion()) - { - // Param space reduced. - theUPeriod = 0.0; - } - } - - // V param space. - if (theSurf->IsVPeriodic()) - { - theVPeriod = theSurf->VPeriod(); - } - else if(theSurf->IsVClosed()) - { - theVPeriod = theSurf->LastVParameter() - theSurf->FirstVParameter(); - } - if (theVPeriod != 0.0) - { - aTrimF = theSurf->FirstVParameter(); // Trimmed first - aTrimL = theSurf->LastVParameter(); // Trimmed last - aS->Bounds(aDummyF, aDummyL, aBaseF, aBaseL); // Non-trimmed values. - if (Abs (aBaseF - aTrimF) + Abs (aBaseL - aTrimL) > Precision::PConfusion()) - { - // Param space reduced. - theVPeriod = 0.0; - } - } -} - //======================================================================= //function : aFuncValue //purpose : compute functional value in (theU,theV) point @@ -291,14 +232,13 @@ static gp_Pnt2d Function_Value(const Standard_Real theU, // Non-analytical case. Standard_Real Dist2Min = RealLast(); - Standard_Real uperiod = theData.myPeriod[0], - vperiod = theData.myPeriod[1], - u, v; + const Standard_Real uperiod = theData.myPeriod[0], + vperiod = theData.myPeriod[1]; // U0 and V0 are the points within the initialized period. if(U0 < Uinf) { - if(!uperiod) + if(uperiod == 0.0) U0 = Uinf; else { @@ -308,7 +248,7 @@ static gp_Pnt2d Function_Value(const Standard_Real theU, } if(U0 > Usup) { - if(!uperiod) + if (uperiod == 0.0) U0 = Usup; else { @@ -318,7 +258,7 @@ static gp_Pnt2d Function_Value(const Standard_Real theU, } if(V0 < Vinf) { - if(!vperiod) + if(vperiod == 0.0) V0 = Vinf; else { @@ -328,7 +268,7 @@ static gp_Pnt2d Function_Value(const Standard_Real theU, } if(V0 > Vsup) { - if(!vperiod) + if(vperiod == 0.0) V0 = Vsup; else { @@ -371,6 +311,7 @@ static gp_Pnt2d Function_Value(const Standard_Real theU, locext.Perform(p, U0, V0); if (locext.IsDone()) { + Standard_Real u, v; locext.Point().Parameter(u, v); Dist2Min = anOrthogSqValue(p, theData.mySurf, u, v); if (Dist2Min < theData.mySqProjOrtTol && // Point is projection. @@ -395,6 +336,7 @@ static gp_Pnt2d Function_Value(const Standard_Real theU, GoodValue = i; } } + Standard_Real u, v; ext.Point(GoodValue).Parameter(u, v); Dist2Min = anOrthogSqValue(p, theData.mySurf, u, v); if (Dist2Min < theData.mySqProjOrtTol && // Point is projection. @@ -429,7 +371,8 @@ class ProjLib_PolarFunction : public AppCont_Function myNbPnt = 0; myNbPnt2d = 1; - computePeriodicity(Surf, myStruct.myPeriod[0], myStruct.myPeriod[1]); + myStruct.myPeriod[0] = (Surf->IsUPeriodic() && Surf->IsUClosed()) ? Surf->UPeriod() : 0.0; + myStruct.myPeriod[1] = (Surf->IsVPeriodic() && Surf->IsVClosed()) ? Surf->VPeriod() : 0.0; myStruct.myCurve = C; myStruct.myInitCurve2d = InitialCurve2d; @@ -848,8 +791,9 @@ Handle(Geom2d_BSplineCurve) ProjLib_ComputeApproxOnPolarSurface::Perform } } - Standard_Real anUPeriod, anVPeriod; - computePeriodicity(S, anUPeriod, anVPeriod); + const Standard_Real anUPeriod = (S->IsUPeriodic() && S->IsUClosed()) ? S->UPeriod() : 0.0; + const Standard_Real anVPeriod = (S->IsVPeriodic() && S->IsVClosed()) ? S->VPeriod() : 0.0; + Standard_Integer NbC = LOfBSpline2d.Extent(); Handle(Geom2d_BSplineCurve) CurBS; CurBS = Handle(Geom2d_BSplineCurve)::DownCast(LOfBSpline2d.First()); @@ -917,8 +861,8 @@ Handle(Adaptor2d_HCurve2d) DistTol3d = myMaxDist; } Standard_Real DistTol3d2 = DistTol3d * DistTol3d; - Standard_Real uperiod = 0.0, vperiod = 0.0; - computePeriodicity(Surf, uperiod, vperiod); + const Standard_Real uperiod = (Surf->IsUPeriodic() && Surf->IsUClosed()) ? Surf->UPeriod() : 0.0; + const Standard_Real vperiod = (Surf->IsVPeriodic() && Surf->IsVClosed()) ? Surf->VPeriod() : 0.0; // NO myTol is Tol2d !!!! //Standard_Real TolU = myTolerance, TolV = myTolerance; diff --git a/src/ProjLib/ProjLib_ProjectOnPlane.hxx b/src/ProjLib/ProjLib_ProjectOnPlane.hxx index e3d50ce496..495a271299 100644 --- a/src/ProjLib/ProjLib_ProjectOnPlane.hxx +++ b/src/ProjLib/ProjLib_ProjectOnPlane.hxx @@ -120,8 +120,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the projection result is periodic Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns the period of the projection result Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve. diff --git a/src/ProjLib/ProjLib_ProjectedCurve.hxx b/src/ProjLib/ProjLib_ProjectedCurve.hxx index c788587cd3..3bc0a38735 100644 --- a/src/ProjLib/ProjLib_ProjectedCurve.hxx +++ b/src/ProjLib/ProjLib_ProjectedCurve.hxx @@ -146,8 +146,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the projection result is periodic Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! returns the period of the projection result Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve. diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index 33a58bf43f..fc249ca7d4 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -3024,6 +3024,83 @@ static Standard_Integer OCC29311 (Draw_Interpretor& theDI, Standard_Integer theA return 0; } +//======================================================================= +//function : OCC29115c +//purpose : +//======================================================================= +#include +static Standard_Integer OCC29115c(Draw_Interpretor&theDI, Standard_Integer, const char** theArgV) +{ + const Standard_Real aUf = Draw::Atof(theArgV[2]), + aUl = Draw::Atof(theArgV[3]); + const Handle(Geom2d_Curve) aC2d = DrawTrSurf::GetCurve2d(theArgV[1]); + + if (!aC2d.IsNull()) + { + if (GeomLib::IsTrimAllowed(aC2d, aUf, aUl)) + { + theDI << "Trimm is possible.\n"; + } + else + { + theDI << "Trimm is not possible.\n"; + } + + return 0; + } + + const Handle(Geom_Curve) aC3d = DrawTrSurf::GetCurve(theArgV[1]); + + if (aC3d.IsNull()) + return 1; + + if (GeomLib::IsTrimAllowed(aC3d, aUf, aUl)) + { + theDI << "Trimm is possible.\n"; + } + else + { + theDI << "Trimm is not possible.\n"; + } + + return 0; +} + +//======================================================================= +//function : OCC29115s +//purpose : +//======================================================================= +static Standard_Integer OCC29115s(Draw_Interpretor&theDI, Standard_Integer, const char** theArgV) +{ + const Standard_Real aUf = Draw::Atof(theArgV[2]), + aUl = Draw::Atof(theArgV[3]), + aVf = Draw::Atof(theArgV[4]), + aVl = Draw::Atof(theArgV[5]); + + const Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(theArgV[1]); + const GeomAdaptor_Surface anAS(aS); + + if (GeomLib::IsUTrimAllowed(anAS, aUf, aUl)) + { + theDI << "U-trimm is possible.\n"; + } + else + { + theDI << "U-trimm is not possible.\n"; + } + + if (GeomLib::IsVTrimAllowed(anAS, aVf, aVl)) + { + theDI << "V-trimm is possible.\n"; + } + else + { + theDI << "V-trimm is not possible.\n"; + } + + return 0; +} + void QABugs::Commands_20(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -3064,5 +3141,8 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) { theCommands.Add("OCC29807", "OCC29807 surface1 surface2 u1 v1 u2 v2", __FILE__, OCC29807, group); theCommands.Add("OCC29311", "OCC29311 shape counter nbiter: check performance of OBB calculation", __FILE__, OCC29311, group); + theCommands.Add("OCC29115c", "OCC29115c curve Uf Ul ", __FILE__, OCC29115c, group); + theCommands.Add("OCC29115s", "OCC29115s surface Uf Ul Vf Vl", __FILE__, OCC29115s, group); + return; } diff --git a/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx b/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx index d97d1f452e..9969ad5237 100644 --- a/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx @@ -521,8 +521,8 @@ Standard_Boolean ShapeAnalysis_Curve::ValidateRange (const Handle(Geom_Curve)& t } } - // 15.11.2002 PTV OCC966 - if (ShapeAnalysis_Curve::IsPeriodic(theCurve)) { + if(theCurve->IsPeriodic() && theCurve->IsClosed()) + { ElCLib::AdjustPeriodic(cf,cl,Precision::PConfusion(),First,Last); //:a7 abv 11 Feb 98: preci -> PConfusion() } else if (First < Last) { @@ -1205,39 +1205,3 @@ Standard_Boolean ShapeAnalysis_Curve::IsClosed(const Handle(Geom_Curve)& theCurv return (aClosedVal <= preci2); } -//======================================================================= -//function : IsPeriodic -//purpose : OCC996 -//======================================================================= - -Standard_Boolean ShapeAnalysis_Curve::IsPeriodic(const Handle(Geom_Curve)& theCurve) -{ - // 15.11.2002 PTV OCC966 - // remove regressions in DE tests (diva, divb, divc, toe3) in KAS:dev - // ask IsPeriodic on BasisCurve - Handle(Geom_Curve) aTmpCurve = theCurve; - while ( (aTmpCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) || - (aTmpCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) ) { - if (aTmpCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) - aTmpCurve = Handle(Geom_OffsetCurve)::DownCast(aTmpCurve)->BasisCurve(); - if (aTmpCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) - aTmpCurve = Handle(Geom_TrimmedCurve)::DownCast(aTmpCurve)->BasisCurve(); - } - return aTmpCurve->IsPeriodic(); -} - -Standard_Boolean ShapeAnalysis_Curve::IsPeriodic(const Handle(Geom2d_Curve)& theCurve) -{ - // 15.11.2002 PTV OCC966 - // remove regressions in DE tests (diva, divb, divc, toe3) in KAS:dev - // ask IsPeriodic on BasisCurve - Handle(Geom2d_Curve) aTmpCurve = theCurve; - while ( (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) || - (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) ) { - if (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) - aTmpCurve = Handle(Geom2d_OffsetCurve)::DownCast(aTmpCurve)->BasisCurve(); - if (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) - aTmpCurve = Handle(Geom2d_TrimmedCurve)::DownCast(aTmpCurve)->BasisCurve(); - } - return aTmpCurve->IsPeriodic(); -} diff --git a/src/ShapeAnalysis/ShapeAnalysis_Curve.hxx b/src/ShapeAnalysis/ShapeAnalysis_Curve.hxx index cacecdac28..c19f1e27e8 100644 --- a/src/ShapeAnalysis/ShapeAnalysis_Curve.hxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Curve.hxx @@ -131,18 +131,6 @@ public: //! If < 0 then Precision::Confusion is used. Standard_EXPORT static Standard_Boolean IsClosed (const Handle(Geom_Curve)& curve, const Standard_Real preci = -1); - //! This method was implemented as fix for changes in trimmed curve - //! behaviour. For the moment trimmed curve returns false anyway. - //! So it is necessary to adapt all Data exchange tools for this behaviour. - //! Current implementation takes into account that curve may be offset. - Standard_EXPORT static Standard_Boolean IsPeriodic (const Handle(Geom_Curve)& curve); - - //! The same as for Curve3d. - Standard_EXPORT static Standard_Boolean IsPeriodic (const Handle(Geom2d_Curve)& curve); - - - - protected: diff --git a/src/ShapeBuild/ShapeBuild_Edge.cxx b/src/ShapeBuild/ShapeBuild_Edge.cxx index c17a4e4fca..323b1cc6c6 100644 --- a/src/ShapeBuild/ShapeBuild_Edge.cxx +++ b/src/ShapeBuild/ShapeBuild_Edge.cxx @@ -143,38 +143,6 @@ static Standard_Real AdjustByPeriod(const Standard_Real Val, return ( diff >0 ? -P : P ) * (Standard_Integer)( D / P + 0.5 ); } -static Standard_Boolean IsPeriodic(const Handle(Geom_Curve)& theCurve) -{ - // 15.11.2002 PTV OCC966 - // remove regressions in DE tests (diva, divb, divc, toe3) in KAS:dev - // ask IsPeriodic on BasisCurve - Handle(Geom_Curve) aTmpCurve = theCurve; - while ( (aTmpCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) || - (aTmpCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) ) { - if (aTmpCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) - aTmpCurve = Handle(Geom_OffsetCurve)::DownCast(aTmpCurve)->BasisCurve(); - if (aTmpCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) - aTmpCurve = Handle(Geom_TrimmedCurve)::DownCast(aTmpCurve)->BasisCurve(); - } - return aTmpCurve->IsPeriodic(); -} - -Standard_Boolean IsPeriodic(const Handle(Geom2d_Curve)& theCurve) -{ - // 15.11.2002 PTV OCC966 - // remove regressions in DE tests (diva, divb, divc, toe3) in KAS:dev - // ask IsPeriodic on BasisCurve - Handle(Geom2d_Curve) aTmpCurve = theCurve; - while ( (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) || - (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) ) { - if (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) - aTmpCurve = Handle(Geom2d_OffsetCurve)::DownCast(aTmpCurve)->BasisCurve(); - if (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) - aTmpCurve = Handle(Geom2d_TrimmedCurve)::DownCast(aTmpCurve)->BasisCurve(); - } - return aTmpCurve->IsPeriodic(); -} - void ShapeBuild_Edge::CopyRanges (const TopoDS_Edge& toedge, const TopoDS_Edge& fromedge, const Standard_Real alpha, @@ -235,7 +203,7 @@ void ShapeBuild_Edge::CopyRanges (const TopoDS_Edge& toedge, if (toGC->IsKind(STANDARD_TYPE(BRep_Curve3D))) { Handle(Geom_Curve) aCrv3d = Handle(BRep_Curve3D)::DownCast(toGC)->Curve3D(); // 15.11.2002 PTV OCC966 - if ( ! aCrv3d.IsNull() && IsPeriodic(aCrv3d) ) { + if ( ! aCrv3d.IsNull() && aCrv3d->IsPeriodic() ) { aPeriod = aCrv3d->Period(); aCrvF = aCrv3d->FirstParameter(); aCrvL = aCrv3d->LastParameter(); @@ -245,7 +213,7 @@ void ShapeBuild_Edge::CopyRanges (const TopoDS_Edge& toedge, else if (toGC->IsKind(STANDARD_TYPE(BRep_CurveOnSurface))) { Handle(Geom2d_Curve) aCrv2d = Handle(BRep_CurveOnSurface)::DownCast(toGC)->PCurve(); // 15.11.2002 PTV OCC966 - if (!aCrv2d.IsNull() && IsPeriodic(aCrv2d)) { + if (!aCrv2d.IsNull() && aCrv2d->IsPeriodic()) { aPeriod = aCrv2d->Period(); aCrvF = aCrv2d->FirstParameter(); aCrvL = aCrv2d->LastParameter(); @@ -618,7 +586,7 @@ Standard_Boolean ShapeBuild_Edge::BuildCurve3d (const TopoDS_Edge& edge) const if (c3d.IsNull()) return Standard_False; // 15.11.2002 PTV OCC966 - if(!IsPeriodic(c3d)) { + if(!c3d->IsPeriodic()) { Standard_Boolean isLess = Standard_False; if(f < c3d->FirstParameter()) { isLess = Standard_True; diff --git a/src/ShapeConstruct/ShapeConstruct.cxx b/src/ShapeConstruct/ShapeConstruct.cxx index b8b6b1f6eb..feea2b79dd 100644 --- a/src/ShapeConstruct/ShapeConstruct.cxx +++ b/src/ShapeConstruct/ShapeConstruct.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -392,17 +393,18 @@ static inline HCurve GetCurveCopy(const HCurve& curve, } template -static inline void SegmentCurve (HCurve& curve, - const Standard_Real first, - const Standard_Real last) +static inline void SegmentCurve (HCurve& theCurve, + const Standard_Real theFirst, + const Standard_Real theLast) { - if(curve->FirstParameter() < first - Precision::PConfusion() || - curve->LastParameter() > last + Precision::PConfusion()) { - if(curve->IsPeriodic()) - curve->Segment(first,last); - else curve->Segment(Max(curve->FirstParameter(),first), - Min(curve->LastParameter(),last)); + Standard_Real aF = theFirst, aL = theLast; + if (!GeomLib::IsTrimAllowed(theCurve, aF, aL)) + { + aF = Max(theCurve->FirstParameter(), aF); + aL = Min(theCurve->LastParameter(), aL); } + + theCurve->Segment(aF, aL); } template diff --git a/src/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx b/src/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx index 117680e430..57ed6f6b79 100644 --- a/src/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx +++ b/src/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -537,7 +538,11 @@ Standard_Boolean ShapeConstruct_ProjectCurveOnSurface::PerformByProjLib(Handle(G return result; } - //! Fix possible period jump and handle walking period parameter. +//======================================================================= +//function : fixPeriodictyTroubles +//purpose : Fix possible period jump and handle walking period parameter. +// This function will adjust only first and last point of thePnt-array +//======================================================================= static Standard_Boolean fixPeriodictyTroubles(gp_Pnt2d *thePnt, // pointer to gp_Pnt2d[4] beginning Standard_Integer theIdx, // Index of objective coord: 1 ~ X, 2 ~ Y Standard_Real thePeriod, // Period on objective coord @@ -660,8 +665,17 @@ Standard_Boolean ShapeConstruct_ProjectCurveOnSurface::PerformByProjLib(Handle(G Standard_Integer i = 0; Standard_Real aTol2 = theTol * theTol; - Standard_Boolean isPeriodicU = mySurf->Surface()->IsUPeriodic(); - Standard_Boolean isPeriodicV = mySurf->Surface()->IsVPeriodic(); + const Handle(Geom_Surface) &aSurf = mySurf->Surface(); + + // Method IsUClosed/IsVClosed returns incorrect result + // for some kind of surfaces (e.g. Geom_OffsetSurface based on + // B-spline surface is always not U(V)-closed). Therefore, + // here we use honest computation of closure. + Standard_Boolean isUClosed = Standard_False, isVClosed = Standard_False; + GeomLib::IsClosed(aSurf, Precision::Confusion(), isUClosed, isVClosed); + + const Standard_Boolean isPeriodicU = isUClosed && aSurf->IsUPeriodic(), + isPeriodicV = isVClosed && aSurf->IsVPeriodic(); // Workaround: // Protection against bad "tolerance" shapes. @@ -759,7 +773,6 @@ Standard_Boolean ShapeConstruct_ProjectCurveOnSurface::PerformByProjLib(Handle(G return 0; gp_Vec2d aVec0 (aP2d[0], aP2d[3]); gp_Vec2d aVec = aVec0 / dPar; - Handle(Geom_Surface) aSurf = mySurf->Surface(); Standard_Boolean isNormalCheck = aSurf->IsCNu(1) && aSurf->IsCNv(1); if (isNormalCheck) { for(i = 1; i <= nb; i++) diff --git a/src/ShapeCustom/ShapeCustom_BSplineRestriction.cxx b/src/ShapeCustom/ShapeCustom_BSplineRestriction.cxx index 9a5e73bda2..394e737423 100644 --- a/src/ShapeCustom/ShapeCustom_BSplineRestriction.cxx +++ b/src/ShapeCustom/ShapeCustom_BSplineRestriction.cxx @@ -999,7 +999,7 @@ Standard_Boolean ShapeCustom_BSplineRestriction::ConvertCurve(const Handle(Geom_ Handle(Geom_Curve) aCurve1; Standard_Real pf =aCurve->FirstParameter(), pl = aCurve->LastParameter(); // 15.11.2002 PTV OCC966 - if(ShapeAnalysis_Curve::IsPeriodic(aCurve) && (First != Last)) aCurve1 = new Geom_TrimmedCurve(aCurve,First,Last); + if(aCurve->IsPeriodic() && (First != Last)) aCurve1 = new Geom_TrimmedCurve(aCurve, First, Last); else if(pf < (First - Precision::PConfusion()) || pl > (Last + Precision::PConfusion())) { Standard_Real F = Max(First,pf), @@ -1308,7 +1308,7 @@ Standard_Boolean ShapeCustom_BSplineRestriction::ConvertCurve2d(const Handle(Geo Handle(Geom2d_Curve) aCurve1; Standard_Real pf =aCurve->FirstParameter(), pl = aCurve->LastParameter(); // 15.11.2002 PTV OCC966 - if(ShapeAnalysis_Curve::IsPeriodic(aCurve) && (First != Last)) aCurve1 = new Geom2d_TrimmedCurve(aCurve,First,Last); + if(aCurve->IsPeriodic() && (First != Last)) aCurve1 = new Geom2d_TrimmedCurve(aCurve,First,Last); else if(aCurve->FirstParameter() < (First - Precision::PConfusion()) || aCurve->LastParameter() > (Last + Precision::PConfusion())) { Standard_Real F = Max(First,pf), diff --git a/src/ShapeFix/ShapeFix_Edge.cxx b/src/ShapeFix/ShapeFix_Edge.cxx index 46fbfbd943..92ecda5fc6 100644 --- a/src/ShapeFix/ShapeFix_Edge.cxx +++ b/src/ShapeFix/ShapeFix_Edge.cxx @@ -385,7 +385,7 @@ static Handle(Geom2d_Curve) TranslatePCurve (const Handle(Geom_Surface)& aSurf, oldFirst = geometric_representation_ptr->First(); oldLast = geometric_representation_ptr->Last(); // 15.11.2002 PTV OCC966 - if(ShapeAnalysis_Curve::IsPeriodic(Curve2dPtr)) { + if(Curve2dPtr->IsPeriodic()) { Handle(Geom2d_TrimmedCurve) tc = new Geom2d_TrimmedCurve(Curve2dPtr,oldFirst,oldLast); Standard_Real shift = tc->FirstParameter()-oldFirst; oldFirst += shift; diff --git a/src/ShapeFix/ShapeFix_EdgeProjAux.cxx b/src/ShapeFix/ShapeFix_EdgeProjAux.cxx index 5b2fb486fa..f1166b5aa0 100644 --- a/src/ShapeFix/ShapeFix_EdgeProjAux.cxx +++ b/src/ShapeFix/ShapeFix_EdgeProjAux.cxx @@ -441,10 +441,11 @@ void ShapeFix_EdgeProjAux::Init2d (const Standard_Real preci) } //pdn adjust parameters in periodic case - if(parU || parV) { + if ((parU && theSurface->IsUPeriodic()) || (parV && theSurface->IsVPeriodic())) + { Standard_Real uf,ul,vf,vl; theSurface->Bounds(uf,ul,vf,vl); - Standard_Real period = (parU ? ul-uf : vl-vf); + Standard_Real period = (parU ? theSurface->UPeriod() : theSurface->VPeriod()); w1+=ShapeAnalysis::AdjustToPeriod(w1,0,period); myFirstParam = w1; w2+=ShapeAnalysis::AdjustToPeriod(w2,0,period); @@ -578,7 +579,8 @@ void ShapeFix_EdgeProjAux::UpdateParam2d (const Handle(Geom2d_Curve)& theCurve2d Standard_Real preci2d = Precision::PConfusion(); //:S4136: Parametric(preci, 0.01); // 15.11.2002 PTV OCC966 - if (ShapeAnalysis_Curve::IsPeriodic(theCurve2d)) { + if(theCurve2d->IsPeriodic() && theCurve2d->IsClosed()) + { ElCLib::AdjustPeriodic(cf,cl,preci2d,myFirstParam,myLastParam); } else if (theCurve2d->IsClosed()) { diff --git a/src/ShapeFix/ShapeFix_Wire.cxx b/src/ShapeFix/ShapeFix_Wire.cxx index 4bb06b163c..fc84ef259f 100644 --- a/src/ShapeFix/ShapeFix_Wire.cxx +++ b/src/ShapeFix/ShapeFix_Wire.cxx @@ -1374,9 +1374,13 @@ Standard_Boolean ShapeFix_Wire::FixShifted() Standard_Boolean IsVCrvClosed = Standard_False; Standard_Real VRange = 1.; if (surf->Surface()->IsKind (STANDARD_TYPE(Geom_SurfaceOfRevolution))) { + //! Issue #29115. Surface of revolution is considered to be V-periodic + //! if and only if its basis curve is periodic and closed simultaneously. + //! Therefore, we need to keep this complex check for the given specific algorithm. + Handle(Geom_SurfaceOfRevolution) aSurOfRev = Handle(Geom_SurfaceOfRevolution)::DownCast(surf->Surface()); Handle(Geom_Curve) aBaseCrv = aSurOfRev->BasisCurve(); - while ( (aBaseCrv->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) || + while ((aBaseCrv->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) || (aBaseCrv->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) ) { if (aBaseCrv->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) aBaseCrv = Handle(Geom_OffsetCurve)::DownCast(aBaseCrv)->BasisCurve(); @@ -1385,7 +1389,7 @@ Standard_Boolean ShapeFix_Wire::FixShifted() } if (aBaseCrv->IsPeriodic()) { vclosed = Standard_True; - VRange = aBaseCrv->Period(); + VRange = aSurOfRev->VPeriod(); IsVCrvClosed = Standard_True; #ifdef OCCT_DEBUG cout << "Warning: ShapeFix_Wire::FixShifted set vclosed True for Surface of Revolution" << endl; diff --git a/src/ShapeFix/ShapeFix_Wire_1.cxx b/src/ShapeFix/ShapeFix_Wire_1.cxx index 5c00a23f49..2ff259773a 100644 --- a/src/ShapeFix/ShapeFix_Wire_1.cxx +++ b/src/ShapeFix/ShapeFix_Wire_1.cxx @@ -165,7 +165,7 @@ static Standard_Real AdjustOnPeriodic3d (const Handle(Geom_Curve)& c, const Standard_Real param) { // 15.11.2002 PTV OCC966 - if (ShapeAnalysis_Curve::IsPeriodic(c)) + if (c->IsPeriodic()) { Standard_Real T = c->Period(); Standard_Real shift = -IntegerPart(first/T)*T; if (first<0.) shift += T; @@ -360,7 +360,7 @@ static Standard_Real AdjustOnPeriodic3d (const Handle(Geom_Curve)& c, { OCC_CATCH_SIGNALS // 15.11.2002 PTV OCC966 - if(!ShapeAnalysis_Curve::IsPeriodic(c)) + if(!c->IsPeriodic()) tc = new Geom_TrimmedCurve(c,Max(first,c->FirstParameter()),Min(last,c->LastParameter())); else tc = new Geom_TrimmedCurve(c,first,last); bsp = GeomConvert::CurveToBSplineCurve(tc); @@ -755,7 +755,7 @@ static Standard_Real AdjustOnPeriodic2d (const Handle(Geom2d_Curve)& pc, const Standard_Real param) { // 15.11.2002 PTV OCC966 - if (ShapeAnalysis_Curve::IsPeriodic(pc)) + if (pc->IsPeriodic()) { Standard_Real T = pc->Period(); Standard_Real shift = -IntegerPart(first/T)*T; if (first<0.) shift += T; @@ -942,7 +942,7 @@ static Standard_Real AdjustOnPeriodic2d (const Handle(Geom2d_Curve)& pc, OCC_CATCH_SIGNALS Handle(Geom2d_Curve) c; // 15.11.2002 PTV OCC966 - if(!ShapeAnalysis_Curve::IsPeriodic(pc)) + if(!pc->IsPeriodic()) c = new Geom2d_TrimmedCurve(pc,Max(first,pc->FirstParameter()),Min(last,pc->LastParameter())); else c = new Geom2d_TrimmedCurve(pc,first,last); diff --git a/src/ShapeUpgrade/ShapeUpgrade_SplitCurve2d.cxx b/src/ShapeUpgrade/ShapeUpgrade_SplitCurve2d.cxx index c533c518a7..b2514b161b 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_SplitCurve2d.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_SplitCurve2d.cxx @@ -72,7 +72,7 @@ ShapeUpgrade_SplitCurve2d::ShapeUpgrade_SplitCurve2d() if(aCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) aCurve=Handle(Geom2d_TrimmedCurve)::DownCast(aCurve)->BasisCurve(); // 15.11.2002 PTV OCC966 - if(!ShapeAnalysis_Curve::IsPeriodic(C)) { + if(!C->IsPeriodic()) { Standard_Real fP = aCurve->FirstParameter(); Standard_Real lP = aCurve->LastParameter(); if(Abs(firstPar-fP) < precision) diff --git a/src/ShapeUpgrade/ShapeUpgrade_SplitCurve3d.cxx b/src/ShapeUpgrade/ShapeUpgrade_SplitCurve3d.cxx index f3cf45209f..58602dedbd 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_SplitCurve3d.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_SplitCurve3d.cxx @@ -71,7 +71,7 @@ ShapeUpgrade_SplitCurve3d::ShapeUpgrade_SplitCurve3d() if(aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) aCurve=Handle(Geom_TrimmedCurve)::DownCast(aCurve)->BasisCurve(); // 15.11.2002 PTV OCC966 - if(!ShapeAnalysis_Curve::IsPeriodic(C)) { + if(!C->IsPeriodic()) { Standard_Real fP = aCurve->FirstParameter(); Standard_Real lP = aCurve->LastParameter(); if(Abs(firstPar-fP) < precision) @@ -156,7 +156,7 @@ ShapeUpgrade_SplitCurve3d::ShapeUpgrade_SplitCurve3d() //pdn fix on BuildCurve 3d // 15.11.2002 PTV OCC966 - if(!ShapeAnalysis_Curve::IsPeriodic(myCurve)) { + if(!myCurve->IsPeriodic()) { //pdn exceptons only on non periodic curves Standard_Real precision = Precision::PConfusion(); Standard_Real firstPar = myCurve->FirstParameter(); diff --git a/src/StepToTopoDS/StepToTopoDS_GeometricTool.cxx b/src/StepToTopoDS/StepToTopoDS_GeometricTool.cxx index d764aaa26c..791c97fc53 100644 --- a/src/StepToTopoDS/StepToTopoDS_GeometricTool.cxx +++ b/src/StepToTopoDS/StepToTopoDS_GeometricTool.cxx @@ -226,11 +226,11 @@ Standard_Boolean StepToTopoDS_GeometricTool::UpdateParam3d( const Handle(Geom_Curve)& theCurve, Standard_Real& w1, Standard_Real& w2, - const Standard_Real preci) + const Standard_Real preci) { // w1 et/ou w2 peuvent etre en dehors des bornes naturelles de la courbe. // On donnera alors la valeur en bout a w1 et/ou w2 - + Standard_Real cf = theCurve->FirstParameter(); Standard_Real cl = theCurve->LastParameter(); @@ -266,9 +266,9 @@ Standard_Boolean StepToTopoDS_GeometricTool::UpdateParam3d( if (w1 < w2) return Standard_True; - if (theCurve->IsPeriodic()) + if (theCurve->IsPeriodic() && theCurve->IsClosed()) { - ElCLib::AdjustPeriodic(cf, cl, Precision::PConfusion(), w1, w2); //:a7 abv 11 Feb 98: preci -> PConfusion() + ElCLib::AdjustPeriodic(cf,cl,Precision::PConfusion(),w1,w2); //:a7 abv 11 Feb 98: preci -> PConfusion() } else if (theCurve->IsClosed()) { @@ -319,16 +319,16 @@ Standard_Boolean StepToTopoDS_GeometricTool::UpdateParam3d( // The curve is closed within the 3D tolerance else if (theCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { - Handle(Geom_BSplineCurve) aBSpline = + Handle(Geom_BSplineCurve) aBSpline = Handle(Geom_BSplineCurve)::DownCast(theCurve); if (aBSpline->StartPoint().Distance(aBSpline->EndPoint()) <= preci) { - //:S4136 <= BRepAPI::Precision()) { - // l'un des points projecte se trouve sur l'origine du parametrage - // de la courbe 3D. L algo a donne cl +- preci au lieu de cf ou vice-versa - // DANGER precision 3d applique a une espace 1d - - // w2 = cf au lieu de w2 = cl +//:S4136 <= BRepAPI::Precision()) { + // l'un des points projecte se trouve sur l'origine du parametrage + // de la courbe 3D. L algo a donne cl +- preci au lieu de cf ou vice-versa + // DANGER precision 3d applique a une espace 1d + + // w2 = cf au lieu de w2 = cl if (Abs(w2 - cf) < Precision::PConfusion()) { w2 = cl; @@ -344,11 +344,11 @@ Standard_Boolean StepToTopoDS_GeometricTool::UpdateParam3d( else { #ifdef OCCT_DEBUG - cout << "Warning : parameter range of edge crossing non periodic curve origin" << endl; + cout << "Warning : parameter range of edge crossing non periodic curve origin" << endl; #endif - Standard_Real tmp = w1; - w1 = w2; - w2 = tmp; + Standard_Real tmp = w1; + w1 = w2; + w2 = tmp; } } //abv 15.03.00 #72 bm1_pe_t4 protection of exceptions in draw @@ -357,11 +357,11 @@ Standard_Boolean StepToTopoDS_GeometricTool::UpdateParam3d( #ifdef OCCT_DEBUG cout << "Warning: parameter range is bad; curve reversed" << endl; #endif - w1 = theCurve->ReversedParameter(w1); - w2 = theCurve->ReversedParameter(w2); + w1 = theCurve->ReversedParameter ( w1 ); + w2 = theCurve->ReversedParameter ( w2 ); theCurve->Reverse(); } - //:j9 abv 11 Dec 98: PRO7747 #4875, after :j8: else +//:j9 abv 11 Dec 98: PRO7747 #4875, after :j8: else if (w1 == w2) { //gka 10.07.1998 file PRO7656 entity 33334 w1 = cf; @@ -383,8 +383,8 @@ Standard_Boolean StepToTopoDS_GeometricTool::UpdateParam3d( #ifdef OCCT_DEBUG cout << "Warning: parameter range is bad; curve reversed" << endl; #endif - w1 = theCurve->ReversedParameter(w1); - w2 = theCurve->ReversedParameter(w2); + w1 = theCurve->ReversedParameter ( w1 ); + w2 = theCurve->ReversedParameter ( w2 ); theCurve->Reverse(); } //pdn 11.01.99 #144 bm1_pe_t4 protection of exceptions in draw diff --git a/src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx b/src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx index b2b17747bc..71ec077f01 100644 --- a/src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx +++ b/src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx @@ -158,7 +158,7 @@ static void CheckPCurves (TopoDS_Wire& aWire, const TopoDS_Face& aFace, w2 = cf; } - if (w1 > w2 && mySurf->IsUPeriodic()) + if (w1 > w2 && mySurf->IsUPeriodic() && mySurf->IsUClosed()) { Standard_Real u1,u2,v1,v2; mySurf->Bounds(u1,u2,v1,v2); diff --git a/src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx b/src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx index 6ed5f5bc81..5397384a67 100644 --- a/src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx +++ b/src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx @@ -708,7 +708,7 @@ void TopOpeBRepDS_BuildTool::ComputePCurves if ( C3D->IsPeriodic() ) { // ellipse on cone : periodize parmin,parmax - Standard_Real period = C3D->LastParameter() - C3D->FirstParameter(); + Standard_Real period = C3D->Period(); Standard_Real f,l; if (Vmin.Orientation() == TopAbs_FORWARD) { f = parmin; l = parmax; } else { f = parmax; l = parmin; } @@ -998,7 +998,7 @@ void TopOpeBRepDS_BuildTool::UpdateEdge(const TopoDS_Shape& Ein, if ( Cou->IsPeriodic() ) { Standard_Real f2n = f2, l2n = l2; if ( l2n <= f2n ) { - ElCLib::AdjustPeriodic(f1,l1,Precision::PConfusion(),f2n,l2n); + ElCLib::AdjustPeriodic(f1,f1+Cou->Period(),Precision::PConfusion(),f2n,l2n); Range(Eou,f2n,l2n); } } @@ -1082,7 +1082,7 @@ void TopOpeBRepDS_BuildTool::TranslateOnPeriodic Standard_Real first = C3Df, last = C3Dl; if (C3D->IsPeriodic()) { - if ( last < first ) last += Abs(first - last); + if ( last < first ) last += C3D->Period(); } // jyl-xpu : 13-06-97 : diff --git a/src/TopOpeBRepTool/TopOpeBRepTool_CurveTool.cxx b/src/TopOpeBRepTool/TopOpeBRepTool_CurveTool.cxx index 5f76fea777..f5e37c8f92 100644 --- a/src/TopOpeBRepTool/TopOpeBRepTool_CurveTool.cxx +++ b/src/TopOpeBRepTool/TopOpeBRepTool_CurveTool.cxx @@ -198,9 +198,7 @@ static Standard_Boolean CheckPCurve // adjust domain for periodic surfaces TopLoc_Location aLoc; - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace, aLoc); - if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) - aSurf = (Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf))->BasisSurface(); + const Handle(Geom_Surface) &aSurf = BRep_Tool::Surface(aFace, aLoc); gp_Pnt2d pnt = aPC->Value((fp+lp)/2); Standard_Real u,v; diff --git a/src/TopOpeBRepTool/TopOpeBRepTool_ShapeTool.cxx b/src/TopOpeBRepTool/TopOpeBRepTool_ShapeTool.cxx index 1cb9bc25aa..745a854937 100644 --- a/src/TopOpeBRepTool/TopOpeBRepTool_ShapeTool.cxx +++ b/src/TopOpeBRepTool/TopOpeBRepTool_ShapeTool.cxx @@ -307,8 +307,8 @@ Standard_Real TopOpeBRepTool_ShapeTool::PeriodizeParameter TopLoc_Location Loc; const Handle(Geom_Surface) Surf = BRep_Tool::Surface(F,Loc); - Standard_Boolean isUperio = Surf->IsUPeriodic(); - Standard_Boolean isVperio = Surf->IsVPeriodic(); + Standard_Boolean isUperio = Surf->IsUPeriodic() && Surf->IsUClosed(); + Standard_Boolean isVperio = Surf->IsVPeriodic() && Surf->IsVClosed(); if (!isUperio && !isVperio) return periopar; Standard_Real Ufirst,Ulast,Vfirst,Vlast; diff --git a/src/math/math_NewtonMinimum.cxx b/src/math/math_NewtonMinimum.cxx index dd326dc1a9..76c2b8cd1b 100644 --- a/src/math/math_NewtonMinimum.cxx +++ b/src/math/math_NewtonMinimum.cxx @@ -165,15 +165,19 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F, Standard_Real aMult = RealLast(); for(Standard_Integer anIdx = 1; anIdx <= myLeft.Upper(); anIdx++) { + const Standard_Real anAbsStep = Abs(TheStep(anIdx)); + if (anAbsStep < gp::Resolution()) + continue; + if (suivant->Value(anIdx) < myLeft(anIdx)) { - Standard_Real aValue = Abs(precedent->Value(anIdx) - myLeft(anIdx)) / Abs(TheStep(anIdx)); + Standard_Real aValue = Abs(precedent->Value(anIdx) - myLeft(anIdx)) / anAbsStep; aMult = Min (aValue, aMult); } if (suivant->Value(anIdx) > myRight(anIdx)) { - Standard_Real aValue = Abs(precedent->Value(anIdx) - myRight(anIdx)) / Abs(TheStep(anIdx)); + Standard_Real aValue = Abs(precedent->Value(anIdx) - myRight(anIdx)) / anAbsStep; aMult = Min (aValue, aMult); } } diff --git a/tests/adaptors/begin b/tests/adaptors/begin new file mode 100644 index 0000000000..51f57acba6 --- /dev/null +++ b/tests/adaptors/begin @@ -0,0 +1,43 @@ +if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } { + pload TOPTEST + pload AISV +} +# To prevent loops limit to 10 minutes +cpulimit 60 + +if { [info exists imagedir] == 0 } { + set imagedir . +} + +if { [info exists test_image ] == 0 } { + set test_image photo +} + +proc compare {r1 r2 tol} { + if {$r1 - $r2 >= $tol} { + puts "Error : evalution" + } + if {$r2 - $r1 >= $tol} { + puts "Error : evalution" + } +} + +proc comparepnt2d {p1 p2 tol} { + upvar $p1 pp1 + upvar $p2 pp2 + coord pp1 x1 y1 + coord pp2 x2 y2 + compare [dval x1] [dval x2] $tol + compare [dval y1] [dval y2] $tol +} + +proc comparepnt3d {p1 p2 tol} { + upvar $p1 pp1 + upvar $p2 pp2 + coord pp1 x1 y1 z1 + coord pp2 x2 y2 z2 + compare [dval x1] [dval x2] $tol + compare [dval y1] [dval y2] $tol + compare [dval z1] [dval z2] $tol +} + diff --git a/tests/adaptors/end b/tests/adaptors/end new file mode 100644 index 0000000000..57901e2abe --- /dev/null +++ b/tests/adaptors/end @@ -0,0 +1,2 @@ +# to end a test script +puts "TEST COMPLETED" diff --git a/tests/adaptors/grids.list b/tests/adaptors/grids.list new file mode 100644 index 0000000000..3257f2a8a4 --- /dev/null +++ b/tests/adaptors/grids.list @@ -0,0 +1,2 @@ +001 properties +002 resolution \ No newline at end of file diff --git a/tests/adaptors/parse.rules b/tests/adaptors/parse.rules new file mode 100644 index 0000000000..2e8d896abc --- /dev/null +++ b/tests/adaptors/parse.rules @@ -0,0 +1 @@ +OK /Relative error of mass computation/ message from vprops \ No newline at end of file diff --git a/tests/adaptors/properties/A01 b/tests/adaptors/properties/A01 new file mode 100644 index 0000000000..529ad85d07 --- /dev/null +++ b/tests/adaptors/properties/A01 @@ -0,0 +1,26 @@ +circle c 0 0 20 + +set ExpPeriodic "Adaptor2d_Curve2d is periodic with period 6.2831853071795862" +set ExpClosed "Adaptor2d_Curve2d is closed" + +nulifyadaptors +makeadaptor c +set logp [adaptorproperties -isperiodic] +set logc [adaptorproperties -isclosed] +set logpc [adaptorproperties -isperiodic -isclosed] + +if { ![regexp $ExpPeriodic $logp] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logc] } { + puts "Error: the adaptor is not closed" +} + +if { ![regexp $ExpPeriodic $logpc] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logpc] } { + puts "Error: the adaptor is not closed" +} diff --git a/tests/adaptors/properties/B01 b/tests/adaptors/properties/B01 new file mode 100644 index 0000000000..4b8bb5f359 --- /dev/null +++ b/tests/adaptors/properties/B01 @@ -0,0 +1,26 @@ +bsplinecurve cc 4 3 0 5 3.1415926535897931 3 6.2831853071795862 5 0 20 100 1 -14.1421356237309 20 106.594586144012 1 -34.9044110322929 0 116.276194167748 1 -14.1421356237311 -20 106.594586144013 1 14.142135623731 -20 93.4054138559873 1 34.904411032293 0 83.7238058322526 1 14.1421356237309 20 93.4054138559873 1 0 20 100 1 + +set ExpPeriodic "Adaptor3d_Curve is not periodic" +set ExpClosed "Adaptor3d_Curve is closed" + +nulifyadaptors +makeadaptor cc +set logp [adaptorproperties -isperiodic] +set logc [adaptorproperties -isclosed] +set logpc [adaptorproperties -isperiodic -isclosed] + +if { ![regexp $ExpPeriodic $logp] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logc] } { + puts "Error: the adaptor is not closed" +} + +if { ![regexp $ExpPeriodic $logpc] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logpc] } { + puts "Error: the adaptor is not closed" +} diff --git a/tests/adaptors/properties/C01 b/tests/adaptors/properties/C01 new file mode 100644 index 0000000000..085a32f1c1 --- /dev/null +++ b/tests/adaptors/properties/C01 @@ -0,0 +1,28 @@ +sphere s 100 +convert bs s +trim bs bs 0 6 -1 1 + +set ExpPeriodic "Adaptor3d_Surface is U-periodic with U-period 6.2831853071795862\nAdaptor3d_Surface is not V-periodic" +set ExpClosed "Adaptor3d_Surface is not U-closed\nAdaptor3d_Surface is not V-closed" + +nulifyadaptors +makeadaptor bs +set logp [adaptorproperties -isperiodic] +set logc [adaptorproperties -isclosed] +set logpc [adaptorproperties -isperiodic -isclosed] + +if { ![regexp $ExpPeriodic $logp] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logc] } { + puts "Error: the adaptor is not closed" +} + +if { ![regexp $ExpPeriodic $logpc] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logpc] } { + puts "Error: the adaptor is not closed" +} diff --git a/tests/adaptors/properties/D01 b/tests/adaptors/properties/D01 new file mode 100644 index 0000000000..6c5be6c66c --- /dev/null +++ b/tests/adaptors/properties/D01 @@ -0,0 +1,29 @@ +box b 1 1 1 +explode b e + +set ExpPeriodic "Adaptor3d_Curve is not periodic" +set ExpClosed "Adaptor3d_Curve is not closed" + +nulifyadaptors +makeadaptor b_1 + +set logp [adaptorproperties -isperiodic] +set logc [adaptorproperties -isclosed] +set logpc [adaptorproperties -isperiodic -isclosed] + +if { ![regexp $ExpPeriodic $logp] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logc] } { + puts "Error: the adaptor is not closed" +} + +if { ![regexp $ExpPeriodic $logpc] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logpc] } { + puts "Error: the adaptor is not closed" +} + diff --git a/tests/adaptors/properties/E01 b/tests/adaptors/properties/E01 new file mode 100644 index 0000000000..23d8b6e7fa --- /dev/null +++ b/tests/adaptors/properties/E01 @@ -0,0 +1,28 @@ +pcylinder f 20 200 +explode f f + +set ExpPeriodic "Adaptor3d_Surface is U-periodic with U-period 6.2831853071795862\nAdaptor3d_Surface is not V-periodic" +set ExpClosed "Adaptor3d_Surface is U-closed\nAdaptor3d_Surface is not V-closed" + +nulifyadaptors +makeadaptor f_1 + +set logp [adaptorproperties -isperiodic] +set logc [adaptorproperties -isclosed] +set logpc [adaptorproperties -isperiodic -isclosed] + +if { ![regexp $ExpPeriodic $logp] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logc] } { + puts "Error: the adaptor is not closed" +} + +if { ![regexp $ExpPeriodic $logpc] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logpc] } { + puts "Error: the adaptor is not closed" +} diff --git a/tests/adaptors/properties/F01 b/tests/adaptors/properties/F01 new file mode 100644 index 0000000000..2f8a7fc5b6 --- /dev/null +++ b/tests/adaptors/properties/F01 @@ -0,0 +1,37 @@ +pcone co 0 10 10 +explode co f + +mksurface ss co_1 + +if {! [regexp "ConicalSurface" [dump ss] ] } { + puts "Error: Wrong face has been chosen" +} + +explode co_1 e +compound co_1_1 co_1 cm + +set ExpPeriodic "Adaptor2d_Curve2d is not periodic" +set ExpClosed "Adaptor2d_Curve2d is not closed" + +nulifyadaptors +makeadaptor cm + +set logp [adaptorproperties -isperiodic] +set logc [adaptorproperties -isclosed] +set logpc [adaptorproperties -isperiodic -isclosed] + +if { ![regexp $ExpPeriodic $logp] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logc] } { + puts "Error: the adaptor is not closed" +} + +if { ![regexp $ExpPeriodic $logpc] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logpc] } { + puts "Error: the adaptor is not closed" +} diff --git a/tests/adaptors/properties/F02 b/tests/adaptors/properties/F02 new file mode 100644 index 0000000000..dc776c3703 --- /dev/null +++ b/tests/adaptors/properties/F02 @@ -0,0 +1,37 @@ +pcone co 0 10 10 +explode co f + +mksurface ss co_1 + +if {! [regexp "ConicalSurface" [dump ss] ] } { + puts "Error: Wrong face has been chosen" +} + +explode co_1 e +compound co_1_2 co_1 cm + +set ExpPeriodic "Adaptor2d_Curve2d is not periodic" +set ExpClosed "Adaptor2d_Curve2d is not closed" + +nulifyadaptors +makeadaptor cm + +set logp [adaptorproperties -isperiodic] +set logc [adaptorproperties -isclosed] +set logpc [adaptorproperties -isperiodic -isclosed] + +if { ![regexp $ExpPeriodic $logp] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logc] } { + puts "Error: the adaptor is not closed" +} + +if { ![regexp $ExpPeriodic $logpc] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logpc] } { + puts "Error: the adaptor is not closed" +} diff --git a/tests/adaptors/properties/F03 b/tests/adaptors/properties/F03 new file mode 100644 index 0000000000..911c8c33b6 --- /dev/null +++ b/tests/adaptors/properties/F03 @@ -0,0 +1,39 @@ +pcone co 0 10 10 +explode co f + +mksurface ss co_1 + +if {! [regexp "ConicalSurface" [dump ss] ] } { + puts "Error: Wrong face has been chosen" +} + +explode co_1 e + +# Degenerated edge +compound co_1_3 co_1 cm + +set ExpPeriodic "Adaptor2d_Curve2d is not periodic" +set ExpClosed "Adaptor2d_Curve2d is not closed" + +nulifyadaptors +makeadaptor cm + +set logp [adaptorproperties -isperiodic] +set logc [adaptorproperties -isclosed] +set logpc [adaptorproperties -isperiodic -isclosed] + +if { ![regexp $ExpPeriodic $logp] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logc] } { + puts "Error: the adaptor is not closed" +} + +if { ![regexp $ExpPeriodic $logpc] } { + puts "Error: the adaptor is not periodic" +} + +if { ![regexp $ExpClosed $logpc] } { + puts "Error: the adaptor is not closed" +} diff --git a/tests/adaptors/resolution/A1 b/tests/adaptors/resolution/A1 new file mode 100644 index 0000000000..9daa8c0897 --- /dev/null +++ b/tests/adaptors/resolution/A1 @@ -0,0 +1,10 @@ +circle cc 0 0 0 20 + +nulifyadaptors +makeadaptor cc + +set log [adaptorproperties -resolution 1.0e-5] + +regexp {Adaptor3d_Curve::Resolution = +([-0-9.+eE]+)} ${log} full ResC + +checkreal {Circle resolution} $ResC 5.0e-007 0.0 0.1 diff --git a/tests/adaptors/resolution/A2 b/tests/adaptors/resolution/A2 new file mode 100644 index 0000000000..d1570bdd26 --- /dev/null +++ b/tests/adaptors/resolution/A2 @@ -0,0 +1,10 @@ +circle cc 0 0 15 + +nulifyadaptors +makeadaptor cc + +set log [adaptorproperties -resolution 6.5e-4] + +regexp {Adaptor2d_Curve2d::Resolution = +([-0-9.+eE]+)} ${log} full ResC + +checkreal {Circle resolution} $ResC 4.3333333336723763e-005 1.0e-6 0.0 diff --git a/tests/adaptors/resolution/A3 b/tests/adaptors/resolution/A3 new file mode 100644 index 0000000000..291d991c54 --- /dev/null +++ b/tests/adaptors/resolution/A3 @@ -0,0 +1,11 @@ +sphere ss 68 + +nulifyadaptors +makeadaptor ss + +set log [adaptorproperties -resolution 1.0e-7] + +regexp {Adaptor3d_Surface: UResolution = +([-0-9.+eE]+); VResolution = +([-0-9.+eE]+)} ${log} full URes VRes + +checkreal {Sphere U-resolution} $URes 1.4705882352941176e-009 0.0 0.1 +checkreal {Sphere V-resolution} $VRes 1.4705882352941176e-009 0.0 0.1 diff --git a/tests/bugs/modalg_7/bug29115_1 b/tests/bugs/modalg_7/bug29115_1 new file mode 100644 index 0000000000..82b20866d2 --- /dev/null +++ b/tests/bugs/modalg_7/bug29115_1 @@ -0,0 +1,44 @@ +puts "========" +puts "OCC29115" +puts "========" +puts "" +################################################# +# [Regression] GeomAdaptor mistakenly reports non-periodic curves to be periodic +################################################# + +pload QAcommands + +circle c1 0 0 0 10 +circle c2 0 0 0 10 + +if { ! [regexp "Trimm is possible" [OCC29115c c1 0 pi] ] } { + puts "Error in \"c1 0 pi\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c1 5*pi 11*pi/2] ] } { + puts "Error in \"c1 5*pi 11*pi/2\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c1 100*pi 102*pi] ] } { + puts "Error in \"c1 100*pi 102*pi\"-bounds computation " +} + +if { ! [regexp "Trimm is not possible" [OCC29115c c1 50*pi 55*pi] ] } { + puts "Error in \"c1 50*pi 55*pi\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c2 0 pi] ] } { + puts "Error in \"c2 0 pi\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c2 5*pi 11*pi/2] ] } { + puts "Error in \"c2 5*pi 11*pi/2\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c2 100*pi 102*pi] ] } { + puts "Error in \"c2 100*pi 102*pi\"-bounds computation " +} + +if { ! [regexp "Trimm is not possible" [OCC29115c c2 50*pi 55*pi] ] } { + puts "Error in \"c2 50*pi 55*pi\"-bounds computation " +} diff --git a/tests/bugs/modalg_7/bug29115_2 b/tests/bugs/modalg_7/bug29115_2 new file mode 100644 index 0000000000..deafad456e --- /dev/null +++ b/tests/bugs/modalg_7/bug29115_2 @@ -0,0 +1,44 @@ +puts "========" +puts "OCC29115" +puts "========" +puts "" +################################################# +# [Regression] GeomAdaptor mistakenly reports non-periodic curves to be periodic +################################################# + +pload QAcommands + +bsplinecurve c1 3 3 0 4 0.5 2 1 4 2 2 2 1 3 3 3 1 4 4 4 1 5 5 5 1 6 6 6 1 7 7 7 1 +2dbsplinecurve c2 3 3 0 4 0.5 2 1 4 2 2 1 3 3 1 4 4 1 5 5 1 6 6 1 7 7 1 + +if { ! [regexp "Trimm is possible" [OCC29115c c1 0 0.1] ] } { + puts "Error in \"c1 0 0.1\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c1 0.6 0.78] ] } { + puts "Error in \"c1 0.6 0.78\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c1 0.5 1] ] } { + puts "Error in \"c1 0.5 1\"-bounds computation " +} + +if { ! [regexp "Trimm is not possible" [OCC29115c c1 0.8 1.5] ] } { + puts "Error in \"c1 0.8 1.5\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c2 0 0.1] ] } { + puts "Error in \"c2 0 0.1\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c2 0.6 0.78] ] } { + puts "Error in \"c2 0.6 0.78\"-bounds computation " +} + +if { ! [regexp "Trimm is possible" [OCC29115c c2 0.5 1] ] } { + puts "Error in \"c2 0.5 1\"-bounds computation " +} + +if { ! [regexp "Trimm is not possible" [OCC29115c c2 0.8 1.5] ] } { + puts "Error in \"c2 0.8 1.5\"-bounds computation " +} diff --git a/tests/bugs/modalg_7/bug29115_3 b/tests/bugs/modalg_7/bug29115_3 new file mode 100644 index 0000000000..e9d4f7e5f7 --- /dev/null +++ b/tests/bugs/modalg_7/bug29115_3 @@ -0,0 +1,24 @@ +puts "========" +puts "OCC29115" +puts "========" +puts "" +################################################# +# [Regression] GeomAdaptor mistakenly reports non-periodic curves to be periodic +################################################# + +pload QAcommands + +sphere sp 100 +offset s1 sp 10 + +if { ! [regexp "U-trimm is possible.\nV-trimm is possible." [OCC29115s s1 0 2*pi -1 1] ] } { + puts "Error in \"s1 0 2*pi -1 1\"-bounds computation " +} + +if { ! [regexp "U-trimm is not possible.\nV-trimm is possible." [OCC29115s s1 pi 5*pi -1 1] ] } { + puts "Error in \"s1 pi 5*pi -1 1\"-bounds computation " +} + +if { ! [regexp "U-trimm is possible.\nV-trimm is not possible." [OCC29115s s1 0 2*pi 1 2] ] } { + puts "Error in \"s1 0 2*pi 1 2\"-bounds computation " +} diff --git a/tests/bugs/modalg_7/bug29115_4 b/tests/bugs/modalg_7/bug29115_4 new file mode 100644 index 0000000000..470c738dad --- /dev/null +++ b/tests/bugs/modalg_7/bug29115_4 @@ -0,0 +1,19 @@ +puts "========" +puts "OCC29115" +puts "========" +puts "" +################################################# +# [Regression] GeomAdaptor mistakenly reports non-periodic curves to be periodic +################################################# + +pload QAcommands + +cone s1 45 100 + +if { ! [regexp "U-trimm is possible.\nV-trimm is possible." [OCC29115s s1 0 2*pi 0 150] ] } { + puts "Error in \"s1 0 2*pi -1 1\"-bounds computation " +} + +if { ! [regexp "U-trimm is possible.\nV-trimm is not possible." [OCC29115s s1 0 2*pi -150 0] ] } { + puts "Error in \"s1 0 2*pi 1 2\"-bounds computation " +} diff --git a/tests/bugs/modalg_7/bug29115_5 b/tests/bugs/modalg_7/bug29115_5 new file mode 100644 index 0000000000..d369d530c1 --- /dev/null +++ b/tests/bugs/modalg_7/bug29115_5 @@ -0,0 +1,47 @@ +puts "========" +puts "OCC29115" +puts "========" +puts "" +################################################# +# [Regression] GeomAdaptor mistakenly reports non-periodic curves to be periodic +################################################# + +pload QAcommands + +bsplinecurve c1 4 3 0 5 3.1415926535897931 3 6.2831853071795862 5 0 20 100 1 -14.1421356237309 20 106.594586144012 1 -34.9044110322929 0 116.276194167748 1 -14.1421356237311 -20 106.594586144013 1 14.142135623731 -20 93.4054138559873 1 34.904411032293 0 83.7238058322526 1 14.1421356237309 20 93.4054138559873 1 0 20 100 1 + +revsurf s1 c1 -0.654999286110387, 8.14738225247612, 100.305431183199 0.906307787036651, -3.94430452610506e-031, -0.422618261740697 + +setperiodic c1 + +revsurf s2 c1 -0.654999286110387, 8.14738225247612, 100.305431183199 0.906307787036651, -3.94430452610506e-031, -0.422618261740697 + +## +if { ! [regexp "U-trimm is possible.\nV-trimm is possible." [OCC29115s s1 0 2*pi 0 1] ] } { + puts "Error in \"s1 0 2*pi 0 1\"-bounds computation " +} + +if { ! [regexp "U-trimm is possible.\nV-trimm is possible." [OCC29115s s2 0 2*pi 0 1] ] } { + puts "Error in \"s2 0 2*pi 0 1\"-bounds computation " +} + +## + +if { ! [regexp "U-trimm is possible.\nV-trimm is not possible." [OCC29115s s1 10*pi 12*pi -0.2 1] ] } { + puts "Error in \"s1 10*pi 12*pi -0.2 1\"-bounds computation " +} + +if { ! [regexp "U-trimm is possible.\nV-trimm is possible." [OCC29115s s2 10*pi 12*pi -0.2 1] ] } { + puts "Error in \"s2 10*pi 12*pi -0.2 1\"-bounds computation " +} + +## + +if { ! [regexp "U-trimm is not possible.\nV-trimm is not possible." [OCC29115s s1 -pi 2*pi 0.5 1.5] ] } { + puts "Error in \"s1 -pi 2*pi 0.5 1.5\"-bounds computation " +} + +if { ! [regexp "U-trimm is not possible.\nV-trimm is not possible." [OCC29115s s2 -pi 2*pi 0.5 1.5] ] } { + puts "Error in \"s2 -pi 2*pi 0.5 1.5\"-bounds computation " +} + diff --git a/tests/geometry/geomperiodic/A1 b/tests/geometry/geomperiodic/A1 new file mode 100644 index 0000000000..2585631cfd --- /dev/null +++ b/tests/geometry/geomperiodic/A1 @@ -0,0 +1,17 @@ +ellipse c1 0 0 0 0 1 1 100 40 + +if { ![regexp {is periodic} [curveperiod c1] ] } { + puts "Error: the periodic curve is detected to be not periodic" +} else { + puts "OK. The curve is true periodic" +} + +trim c2 c1 0 2 + +dump c2 + +if { ![regexp {is periodic} [curveperiod c2] ] } { + puts "Error: the trimmed curve must be periodic" +} else { + puts "OK. The trimmed curve is true periodic" +} diff --git a/tests/geometry/geomperiodic/A2 b/tests/geometry/geomperiodic/A2 new file mode 100644 index 0000000000..52e85ce9e8 --- /dev/null +++ b/tests/geometry/geomperiodic/A2 @@ -0,0 +1,41 @@ +2dbsplinecurve c1 2 6 -2.0943951023932 1 0 2 2.0943951023932 2 4.18879020478639 2 6.28318530717959 2 8.37758040957278 1 100 0 1 100 173 0.5 -50 87 1 -200 0 0.5 -50 -87 1 100 -173 0.5 100 0 1 + +dump c1 + +if { [regexp {is not periodic} [curveperiod c1] ] } { + puts "OK. The curve is not periodic" +} else { + puts "Error: the not periodic curve is detected to be periodic" +} + +setperiodic c1 +dump c1 + +if { ![regexp {is periodic} [curveperiod c1] ] } { + puts "Error: the periodic curve is detected to be not periodic" +} else { + puts "OK. The curve is true periodic" +} + +trim c2 c1 0 6 + +# Trim operation does not affect the periodicity +if { ![regexp {is periodic} [curveperiod c2] ] } { + puts "Error: the periodic curve is detected to be not periodic" +} else { + puts "OK. The curve is true periodic" +} + +setnotperiodic c1 +if { [regexp {is not periodic} [curveperiod c1] ] } { + puts "OK. The curve is not periodic" +} else { + puts "Error: the not periodic curve is detected to be periodic" +} + +# setnotperiodic command works with B-spline curve only. +# As result, trimmed curves (even based on B-splines) +# sent as arguments result in TCL-exceptions + +#setnotperiodic c2 -- INCORRECT OPERATION + diff --git a/tests/geometry/geomperiodic/B1 b/tests/geometry/geomperiodic/B1 new file mode 100644 index 0000000000..5af5096c24 --- /dev/null +++ b/tests/geometry/geomperiodic/B1 @@ -0,0 +1,80 @@ +pcylinder cy 100 200 +nurbsconvert bc cy + +explode bc f + +mksurface s1 bc_1 +mksurface s2 bc_2 +mksurface s3 bc_3 + +set log1 [surfaceperiod s1] +set log2 [surfaceperiod s2] +set log3 [surfaceperiod s3] + +if { ![regexp {is U-periodic} $log1 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true periodic" +} + +if { [regexp {is not V-periodic} $log1 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} + +if { [regexp {is not U-periodic} $log2 ] } { + puts "OK. The surface is not U-periodic" +} else { + puts "Error: the not U-periodic surface is detected to be U-periodic" +} + +if { [regexp {is not V-periodic} $log2 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} + +if { [regexp {is not U-periodic} $log3 ] } { + puts "OK. The surface is not U-periodic" +} else { + puts "Error: the not U-periodic surface is detected to be U-periodic" +} + +if { [regexp {is not V-periodic} $log3 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} + +# Trim operation does not affect the periodicity + +trimu st1 s1 3 5 +if { ![regexp {is U-periodic} [surfaceperiod st1] ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true periodic" +} + +setunotperiodic s1 +if { [regexp {is not U-periodic} [surfaceperiod s1] ] } { + puts "OK. The surface is not U-periodic" +} else { + puts "Error: the not U-periodic surface is detected to be U-periodic" +} + +# Not closed surface is not converted. It has to stay periodic +setunotperiodic st1 +if { ![regexp {is U-periodic} [surfaceperiod st1] ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true periodic" +} + +viso c1 st1 50 + +if { ![regexp {is periodic} [curveperiod c1] ] } { + puts "Error: the periodic curve is detected to be not periodic" +} else { + puts "OK. The curve is true periodic" +} diff --git a/tests/geometry/geomperiodic/B2 b/tests/geometry/geomperiodic/B2 new file mode 100644 index 0000000000..b7c6830686 --- /dev/null +++ b/tests/geometry/geomperiodic/B2 @@ -0,0 +1,32 @@ +ellipse c1 0 0 0 0 0 1 1 0 0 100 30 +trim c2 c1 1.5 4.5 +extsurf s1 c2 0 0 1 +trim s2 s1 2 3 -100 100 + +set log1 [surfaceperiod s1] +set log2 [surfaceperiod s2] + +if { ![regexp {is U-periodic} $log1 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true periodic" +} + +if { [regexp {is not V-periodic} $log1 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} + +if { ![regexp {is U-periodic} $log2 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true periodic" +} + +if { [regexp {is not V-periodic} $log2 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} + diff --git a/tests/geometry/geomperiodic/B3 b/tests/geometry/geomperiodic/B3 new file mode 100644 index 0000000000..d73d43a094 --- /dev/null +++ b/tests/geometry/geomperiodic/B3 @@ -0,0 +1,91 @@ +bsplinecurve c1 4 3 0 5 3.1415926535897931 3 6.2831853071795862 5 0 20 100 1 -14.1421356237309 20 106.594586144012 1 -34.9044110322929 0 116.276194167748 1 -14.1421356237311 -20 106.594586144013 1 14.142135623731 -20 93.4054138559873 1 34.904411032293 0 83.7238058322526 1 14.1421356237309 20 93.4054138559873 1 0 20 100 1 + +if { [regexp {is not periodic} [curveperiod c1] ] } { + puts "OK. The curve is not periodic" +} else { + puts "Error: the not periodic curve is detected to be periodic" +} + +setperiodic c1 + +if { ![regexp {is periodic} [curveperiod c1] ] } { + puts "Error: the periodic curve is detected to be not periodic" +} else { + puts "OK. The curve is true periodic" +} + +trim c2 c1 2 5 + +if { ![regexp {is periodic} [curveperiod c2] ] } { + puts "Error: the periodic curve is detected to be not periodic" +} else { + puts "OK. The curve is true periodic" +} + +revsurf s1 c1 -0.654999286110526 48.1473822524761 100.305431183199 0.906307787036651 0 -0.422618261740697 +revsurf s2 c2 -0.654999286110526 48.1473822524761 100.305431183199 0.906307787036651 0 -0.422618261740697 + +trim st1 s1 pi 2*pi 3 4 +trim st2 s2 pi 2*pi 3 4 + +# The surfaces st1 and st2 take the same locus. + +set logS1 [surfaceperiod s1] +set logS2 [surfaceperiod s2] +set logST1 [surfaceperiod st1] +set logST2 [surfaceperiod st2] + +# s1 is a surface of revolution based on closed curve. +# Therefore, it is U- and V-periodic. + +if { ![regexp {is U-periodic} $logS1 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { ![regexp {is V-periodic} $logS1 ] } { + puts "Error: the V-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true V-periodic" +} + +# s2 is a surface of revolution based on not closed curve. +# Therefore, it is U-periodic and is not V-periodic. +if { ![regexp {is U-periodic} $logS2 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { [regexp {is not V-periodic} $logS2 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} + +# Trim operation does not affect the periodicity + +if { ![regexp {is U-periodic} $logST1 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { ![regexp {is V-periodic} $logST1 ] } { + puts "Error: the V-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true V-periodic" +} + +if { ![regexp {is U-periodic} $logST2 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { [regexp {is not V-periodic} $logST2 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} diff --git a/tests/geometry/geomperiodic/B4 b/tests/geometry/geomperiodic/B4 new file mode 100644 index 0000000000..6a8aa932a7 --- /dev/null +++ b/tests/geometry/geomperiodic/B4 @@ -0,0 +1,94 @@ +bsplinecurve c1 4 3 0 5 3.1415926535897931 3 6.2831853071795862 5 0 20 100 1 -14.1421356237309 20 106.594586144012 1 -34.9044110322929 0 116.276194167748 1 -14.1421356237311 -20 106.594586144013 1 14.142135623731 -20 93.4054138559873 1 34.904411032293 0 83.7238058322526 1 14.1421356237309 20 93.4054138559873 1 0 20 100 1 + +if { [regexp {is not periodic} [curveperiod c1] ] } { + puts "OK. The curve is not periodic" +} else { + puts "Error: the not periodic curve is detected to be periodic" +} + +setperiodic c1 +point pp 1 1 1 +offsetcurve co c1 -1 pp + +if { ![regexp {is periodic} [curveperiod co] ] } { + puts "Error: the periodic curve is detected to be not periodic" +} else { + puts "OK. The curve is true periodic" +} + +trim c2 co 2 5 + +if { ![regexp {is periodic} [curveperiod c2] ] } { + puts "Error: the periodic curve is detected to be not periodic" +} else { + puts "OK. The curve is true periodic" +} + +revsurf s1 co -0.654999286110526 48.1473822524761 100.305431183199 0.906307787036651 0 -0.422618261740697 +revsurf s2 c2 -0.654999286110526 48.1473822524761 100.305431183199 0.906307787036651 0 -0.422618261740697 + +trim st1 s1 pi 2*pi 3 4 +trim st2 s2 pi 2*pi 3 4 + +# The surfaces st1 and st2 take the same locus. + +set logS1 [surfaceperiod s1] +set logS2 [surfaceperiod s2] +set logST1 [surfaceperiod st1] +set logST2 [surfaceperiod st2] + +# s1 is a surface of revolution based on the offset curve. +# Currently, offset from B-spline curve is always detected as not-closed. +# Therefore, s1 is U-periodic and is not V-periodic. + +if { ![regexp {is U-periodic} $logS1 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { ![regexp {is not V-periodic} $logS1 ] } { + puts "Error: the V-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true V-periodic" +} + +# s2 is a surface of revolution based on not closed curve. +# Therefore, it is U-periodic and is not V-periodic. +if { ![regexp {is U-periodic} $logS2 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { [regexp {is not V-periodic} $logS2 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} + +# Trim operation does not affect the periodicity + +if { ![regexp {is U-periodic} $logST1 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { ![regexp {is not V-periodic} $logST1 ] } { + puts "Error: the V-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true V-periodic" +} + +if { ![regexp {is U-periodic} $logST2 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { [regexp {is not V-periodic} $logST2 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} diff --git a/tests/geometry/geomperiodic/B5 b/tests/geometry/geomperiodic/B5 new file mode 100644 index 0000000000..290445ec5e --- /dev/null +++ b/tests/geometry/geomperiodic/B5 @@ -0,0 +1,29 @@ +sphere ss 100 +trim st ss 0 pi -1 1 + +set log1 [surfaceperiod ss] +set log2 [surfaceperiod st] + +if { ![regexp {is U-periodic} $log1 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { [regexp {is not V-periodic} $log1 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} + +if { ![regexp {is U-periodic} $log2 ] } { + puts "Error: the U-periodic surface is detected to be not periodic" +} else { + puts "OK. The surface is true U-periodic" +} + +if { [regexp {is not V-periodic} $log2 ] } { + puts "OK. The surface is not V-periodic" +} else { + puts "Error: the not V-periodic surface is detected to be V-periodic" +} diff --git a/tests/geometry/grids.list b/tests/geometry/grids.list index b91d9cc11b..e5dd725534 100644 --- a/tests/geometry/grids.list +++ b/tests/geometry/grids.list @@ -12,4 +12,5 @@ 012 parabola 013 project 014 revsurf -015 2dpolygon \ No newline at end of file +015 2dpolygon +016 geomperiodic \ No newline at end of file -- 2.39.5