From c5b42a1afed700a4e00fa306863b9c772b46c3d1 Mon Sep 17 00:00:00 2001 From: akaftasev Date: Mon, 2 Nov 2020 17:23:14 +0300 Subject: [PATCH] 0030342: Modeling Data - Successively trimming surface in both directions lose the first trim Added trim for U and V directions when trimming happens sequentially in these directions. Added possibility to set sense to trim command. --- dox/upgrade/upgrade.md | 14 +++++ .../draw_test_harness/draw_test_harness.md | 6 +- src/Geom/Geom_RectangularTrimmedSurface.cxx | 58 ++++++++++++++----- .../GeomliteTest_SurfaceCommands.cxx | 54 ++++++++++++++--- tests/bugs/moddata_3/bug30342_1 | 17 ++++++ tests/bugs/moddata_3/bug30342_2 | 17 ++++++ 6 files changed, 142 insertions(+), 24 deletions(-) create mode 100644 tests/bugs/moddata_3/bug30342_1 create mode 100644 tests/bugs/moddata_3/bug30342_2 diff --git a/dox/upgrade/upgrade.md b/dox/upgrade/upgrade.md index fdb3a8ee03..34958e3bd6 100644 --- a/dox/upgrade/upgrade.md +++ b/dox/upgrade/upgrade.md @@ -2156,3 +2156,17 @@ Message files (with extension .msg) are now expected to be in UTF-8 encoding (un This allows using arbitrary Unicode symbols for localization of messages. Existing message files containing 8-bit characters (previously interpreted as characters from Latin-1 code block) should be converted to UTF-8. + +@section upgrade_occt760 Upgrade to OCCT 7.6.0 + +@subsection upgrade_760_trimming_surface Trimming surface + +Geom_RectangularTrimmedSurface sequentially trimming in U and V directions already no longer loses the first trim. +For example: +~~~~~ + Handle(Geom_RectangularTrimmedSurface) ST = new Geom_RectangularTrimmedSurface (Sbase, u1, u2, Standard_True); // trim along U + Handle(Geom_RectangularTrimmedSurface) ST1 = new Geom_RectangularTrimmedSurface (ST, v1, v2, Standard_False); // trim along V +~~~~~ +gives different result. +In current version ST1 - surface trimmed only along V, U trim is removed; +After modification ST1 - surface trimmed along U and V, U trim is kept. diff --git a/dox/user_guides/draw_test_harness/draw_test_harness.md b/dox/user_guides/draw_test_harness/draw_test_harness.md index a88eda07ea..d746707c3a 100644 --- a/dox/user_guides/draw_test_harness/draw_test_harness.md +++ b/dox/user_guides/draw_test_harness/draw_test_harness.md @@ -4879,9 +4879,9 @@ bsplinesurf s \ Syntax: ~~~~~ -trim newname name [u1 u2 [v1 v2]] -trimu newname name -trimv newname name +trim newname name [u1 u2 [v1 v2] [usense vsense]] +trimu newname name u1 u2 [usense] +trimv newname name v1 v2 [vsense] ~~~~~ The **trim** commands create trimmed curves or trimmed surfaces. Note that trimmed curves and surfaces are classes of the *Geom* package. diff --git a/src/Geom/Geom_RectangularTrimmedSurface.cxx b/src/Geom/Geom_RectangularTrimmedSurface.cxx index 69bb5b3ea5..835bdaeaeb 100644 --- a/src/Geom/Geom_RectangularTrimmedSurface.cxx +++ b/src/Geom/Geom_RectangularTrimmedSurface.cxx @@ -67,15 +67,15 @@ Handle(Geom_Geometry) Geom_RectangularTrimmedSurface::Copy () const { S = new RectangularTrimmedSurface (basisSurf, utrim1 , utrim2, vtrim1 , vtrim2, - Standard_True , Standard_True ); + Standard_True, Standard_True); else if ( isutrimmed) S = new RectangularTrimmedSurface (basisSurf, utrim1 , utrim2, - Standard_True, Standard_True ); + Standard_True, Standard_True); else if (isvtrimmed) S = new RectangularTrimmedSurface (basisSurf, vtrim1 , vtrim2, - Standard_False , Standard_True ); + Standard_False , Standard_True); return S; } @@ -138,7 +138,6 @@ Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface ( const Standard_Boolean UTrim, const Standard_Boolean Sense ) { - // kill trimmed basis surfaces Handle(Geom_RectangularTrimmedSurface) T = Handle(Geom_RectangularTrimmedSurface)::DownCast(S); @@ -156,6 +155,20 @@ Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface ( basisSurf = new Geom_OffsetSurface(S2, O->Offset(), Standard_True); } + if (!T.IsNull()) + { + if (UTrim && T->isvtrimmed) + { + SetTrim(Param1, Param2, T->vtrim1, T->vtrim2, Sense, Standard_True); + return; + } + else if (!UTrim && T->isutrimmed) + { + SetTrim(T->utrim1, T->utrim2, Param1, Param2, Standard_True, Sense); + return; + } + } + SetTrim(Param1, Param2, UTrim, Sense); } @@ -171,7 +184,6 @@ void Geom_RectangularTrimmedSurface::SetTrim (const Standard_Real U1, const Standard_Real V2, const Standard_Boolean USense, const Standard_Boolean VSense ) { - SetTrim( U1, U2, V1, V2, Standard_True, Standard_True, USense, VSense); } @@ -193,16 +205,36 @@ void Geom_RectangularTrimmedSurface::SetTrim (const Standard_Real Param1, Standard_Boolean dummy_Sense = Standard_True; if ( UTrim) { - SetTrim( Param1 , Param2 , - dummy_a , dummy_b , - Standard_True , Standard_False, - Sense , dummy_Sense ); + if (isvtrimmed) + { + SetTrim (Param1, Param2, + vtrim1, vtrim2, + Standard_True, Standard_True, + Sense, dummy_Sense); + } + else + { + SetTrim (Param1, Param2, + dummy_a, dummy_b, + Standard_True, Standard_False, + Sense, dummy_Sense); + } } else { - SetTrim( dummy_a , dummy_b , - Param1 , Param2 , - Standard_False, Standard_True, - dummy_Sense , Sense ); + if (isutrimmed) + { + SetTrim (utrim1, utrim2, + Param1, Param2, + Standard_True, Standard_True, + dummy_Sense, Sense); + } + else + { + SetTrim (dummy_a, dummy_b, + Param1, Param2, + Standard_False, Standard_True, + dummy_Sense, Sense); + } } } diff --git a/src/GeomliteTest/GeomliteTest_SurfaceCommands.cxx b/src/GeomliteTest/GeomliteTest_SurfaceCommands.cxx index be942fb046..2ad175db9d 100644 --- a/src/GeomliteTest/GeomliteTest_SurfaceCommands.cxx +++ b/src/GeomliteTest/GeomliteTest_SurfaceCommands.cxx @@ -424,28 +424,48 @@ static Standard_Integer trimming (Draw_Interpretor& , Standard_Real u1 = Draw::Atof(a[3]); Standard_Real u2 = Draw::Atof(a[4]); + Standard_Real v1 = 0., v2 = 0.; + Standard_Boolean USense = Standard_True, VSense = Standard_True; + Handle(Geom_Geometry) result; Handle(Geom2d_Curve) result2d; if (!strcasecmp(a[0],"trim")) { if (!GS.IsNull()) { if (n<7) return 1; + v1 = Draw::Atof(a[5]); + v2 = Draw::Atof(a[6]); + if (n > 7) + { + USense = *a[7] != '0'; + VSense = *a[8] != '0'; + } result = - new Geom_RectangularTrimmedSurface(GS,u1,u2,Draw::Atof(a[5]),Draw::Atof(a[6])); + new Geom_RectangularTrimmedSurface(GS, u1, u2, v1, v2, USense, VSense); } else if (!GC.IsNull()) { - result = new Geom_TrimmedCurve(GC, u1, u2); + if (n>5) + { + USense = *a[5] != '0'; + } + result = new Geom_TrimmedCurve(GC, u1, u2, USense); } else if (!GC2d.IsNull()) { - result2d = new Geom2d_TrimmedCurve(GC2d, u1, u2); + if (n > 5) + { + USense = *a[5] != '0'; + } + result2d = new Geom2d_TrimmedCurve(GC2d, u1, u2, USense); } else return 1; } else { if (GS.IsNull()) return 1; - result = new Geom_RectangularTrimmedSurface(GS,u1,u2, - !strcasecmp(a[0],"trimu")); + Standard_Boolean Utrim = !strcasecmp(a[0], "trimu"); + if (n > 5) + USense = *a[5] != '0'; + result = new Geom_RectangularTrimmedSurface(GS, u1, u2, Utrim, USense); } if (!result.IsNull()) @@ -1642,17 +1662,35 @@ void GeomliteTest::SurfaceCommands(Draw_Interpretor& theCommands) offseting,g); theCommands.Add("trim", - "trim newname name [u1 u2 [v1 v2]], no args remove trim", + "trim newname name [u1 u2 [v1 v2] [usense=1 vsense=1]]" + "\n\t\t: Creates either a new trimmed curve from a curve" + "\n\t\t: or a new trimmed surface in u and v from a surface." + "\n\t\t: Removes trim when called without arguments." + "\n\t\t: - u1 u2 lower and upper parameters of trimming on U direction" + "\n\t\t: - v1 v2 lower and upper parameters of trimming on V direction" + "\n\t\t: - usense vsense senses on U and V directions: 1 - true, 0 - false;" + "\n\t\t Senses are used for the construction only if the surface is periodic" + "\n\t\t in the corresponding parametric direction, and define the available part of the surface", __FILE__, trimming,g); theCommands.Add("trimu", - "trim newname name u1 u2", + "trimu newname name u1 u2 [usense=1]" + "\n\t\t: Creates a u-trimmed surface." + "\n\t\t: - u1 u2 lower and upper parameters of trimming on U direction" + "\n\t\t: - usense sense on U direction: 1 - true, 0 - false;" + "\n\t\t usense is used for the construction only if the surface is u-periodic" + "\n\t\t in the u parametric direction, and define the available part of the surface", __FILE__, trimming,g); theCommands.Add("trimv", - "trim newname name v1 v2", + "trimv newname name v1 v2 [vsense=1]" + "\n\t\t: Creates a v-trimmed surface." + "\n\t\t: - u1 u2 lower and upper parameters of trimming on V direction" + "\n\t\t: - vsense sense on V direction: 1 - true, 0 - false;" + "\n\t\t vsense is used for the construction only if the surface is v-periodic" + "\n\t\t in the v parametric direction, and define the available part of the surface", __FILE__, trimming,g); diff --git a/tests/bugs/moddata_3/bug30342_1 b/tests/bugs/moddata_3/bug30342_1 new file mode 100644 index 0000000000..b6af94d837 --- /dev/null +++ b/tests/bugs/moddata_3/bug30342_1 @@ -0,0 +1,17 @@ +puts "==========" +puts "0030342: Modeling Data - Successively trimming surface in both directions lose the first trim" +puts "==========" +puts "" + +cylinder c1 10 + +trim c3 c1 0 3.14 0 50 +set expected [dump c3] + +trimu c2 c1 0 3.14 +trimv c3 c2 0 50 + +set result [dump c3] +if { [string compare $expected $result] != 0 } { + puts "Error: invalid result" +} diff --git a/tests/bugs/moddata_3/bug30342_2 b/tests/bugs/moddata_3/bug30342_2 new file mode 100644 index 0000000000..61f829500d --- /dev/null +++ b/tests/bugs/moddata_3/bug30342_2 @@ -0,0 +1,17 @@ +puts "==========" +puts "0030342: Modeling Data - Successively trimming surface in both directions lose the first trim" +puts "==========" +puts "" + +torus t 1 0.5 + +trim t2 t 0 2 0 4 0 0 +set expected [dump t2] + +trimu t1 t 0 2 0 +trimv t2 t1 0 4 0 + +set result [dump t2] +if { [string compare $expected $result] != 0 } { + puts "Error: invalid result" +} -- 2.20.1