From 7a1e372e5efe0a4a9d0284aef129775fc8a8255e 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. Section "Periodicity concept" has been added in Doxigen-documentation 2. Method IsPeriodic() of classes Geom(2d)_TrimmedCurve has changed its behavior. Please see the documentation about correspond methods. 3. Methods IsUPeriodic() and IsVPeriodic() has changed their behavior. 4. Methods Geom_SurfaceOfLinearExtrusion::UPeriod() and Geom_SurfaceOfRevolution::VPeriod() has changed their behavior. 5. Method GeomLib::IsClosed(...) has been added in order to check closure of 3D/2D curve with some tolerance. 6. Methods ShapeAnalysis_Curve::IsPeriodic(...), BRepBlend_HCurve2dTool::IsPeriodic(...), Contap_HCurve2dTool::IsPeriodic(...), IntPatch_HCurve2dTool::IsPeriodic(...), BRepBlend_HCurveTool::IsPeriodic(...) have been removed. 7. 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. 8. Methods GeomLib::AllowExtend(...), GeomLib::AllowExtendUParameter(...) and GeomLib::AllowExtendVParameter(...) have been created. 9. Interface of Geom_ConicalSurface::Apex(...) method has been corrected insignificantly. 10. Method IntTools_Tools::IsClosed(...) has been removed. 11. The DRAW-commands "curveperiod" and "surfaceperiod" have been created. Please see help-system to obtain the information these commands. 12. 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. 13. New test cases have been created. --- .../modeling_data/modeling_data.md | 139 ++++++ src/Adaptor2d/Adaptor2d_Curve2d.hxx | 6 + src/Adaptor2d/Adaptor2d_HCurve2d.hxx | 12 +- src/Adaptor2d/Adaptor2d_Line2d.hxx | 2 + src/Adaptor2d/Adaptor2d_OffsetCurve.hxx | 2 + src/Adaptor3d/Adaptor3d_Curve.hxx | 4 + src/Adaptor3d/Adaptor3d_CurveOnSurface.hxx | 2 + src/Adaptor3d/Adaptor3d_HCurve.hxx | 6 + src/Adaptor3d/Adaptor3d_HSurface.hxx | 8 + src/Adaptor3d/Adaptor3d_HSurfaceTool.hxx | 14 +- src/Adaptor3d/Adaptor3d_IsoCurve.hxx | 2 + src/Adaptor3d/Adaptor3d_Surface.hxx | 12 +- src/BOPTools/BOPTools_AlgoTools.cxx | 16 +- src/BOPTools/BOPTools_AlgoTools2D.cxx | 16 - src/BOPTools/BOPTools_AlgoTools2D.hxx | 9 - src/BOPTools/BOPTools_AlgoTools3D.cxx | 67 +-- src/BRepAdaptor/BRepAdaptor_CompCurve.hxx | 2 + 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 | 27 +- 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_EdgeTessellator.cxx | 3 + src/BRepMesh/BRepMesh_FastDiscret.cxx | 4 +- src/BRepOffset/BRepOffset_Inter2d.cxx | 3 + src/BRepOffset/BRepOffset_Tool.cxx | 25 +- 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.hxx | 4 +- src/BiTgte/BiTgte_CurveOnVertex.hxx | 2 + src/BinTools/BinTools_Curve2dSet.cxx | 4 +- src/BinTools/BinTools_CurveSet.cxx | 4 +- src/BinTools/BinTools_SurfaceSet.cxx | 8 +- src/Bisector/Bisector_BisecAna.cxx | 2 +- src/Bisector/Bisector_BisecAna.hxx | 1 + 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.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_BezierCurve.hxx | 3 +- src/Geom/Geom_ConicalSurface.cxx | 6 +- src/Geom/Geom_ConicalSurface.hxx | 4 +- src/Geom/Geom_Curve.hxx | 23 +- src/Geom/Geom_OffsetCurve.cxx | 3 + src/Geom/Geom_OffsetCurve.hxx | 6 +- src/Geom/Geom_OffsetSurface.cxx | 8 + src/Geom/Geom_OffsetSurface.hxx | 6 +- src/Geom/Geom_RectangularTrimmedSurface.cxx | 44 +- src/Geom/Geom_RectangularTrimmedSurface.hxx | 13 +- src/Geom/Geom_Surface.hxx | 28 +- src/Geom/Geom_SurfaceOfLinearExtrusion.cxx | 9 + src/Geom/Geom_SurfaceOfLinearExtrusion.hxx | 3 + src/Geom/Geom_SurfaceOfRevolution.cxx | 18 +- src/Geom/Geom_SurfaceOfRevolution.hxx | 5 +- src/Geom/Geom_TrimmedCurve.cxx | 7 +- src/Geom/Geom_TrimmedCurve.hxx | 4 +- src/Geom2d/Geom2d_Curve.hxx | 23 +- src/Geom2d/Geom2d_OffsetCurve.cxx | 3 + src/Geom2d/Geom2d_OffsetCurve.hxx | 8 +- src/Geom2d/Geom2d_TrimmedCurve.cxx | 15 +- src/Geom2d/Geom2d_TrimmedCurve.hxx | 4 +- src/Geom2dAdaptor/Geom2dAdaptor_Curve.hxx | 2 + src/Geom2dConvert/Geom2dConvert.cxx | 4 +- src/GeomAdaptor/GeomAdaptor_Curve.hxx | 2 + src/GeomAdaptor/GeomAdaptor_Surface.hxx | 4 + .../GeomAdaptor_SurfaceOfLinearExtrusion.hxx | 4 + .../GeomAdaptor_SurfaceOfRevolution.hxx | 4 + 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.hxx | 2 + src/GeomLib/GeomLib.cxx | 129 ++++- src/GeomLib/GeomLib.hxx | 67 +++ src/GeomPlate/GeomPlate_Surface.hxx | 21 +- 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 | 9 +- src/IntPatch/IntPatch_PrmPrmIntersection.cxx | 38 +- src/IntPatch/IntPatch_RstInt.cxx | 87 +--- src/IntPatch/IntPatch_SpecialPoints.cxx | 43 +- src/IntPatch/IntPatch_WLineTool.cxx | 7 +- src/IntTools/IntTools_FaceFace.cxx | 9 +- 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 | 5 +- src/ShapeFix/ShapeFix_Wire.cxx | 8 +- src/ShapeFix/ShapeFix_Wire_1.cxx | 8 +- .../ShapeUpgrade_SplitCurve2d.cxx | 2 +- .../ShapeUpgrade_SplitCurve3d.cxx | 4 +- .../StepToTopoDS_GeometricTool.cxx | 2 +- .../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 | 1 + 176 files changed, 2635 insertions(+), 951 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/modeling_data/modeling_data.md b/dox/user_guides/modeling_data/modeling_data.md index 914260fc25..7c7fa5d933 100644 --- a/dox/user_guides/modeling_data/modeling_data.md +++ b/dox/user_guides/modeling_data/modeling_data.md @@ -723,6 +723,145 @@ 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 (detailed information can be found in Wikipedia or on the site of WolframMathWorld): + +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 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::AllowExtend(...)** 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 bi-periodic 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 have 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::AllowExtend(...)** that can be applied to a surface are called **GeomLib::AllowExtendUParameter(...)** and **GeomLib::AllowExtendVParameter(...)**. + +@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. 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::AllowExtendVParameter(...)** method). We offer 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::AllowExtendVParameter(...)** method with existing surface of revolution and the new range. If the new range is valid the method will return TRUE.
+ +The method **GeomLib::AllowExtendVParameter(...)** 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. However, for not-periodic elements, the behavior of these methods depends on the specific object (sometimes exception can be thrown, sometimes 0 will be returned, sometimes these methods will return some positive value). In general, such behavior is described in the documentation to the classes. + +Nevertheless, calling of methods Period(), UPeriod() and VPeriod() for not-periodic elements is not recommended and the behavior of these methods (for not-periodic elements) can be changed in future OCCT-versions. @section occt_modat_5 Topology diff --git a/src/Adaptor2d/Adaptor2d_Curve2d.hxx b/src/Adaptor2d/Adaptor2d_Curve2d.hxx index c845bcef7a..00d030d4f5 100644 --- a/src/Adaptor2d/Adaptor2d_Curve2d.hxx +++ b/src/Adaptor2d/Adaptor2d_Curve2d.hxx @@ -86,8 +86,14 @@ public: Standard_EXPORT virtual Standard_Boolean IsClosed() const; + //! //! Returns true if the curve in this adaptor is periodic + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). Standard_EXPORT virtual Standard_Boolean IsPeriodic() const; + //! Returns the period of 2D-adaptor's curve + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). 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..9f300c22bb 100644 --- a/src/Adaptor2d/Adaptor2d_HCurve2d.hxx +++ b/src/Adaptor2d/Adaptor2d_HCurve2d.hxx @@ -76,9 +76,15 @@ public: Standard_Boolean IsClosed() const; - Standard_Boolean IsPeriodic() const; - - Standard_Real Period() const; + //! Returns true if the curve in this adaptor is periodic + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). + Standard_Boolean IsPeriodic() const; + + //! Returns the period of 2D-adaptor's curve + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). + Standard_Real Period() const; gp_Pnt2d Value (const Standard_Real U) const; diff --git a/src/Adaptor2d/Adaptor2d_Line2d.hxx b/src/Adaptor2d/Adaptor2d_Line2d.hxx index f365e50804..6361517e5c 100644 --- a/src/Adaptor2d/Adaptor2d_Line2d.hxx +++ b/src/Adaptor2d/Adaptor2d_Line2d.hxx @@ -87,8 +87,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Always returns FALSE Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Raises exception Standard_NoSuchObject Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; Standard_EXPORT gp_Pnt2d Value (const Standard_Real X) const Standard_OVERRIDE; diff --git a/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx b/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx index b1b1c356f3..13e9132c59 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; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve. diff --git a/src/Adaptor3d/Adaptor3d_Curve.hxx b/src/Adaptor3d/Adaptor3d_Curve.hxx index de882dc430..276a82fec4 100644 --- a/src/Adaptor3d/Adaptor3d_Curve.hxx +++ b/src/Adaptor3d/Adaptor3d_Curve.hxx @@ -88,8 +88,12 @@ public: Standard_EXPORT virtual Standard_Boolean IsClosed() const; + //! Returns true if the curve in this adaptor is periodic + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). Standard_EXPORT virtual Standard_Boolean IsPeriodic() const; + //! Returns the period of the periodic adaptor's 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..16d05dc7c9 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; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class 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..9a73f14972 100644 --- a/src/Adaptor3d/Adaptor3d_HCurve.hxx +++ b/src/Adaptor3d/Adaptor3d_HCurve.hxx @@ -93,8 +93,14 @@ public: Standard_Boolean IsClosed() const; + //! Returns true if the curve in this adaptor is periodic + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). Standard_Boolean IsPeriodic() const; + //! Returns the period of the periodic adaptor's curve + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). 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..9686a13696 100644 --- a/src/Adaptor3d/Adaptor3d_HSurface.hxx +++ b/src/Adaptor3d/Adaptor3d_HSurface.hxx @@ -95,12 +95,20 @@ public: Standard_Boolean IsVClosed() const; + //! Returns true if the surface in this adaptor is periodic in U-direction + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). Standard_Boolean IsUPeriodic() const; + //! Returns U-period of U-periodic surface Standard_Real UPeriod() const; + //! Returns true if the surface in this adaptor is periodic in V-direction + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). 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..104ab5aeea 100644 --- a/src/Adaptor3d/Adaptor3d_IsoCurve.hxx +++ b/src/Adaptor3d/Adaptor3d_IsoCurve.hxx @@ -114,6 +114,8 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Returns TRUE if the surface (returned by Surface() method) is periodic + //! along the chosen direction. Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; diff --git a/src/Adaptor3d/Adaptor3d_Surface.hxx b/src/Adaptor3d/Adaptor3d_Surface.hxx index 1f5c3061ee..d605ce455d 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,20 @@ public: Standard_EXPORT virtual Standard_Boolean IsVClosed() const; + //! Returns true if the surface in this adaptor is periodic in U-direction + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept ") Standard_EXPORT virtual Standard_Boolean IsUPeriodic() const; + //! Returns U-period of U-periodic surface Standard_EXPORT virtual Standard_Real UPeriod() const; + //! Returns true if the surface in this adaptor is periodic in V-direction + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). Standard_EXPORT virtual Standard_Boolean IsVPeriodic() const; + //! Returns V-period of V-periodic 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 b4f474ba38..3b3eaad27f 100644 --- a/src/BOPTools/BOPTools_AlgoTools.cxx +++ b/src/BOPTools/BOPTools_AlgoTools.cxx @@ -1544,9 +1544,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; @@ -1566,21 +1564,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 a867d0d9aa..57bc954958 100644 --- a/src/BOPTools/BOPTools_AlgoTools2D.hxx +++ b/src/BOPTools/BOPTools_AlgoTools2D.hxx @@ -110,15 +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 d45c8a139f..80cf4e6ccb 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,58 +97,19 @@ void BOPTools_AlgoTools3D::DoSplitSEAMOnFace (const TopoDS_Edge& aSplit, // aS->Bounds(aUmin, aUmax, aVmin, aVmax); // - bIsUPeriodic=aS->IsUPeriodic(); - bIsVPeriodic=aS->IsVPeriodic(); - // - anUPeriod = bIsUPeriodic ? aS->UPeriod() : 0.; - anVPeriod = bIsVPeriodic ? aS->VPeriod() : 0.; + const Standard_Boolean bIsUPeriodic = aS->IsUPeriodic(), + bIsVPeriodic = aS->IsVPeriodic(); + + const Standard_Real anUPeriod = bIsUPeriodic ? aS->UPeriod() : 0., + anVPeriod = bIsVPeriodic ? aS->VPeriod() : 0.; + + const Standard_Boolean bIsUClosed = aS->IsUClosed(), + bIsVClosed = aS->IsVClosed(); // - 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 || !bIsUClosed) && + (!bIsVPeriodic || !bIsVClosed)) + { + return; } // //--------------------------------------------------- diff --git a/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx b/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx index ca46e6e36b..b0dc8eb25f 100644 --- a/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx +++ b/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx @@ -110,8 +110,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! Always returns FALSE Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! Returns delta between last and first parameters Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve diff --git a/src/BRepAdaptor/BRepAdaptor_Curve.hxx b/src/BRepAdaptor/BRepAdaptor_Curve.hxx index 96a87a73a6..b5ff8fa62b 100644 --- a/src/BRepAdaptor/BRepAdaptor_Curve.hxx +++ b/src/BRepAdaptor/BRepAdaptor_Curve.hxx @@ -146,8 +146,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class 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..c2397e125f 100644 --- a/src/BRepAdaptor/BRepAdaptor_Surface.hxx +++ b/src/BRepAdaptor/BRepAdaptor_Surface.hxx @@ -145,12 +145,16 @@ public: Standard_Boolean IsVClosed() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_Real UPeriod() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class 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 a6bdf8a1d2..edf0150fc9 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 b7396836b2..2e717e8b48 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); // @@ -463,7 +466,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()); @@ -495,13 +497,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) @@ -581,33 +583,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::AllowExtendUParameter(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::AllowExtendVParameter(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 b65d247453..4ccb2e6e06 100644 --- a/src/BRepCheck/BRepCheck_Edge.cxx +++ b/src/BRepCheck/BRepCheck_Edge.cxx @@ -197,6 +197,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(); @@ -237,6 +239,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(); @@ -373,6 +377,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 4cdebf6b10..cadc68599e 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 b51f7fe7f0..9ddfc79d71 100644 --- a/src/BRepFill/BRepFill_MultiLine.cxx +++ b/src/BRepFill/BRepFill_MultiLine.cxx @@ -213,21 +213,27 @@ 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(), Vmin, Vmax); } if (GAS1.GetType() == GeomAbs_Sphere) { + //Is it really correct? if (myIsoU1) ElCLib::AdjustPeriodic(-M_PI/2.,M_PI/2., Precision::PConfusion(), @@ -329,21 +335,27 @@ 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(), Vmin, Vmax); } if (GAS2.GetType() == GeomAbs_Sphere) { + //Is it really correct? if (myIsoU2) ElCLib::AdjustPeriodic(-M_PI/2.,M_PI/2., Precision::PConfusion(), @@ -388,7 +400,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 60d0bbc928..a096611af8 100644 --- a/src/BRepLib/BRepLib.cxx +++ b/src/BRepLib/BRepLib.cxx @@ -1282,30 +1282,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::AllowExtend(*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_EdgeTessellator.cxx b/src/BRepMesh/BRepMesh_EdgeTessellator.cxx index 0daa3509d3..85dc650927 100644 --- a/src/BRepMesh/BRepMesh_EdgeTessellator.cxx +++ b/src/BRepMesh/BRepMesh_EdgeTessellator.cxx @@ -187,6 +187,9 @@ Standard_Boolean BRepMesh_EdgeTessellator::Value( mySurface->GetType() != GeomAbs_BezierSurface && mySurface->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_FastDiscret.cxx b/src/BRepMesh/BRepMesh_FastDiscret.cxx index 1d453897ff..1b77c5d601 100644 --- a/src/BRepMesh/BRepMesh_FastDiscret.cxx +++ b/src/BRepMesh/BRepMesh_FastDiscret.cxx @@ -333,7 +333,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace) if (myumin < umin || myumax > umax) { - if (gFace->IsUPeriodic()) + if (gFace->IsUPeriodic() && gFace->IsUClosed()) { if ((myumax - myumin) > (umax - umin)) myumax = myumin + (umax - umin); @@ -350,7 +350,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace) if (myvmin < vmin || myvmax > vmax) { - if (gFace->IsVPeriodic()) + if (gFace->IsVPeriodic() && gFace->IsVClosed()) { if ((myvmax - myvmin) > (vmax - vmin)) myvmax = myvmin + (vmax - vmin); diff --git a/src/BRepOffset/BRepOffset_Inter2d.cxx b/src/BRepOffset/BRepOffset_Inter2d.cxx index e12dd8233e..9081c84192 100644 --- a/src/BRepOffset/BRepOffset_Inter2d.cxx +++ b/src/BRepOffset/BRepOffset_Inter2d.cxx @@ -929,6 +929,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 0dcbcf3ac8..d909d69d5c 100644 --- a/src/BRepOffset/BRepOffset_Tool.cxx +++ b/src/BRepOffset/BRepOffset_Tool.cxx @@ -251,11 +251,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. //--------------- @@ -1676,25 +1673,15 @@ 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); - BRep_Builder aBB; Standard_Real aTolEdge = BRep_Tool::Tolerance(anEdge); if (!BOPTools_AlgoTools2D::HasCurveOnSurface(anEdge, cpF1)) { Handle(Geom2d_Curve) aC2d = aBC.Curve().FirstCurve2d(); - if(!aC3DETrim.IsNull()) { + if (!aC3DE.IsNull()) { Handle(Geom2d_Curve) aC2dNew; - - if(aC3DE->IsPeriodic()) { BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF1, f, l, aC2d, aC2dNew, aContext); - } - else { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF1, aC3DETrim, aC2d, aC2dNew, aContext); - } aC2d = aC2dNew; } aBB.UpdateEdge(anEdge, aC2d, cpF1, aTolEdge); @@ -1702,15 +1689,9 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, if (!BOPTools_AlgoTools2D::HasCurveOnSurface(anEdge, cpF2)) { Handle(Geom2d_Curve) aC2d = aBC.Curve().SecondCurve2d(); - if(!aC3DETrim.IsNull()) { + if (!aC3DE.IsNull()) { Handle(Geom2d_Curve) aC2dNew; - - if(aC3DE->IsPeriodic()) { BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF2, f, l, aC2d, aC2dNew, aContext); - } - else { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF2, aC3DETrim, aC2d, aC2dNew, aContext); - } aC2d = aC2dNew; } aBB.UpdateEdge(anEdge, aC2d, cpF2, aTolEdge); diff --git a/src/BRepTest/BRepTest_SurfaceCommands.cxx b/src/BRepTest/BRepTest_SurfaceCommands.cxx index 454e3c0c0d..ee35292b6d 100644 --- a/src/BRepTest/BRepTest_SurfaceCommands.cxx +++ b/src/BRepTest/BRepTest_SurfaceCommands.cxx @@ -265,6 +265,8 @@ static Standard_Integer pcurve(Draw_Interpretor& , Standard_Integer n, const cha Standard_Boolean IsPeriodic = c->IsPeriodic(); if (c->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) { + // E.g. see "boolean bopfuse_complex J6" test script + const Handle(Geom2d_Curve)& aC = Handle(Geom2d_TrimmedCurve)::DownCast (c)->BasisCurve(); IsPeriodic = aC->IsPeriodic(); fr = aC->FirstParameter(); diff --git a/src/BRepTools/BRepTools.cxx b/src/BRepTools/BRepTools.cxx index 449a9c6530..57e352110d 100644 --- a/src/BRepTools/BRepTools.cxx +++ b/src/BRepTools/BRepTools.cxx @@ -62,6 +62,7 @@ #include #include #include +#include #include #include //======================================================================= @@ -1011,12 +1012,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::AllowExtend(*C3d, first, last)) { first = Max(first, C3d->FirstParameter()); last = Min(last, C3d->LastParameter()); } - if(!C2d->IsPeriodic()) + + if (!GeomLib::AllowExtend(*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..e5b85d3965 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::AllowExtend(*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..50ce78976b 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::AllowExtend(*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.hxx b/src/BiTgte/BiTgte_CurveOnEdge.hxx index 2dd590986c..d2223a61b1 100644 --- a/src/BiTgte/BiTgte_CurveOnEdge.hxx +++ b/src/BiTgte/BiTgte_CurveOnEdge.hxx @@ -87,8 +87,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! This method is not implemented Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; - + + //! This method is not implemented Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve. diff --git a/src/BiTgte/BiTgte_CurveOnVertex.hxx b/src/BiTgte/BiTgte_CurveOnVertex.hxx index 914bdd52a5..dda8d395fb 100644 --- a/src/BiTgte/BiTgte_CurveOnVertex.hxx +++ b/src/BiTgte/BiTgte_CurveOnVertex.hxx @@ -86,8 +86,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! This method is not implemented Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! This method is not implemented Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve. 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..324717e848 100644 --- a/src/Bisector/Bisector_BisecAna.cxx +++ b/src/Bisector/Bisector_BisecAna.cxx @@ -1398,7 +1398,7 @@ Standard_Boolean Bisector_BisecAna::IsClosed() const //============================================================================= Standard_Boolean Bisector_BisecAna::IsPeriodic() const { - return thebisector->BasisCurve()->IsPeriodic(); + return thebisector->IsPeriodic(); } //============================================================================= diff --git a/src/Bisector/Bisector_BisecAna.hxx b/src/Bisector/Bisector_BisecAna.hxx index fbc0b8a21d..a6b6684405 100644 --- a/src/Bisector/Bisector_BisecAna.hxx +++ b/src/Bisector/Bisector_BisecAna.hxx @@ -104,6 +104,7 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! This method is overridden from Geom2d_Curve::IsPeriodic() Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; diff --git a/src/Bisector/Bisector_BisecCC.hxx b/src/Bisector/Bisector_BisecCC.hxx index 8340c0f76c..e827f79419 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; + //! This method is overridden from Geom2d_Curve::IsPeriodic() 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..24c0005318 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; + //! This method is overridden from Geom2d_Curve::IsPeriodic() 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 fd166d3442..664218a5bf 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::AllowExtendUParameter(S, uu1, uu2)) + { + uu1 = Max(uu1,u1); + uu2 = Min(uu2,u2); + } + if (!GeomLib::AllowExtendVParameter(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) { @@ -2966,9 +2983,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(); @@ -3971,7 +3985,7 @@ Standard_EXPORT 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; @@ -4314,7 +4328,7 @@ Standard_EXPORT } } // 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.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 95b4d022d1..a740b65f8e 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 5329a15d48..6526ea773e 100644 --- a/src/Extrema/Extrema_ExtPExtS.cxx +++ b/src/Extrema/Extrema_ExtPExtS.cxx @@ -309,7 +309,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_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_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 40ac5b531a..c272726d4e 100644 --- a/src/Geom/Geom_ConicalSurface.hxx +++ b/src/Geom/Geom_ConicalSurface.hxx @@ -179,7 +179,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 diff --git a/src/Geom/Geom_Curve.hxx b/src/Geom/Geom_Curve.hxx index 4cacecc422..d32d5e73cb 100644 --- a/src/Geom/Geom_Curve.hxx +++ b/src/Geom/Geom_Curve.hxx @@ -141,25 +141,14 @@ public: //! 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 + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). 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 periodic curve. + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). Standard_EXPORT virtual Standard_Real Period() const; //! It is the global continuity of the curve diff --git a/src/Geom/Geom_OffsetCurve.cxx b/src/Geom/Geom_OffsetCurve.cxx index 5bdffddbf0..826ed688c4 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(); } diff --git a/src/Geom/Geom_OffsetCurve.hxx b/src/Geom/Geom_OffsetCurve.hxx index a195a85e92..05b9ca7f87 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. 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/Geom/Geom_OffsetSurface.cxx b/src/Geom/Geom_OffsetSurface.cxx index 207deca32d..0f3dc08ad6 100644 --- a/src/Geom/Geom_OffsetSurface.cxx +++ b/src/Geom/Geom_OffsetSurface.cxx @@ -639,6 +639,10 @@ 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 currently it is not checked. + return basisSurf->IsUPeriodic(); } @@ -659,6 +663,10 @@ 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 currently it is not checked. + return basisSurf->IsVPeriodic(); } diff --git a/src/Geom/Geom_OffsetSurface.hxx b/src/Geom/Geom_OffsetSurface.hxx index c568f3abac..2771f50c40 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 it is not 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 it is not 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_Surface.hxx b/src/Geom/Geom_Surface.hxx index 187c3b47d9..cd64d5073d 100644 --- a/src/Geom/Geom_Surface.hxx +++ b/src/Geom/Geom_Surface.hxx @@ -175,33 +175,25 @@ 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 + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). 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. + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). 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 + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). 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. + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). 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..b9f5fbf940 100644 --- a/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx +++ b/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx @@ -160,6 +160,9 @@ public: //! IsVPeriodic always returns false. Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! Returns the period of this surface in the u parametric direction. + virtual 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..cff770af8d 100644 --- a/src/Geom/Geom_SurfaceOfRevolution.hxx +++ b/src/Geom/Geom_SurfaceOfRevolution.hxx @@ -247,9 +247,12 @@ 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 the period of this surface in the v parametric direction. + 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_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..177a94eb27 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. 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/Geom2d/Geom2d_Curve.hxx b/src/Geom2d/Geom2d_Curve.hxx index 844993b2bb..ebf641bbc7 100644 --- a/src/Geom2d/Geom2d_Curve.hxx +++ b/src/Geom2d/Geom2d_Curve.hxx @@ -136,25 +136,14 @@ 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 + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). 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 periodic curve. + //! (please see the documentation, the section + //! " /User Guides/Modeling Data/Periodicity concept "). Standard_EXPORT virtual Standard_Real Period() const; diff --git a/src/Geom2d/Geom2d_OffsetCurve.cxx b/src/Geom2d/Geom2d_OffsetCurve.cxx index 2c4ea9536c..a3e07cdd83 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(); } 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 6ecbf6a5c4..b3b59423e9 100644 --- a/src/Geom2dAdaptor/Geom2dAdaptor_Curve.hxx +++ b/src/Geom2dAdaptor/Geom2dAdaptor_Curve.hxx @@ -102,8 +102,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; //! Computes the point of parameter U on the curve diff --git a/src/Geom2dConvert/Geom2dConvert.cxx b/src/Geom2dConvert/Geom2dConvert.cxx index 05c29d8388..c36a3abada 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::AllowExtend(*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 690480906c..9a05395f02 100644 --- a/src/GeomAdaptor/GeomAdaptor_Curve.hxx +++ b/src/GeomAdaptor/GeomAdaptor_Curve.hxx @@ -106,8 +106,10 @@ public: Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class 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..090b51da28 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; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class 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.hxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx index c67e10f8e9..8352037e8d 100644 --- a/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx @@ -116,12 +116,16 @@ public: Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; + //! Always returns FALSE Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Real VPeriod() const Standard_OVERRIDE; //! Returns the parametric U resolution corresponding diff --git a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx index 405d1a94af..9a431111b4 100644 --- a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx @@ -129,12 +129,16 @@ public: Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE; + //! Always returns TRUE Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class 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 f23298afa1..30ec9c6186 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::AllowExtend(*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.hxx b/src/GeomFill/GeomFill_SnglrFunc.hxx index 3de3e68e3f..1ce9c29247 100644 --- a/src/GeomFill/GeomFill_SnglrFunc.hxx +++ b/src/GeomFill/GeomFill_SnglrFunc.hxx @@ -65,8 +65,10 @@ 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 IsPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class 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..188bb4bb46 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,126 @@ Standard_Boolean GeomLib::IsBzVClosed (const Handle(Geom_BezierSurface)& S, return CompareWeightPoles(aPF, 0, aPL, 0, Tol2); } +//======================================================================= +//function : AllowExtendUParameter +//purpose : +//======================================================================= +Standard_Boolean GeomLib::AllowExtendUParameter(const GeomAdaptor_Surface& theS, + const Standard_Real theNewUFirst, + const Standard_Real theNewULast) +{ + const Handle(Geom_Surface) &aSurf = theS.Surface(); + Handle(Geom_Curve) aC = aSurf->VIso(theS.FirstVParameter()); + + 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 (AllowExtend(*aC, theNewUFirst, theNewULast)); +} + +//======================================================================= +//function : AllowExtendVParameter +//purpose : +//======================================================================= +Standard_Boolean GeomLib::AllowExtendVParameter(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 AllowExtendVParameter(GeomAdaptor_Surface(aOS->BasisSurface()), + theNewVFirst, theNewVLast); + } + + Handle(Geom_Curve) aC = aSurf->UIso(theS.FirstUParameter()); + + 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 (!AllowExtend(*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 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) + { + const Standard_Real aParF = theNewVFirst - Precision::PConfusion(), + aParL = theNewVLast + Precision::PConfusion(); + 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..414e3c293e 100644 --- a/src/GeomLib/GeomLib.hxx +++ b/src/GeomLib/GeomLib.hxx @@ -32,8 +32,11 @@ class Geom_Curve; class gp_Ax2; class Geom2d_Curve; +class Geom_Curve; class gp_GTrsf2d; class Adaptor3d_CurveOnSurface; +class Adaptor3d_Surface; +class GeomAdaptor_Surface; class Geom_BoundedCurve; class gp_Pnt; class gp_Vec; @@ -54,6 +57,8 @@ class GeomLib_Tool; class GeomLib_PolyFunc; class GeomLib_LogSample; +#include +#include //! Geom Library. This package provides an //! implementation of functions for basic computation @@ -193,6 +198,68 @@ public: Standard_EXPORT static void IsClosed(const Handle(Geom_Surface)& S, const Standard_Real Tol, Standard_Boolean& isUClosed, Standard_Boolean& isVClosed); + //! This method defines 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)& theCur, + const Standard_Real theTol) + { + const Standard_Real aFPar = theCur->FirstParameter(), + aLPar = theCur->LastParameter(); + + return (theCur->Value(aFPar).SquareDistance(theCur->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 AllowExtend(const 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 + AllowExtendUParameter(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 + AllowExtendVParameter(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.hxx b/src/GeomPlate/GeomPlate_Surface.hxx index 86dc118282..af8cad0b9a 100644 --- a/src/GeomPlate/GeomPlate_Surface.hxx +++ b/src/GeomPlate/GeomPlate_Surface.hxx @@ -149,31 +149,14 @@ 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. diff --git a/src/GeomProjLib/GeomProjLib.cxx b/src/GeomProjLib/GeomProjLib.cxx index d8c61cd84a..b608478107 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::AllowExtend(*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..9ada24b2e2 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 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] << " 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 d83d57cf4d..621bb7f8e4 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); @@ -1290,21 +1293,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 7a8d2e7263..366948c981 100644 --- a/src/IntPatch/IntPatch_Intersection.cxx +++ b/src/IntPatch/IntPatch_Intersection.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -1427,11 +1428,9 @@ 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); + IntPatch_WLineTool::ExtendTwoWLines(slin, theS1, theS2, TolTang, anArrOfPeriod, aBx1, aBx2); } diff --git a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx index 149f379d2d..d28b351dfa 100644 --- a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx +++ b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1575,10 +1576,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() || @@ -1980,33 +1978,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]; @@ -2041,7 +2019,8 @@ void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1, bIsNull=Standard_False; bIsPeriod=Standard_False; // - if (!bIsPeriodic[k]) { + if(aPeriod[k] == 0.0) + { continue; } // @@ -2146,10 +2125,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 b180d9abed..13e997b02e 100644 --- a/src/IntPatch/IntPatch_SpecialPoints.cxx +++ b/src/IntPatch/IntPatch_SpecialPoints.cxx @@ -339,16 +339,6 @@ Standard_Boolean IntPatch_SpecialPoints:: const Standard_Boolean theIsReversed, const Standard_Boolean theIsReqRefCheck) { - const Standard_Real aUpPeriod = thePSurf->IsUPeriodic() ? thePSurf->UPeriod() : 0.0; - const Standard_Real aUqPeriod = theQSurf->IsUPeriodic() ? theQSurf->UPeriod() : 0.0; - const Standard_Real aVpPeriod = thePSurf->IsVPeriodic() ? thePSurf->VPeriod() : 0.0; - const Standard_Real aVqPeriod = theQSurf->IsVPeriodic() ? theQSurf->VPeriod() : 0.0; - - const Standard_Real anArrOfPeriod[4] = {theIsReversed? aUpPeriod : aUqPeriod, - theIsReversed? aVpPeriod : aVqPeriod, - theIsReversed? aUqPeriod : aUpPeriod, - theIsReversed? aVqPeriod : aVpPeriod}; - //On parametric Standard_Real aU0 = 0.0, aV0 = 0.0; //aPQuad is Pole @@ -594,6 +584,16 @@ Standard_Boolean IntPatch_SpecialPoints:: if (!isIsoChoosen) { + Standard_Real anArrOfPeriod[4]; + if (theIsReversed) + { + IntSurf::SetPeriod(thePSurf, theQSurf, anArrOfPeriod); + } + else + { + IntSurf::SetPeriod(theQSurf, thePSurf, anArrOfPeriod); + } + AdjustPointAndVertex(theVertex.PntOn2S(), anArrOfPeriod, theAddedPoint); } else @@ -651,16 +651,19 @@ Standard_Boolean IntPatch_SpecialPoints:: //Here, in case of pole/apex adding, we forbid "jumping" between two neighbor //Walking-point 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 abfe5b0415..9dca2dfe37 100644 --- a/src/IntPatch/IntPatch_WLineTool.cxx +++ b/src/IntPatch/IntPatch_WLineTool.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -1416,10 +1417,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 8726f0ad56..44a69635da 100644 --- a/src/IntTools/IntTools_FaceFace.cxx +++ b/src/IntTools/IntTools_FaceFace.cxx @@ -1877,8 +1877,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) || @@ -2717,10 +2717,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 14185a3504..6657b91d97 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..a298bb8f73 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; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class 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..de5599e900 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; + //! This method is overridden from the basis class Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; + //! This method is overridden from the basis class 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 80f90678cb..a86fe3eb90 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -2834,6 +2834,83 @@ static Standard_Integer OCC29531(Draw_Interpretor&, Standard_Integer, const char 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::AllowExtend(*(aC2d.get()), aUf, aUl)) + { + theDI << "Extension is possible.\n"; + } + else + { + theDI << "Extension is not possible.\n"; + } + + return 0; + } + + const Handle(Geom_Curve) aC3d = DrawTrSurf::GetCurve(theArgV[1]); + + if (aC3d.IsNull()) + return 1; + + if (GeomLib::AllowExtend(*(aC3d.get()), aUf, aUl)) + { + theDI << "Extension is possible.\n"; + } + else + { + theDI << "Extension is not possible.\n"; + } + + return 0; +} + +//======================================================================= +//function : OCC29115c +//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::AllowExtendUParameter(anAS, aUf, aUl)) + { + theDI << "U-extension is possible.\n"; + } + else + { + theDI << "U-extension is not possible.\n"; + } + + if (GeomLib::AllowExtendVParameter(anAS, aVf, aVl)) + { + theDI << "V-extension is possible.\n"; + } + else + { + theDI << "V-extension is not possible.\n"; + } + + return 0; +} + void QABugs::Commands_20(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -2869,5 +2946,8 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) { __FILE__, OCC29430, group); theCommands.Add("OCC29531", "OCC29531 ", __FILE__, OCC29531, 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..60ecbf8140 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::AllowExtend(*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..7e7049f270 100644 --- a/src/ShapeFix/ShapeFix_EdgeProjAux.cxx +++ b/src/ShapeFix/ShapeFix_EdgeProjAux.cxx @@ -444,7 +444,7 @@ void ShapeFix_EdgeProjAux::Init2d (const Standard_Real preci) if(parU || parV) { 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 +578,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 5966d91a5a..66942371b7 100644 --- a/src/ShapeFix/ShapeFix_Wire.cxx +++ b/src/ShapeFix/ShapeFix_Wire.cxx @@ -1368,9 +1368,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(); @@ -1379,7 +1383,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 a0351ee029..f050e8114e 100644 --- a/src/StepToTopoDS/StepToTopoDS_GeometricTool.cxx +++ b/src/StepToTopoDS/StepToTopoDS_GeometricTool.cxx @@ -261,7 +261,7 @@ 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() else if (theCurve->IsClosed()) { // l'un des points projecte se trouve sur l'origine du parametrage 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 24307fb384..c25048f11f 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..7851a1f20a --- /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 600 + +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..739b1dd0bc --- /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 + +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..a0d17445e0 --- /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 "Extension is possible" [OCC29115c c1 0 pi] ] } { + puts "Error in \"c1 0 pi\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c1 5*pi 11*pi/2] ] } { + puts "Error in \"c1 5*pi 11*pi/2\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c1 100*pi 102*pi] ] } { + puts "Error in \"c1 100*pi 102*pi\"-extension computation " +} + +if { ! [regexp "Extension is not possible" [OCC29115c c1 50*pi 55*pi] ] } { + puts "Error in \"c1 50*pi 55*pi\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c2 0 pi] ] } { + puts "Error in \"c2 0 pi\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c2 5*pi 11*pi/2] ] } { + puts "Error in \"c2 5*pi 11*pi/2\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c2 100*pi 102*pi] ] } { + puts "Error in \"c2 100*pi 102*pi\"-extension computation " +} + +if { ! [regexp "Extension is not possible" [OCC29115c c2 50*pi 55*pi] ] } { + puts "Error in \"c2 50*pi 55*pi\"-extension computation " +} diff --git a/tests/bugs/modalg_7/bug29115_2 b/tests/bugs/modalg_7/bug29115_2 new file mode 100644 index 0000000000..bcea39e648 --- /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 "Extension is possible" [OCC29115c c1 0 0.1] ] } { + puts "Error in \"c1 0 0.1\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c1 0.6 0.78] ] } { + puts "Error in \"c1 0.6 0.78\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c1 0.5 1] ] } { + puts "Error in \"c1 0.5 1\"-extension computation " +} + +if { ! [regexp "Extension is not possible" [OCC29115c c1 0.8 1.5] ] } { + puts "Error in \"c1 0.8 1.5\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c2 0 0.1] ] } { + puts "Error in \"c2 0 0.1\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c2 0.6 0.78] ] } { + puts "Error in \"c2 0.6 0.78\"-extension computation " +} + +if { ! [regexp "Extension is possible" [OCC29115c c2 0.5 1] ] } { + puts "Error in \"c2 0.5 1\"-extension computation " +} + +if { ! [regexp "Extension is not possible" [OCC29115c c2 0.8 1.5] ] } { + puts "Error in \"c2 0.8 1.5\"-extension computation " +} diff --git a/tests/bugs/modalg_7/bug29115_3 b/tests/bugs/modalg_7/bug29115_3 new file mode 100644 index 0000000000..8d45fbd426 --- /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-extension is possible.\nV-extension is possible." [OCC29115s s1 0 2*pi -1 1] ] } { + puts "Error in \"s1 0 2*pi -1 1\"-extension computation " +} + +if { ! [regexp "U-extension is not possible.\nV-extension is possible." [OCC29115s s1 pi 5*pi -1 1] ] } { + puts "Error in \"s1 pi 5*pi -1 1\"-extension computation " +} + +if { ! [regexp "U-extension is possible.\nV-extension is not possible." [OCC29115s s1 0 2*pi 1 2] ] } { + puts "Error in \"s1 0 2*pi 1 2\"-extension computation " +} diff --git a/tests/bugs/modalg_7/bug29115_4 b/tests/bugs/modalg_7/bug29115_4 new file mode 100644 index 0000000000..4616b62a03 --- /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-extension is possible.\nV-extension is possible." [OCC29115s s1 0 2*pi 0 150] ] } { + puts "Error in \"s1 0 2*pi -1 1\"-extension computation " +} + +if { ! [regexp "U-extension is possible.\nV-extension is not possible." [OCC29115s s1 0 2*pi -150 0] ] } { + puts "Error in \"s1 0 2*pi 1 2\"-extension computation " +} diff --git a/tests/bugs/modalg_7/bug29115_5 b/tests/bugs/modalg_7/bug29115_5 new file mode 100644 index 0000000000..507ba42cc9 --- /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-extension is possible.\nV-extension is possible." [OCC29115s s1 0 2*pi 0 1] ] } { + puts "Error in \"s1 0 2*pi 0 1\"-extension computation " +} + +if { ! [regexp "U-extension is possible.\nV-extension is possible." [OCC29115s s2 0 2*pi 0 1] ] } { + puts "Error in \"s2 0 2*pi 0 1\"-extension computation " +} + +## + +if { ! [regexp "U-extension is possible.\nV-extension is not possible." [OCC29115s s1 10*pi 12*pi -0.2 1] ] } { + puts "Error in \"s1 10*pi 12*pi -0.2 1\"-extension computation " +} + +if { ! [regexp "U-extension is possible.\nV-extension is possible." [OCC29115s s2 10*pi 12*pi -0.2 1] ] } { + puts "Error in \"s2 10*pi 12*pi -0.2 1\"-extension computation " +} + +## + +if { ! [regexp "U-extension is not possible.\nV-extension is not possible." [OCC29115s s1 -pi 2*pi 0.5 1.5] ] } { + puts "Error in \"s1 -pi 2*pi 0.5 1.5\"-extension computation " +} + +if { ! [regexp "U-extension is not possible.\nV-extension is not possible." [OCC29115s s2 -pi 2*pi 0.5 1.5] ] } { + puts "Error in \"s2 -pi 2*pi 0.5 1.5\"-extension 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 845105e1f0..9778c906df 100644 --- a/tests/geometry/grids.list +++ b/tests/geometry/grids.list @@ -12,3 +12,4 @@ 012 parabola 013 project 014 revsurf +015 geomperiodic -- 2.39.5