From: mpa Date: Tue, 9 Dec 2014 08:06:01 +0000 (+0300) Subject: 0022759: [EDF] Creation of a surface from several edges: added test and example X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmpa%2F22759;p=modules%2Fgeom.git 0022759: [EDF] Creation of a surface from several edges: added test and example --- diff --git a/doc/salome/examples/topological_geom_objs_ex03.py b/doc/salome/examples/topological_geom_objs_ex03.py index 972d81a6f..a88e68578 100644 --- a/doc/salome/examples/topological_geom_objs_ex03.py +++ b/doc/salome/examples/topological_geom_objs_ex03.py @@ -30,6 +30,10 @@ sketcher2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW") sketcher3 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW") isPlanarFace = 1 +sphere = geompy.MakeSphereR(100) +box = geompy.MakeBoxDXDYDZ(200, 200, 200) +cut = geompy.MakeCutList(sphere, [box], True) + # create a face from the wire face1 = geompy.MakeFace(wire, isPlanarFace) @@ -38,11 +42,17 @@ face2 = geompy.MakeFaceWires([wire, sketcher1],isPlanarFace) face3 = geompy.MakeFaces([sketcher2, sketcher3],isPlanarFace) face4 = geompy.MakeFaceFromSurface(face1, sketcher1) +# create face on wire with constraints +face5 = geompy.MakeFaceWithConstraints([geompy.GetSubShape(cut, [5]), geompy.GetSubShape(cut, [3]), + geompy.GetSubShape(cut, [11]), geompy.GetSubShape(cut, [3]), + geompy.GetSubShape(cut, [13]), geompy.GetSubShape(cut, [3])]) + # add objects in the study id_face1 = geompy.addToStudy(face1,"Face1") id_face2 = geompy.addToStudy(face2,"Face2") id_face3 = geompy.addToStudy(face3,"Face3") id_face4 = geompy.addToStudy(face4,"Face4") +id_face5 = geompy.addToStudy(face5,"Face5") # display the faces gg.createAndDisplayGO(id_face1) @@ -57,3 +67,6 @@ gg.setTransparency(id_face3,0.2) gg.createAndDisplayGO(id_face4) gg.setDisplayMode(id_face4,1) gg.setTransparency(id_face4,0.2) +gg.createAndDisplayGO(id_face5) +gg.setDisplayMode(id_face5,1) +gg.setTransparency(id_face5,0.2) diff --git a/src/BuildGUI/BuildGUI_FaceDlg.cxx b/src/BuildGUI/BuildGUI_FaceDlg.cxx index f1b0a4601..f5c569ad2 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.cxx +++ b/src/BuildGUI/BuildGUI_FaceDlg.cxx @@ -346,6 +346,7 @@ bool BuildGUI_FaceDlg::ClickOnApply() //================================================================================= void BuildGUI_FaceDlg::SelectionIntoArgument() { + erasePreview(); if( myEditCurrentArgument == myGroupWire->LineEdit1 ) { myEditCurrentArgument->setText(""); @@ -394,8 +395,10 @@ void BuildGUI_FaceDlg::SelectionIntoArgument() myCurrentItem->setFace( aSelectedObject ); findEmptyTreeItem(); } - else + else { myCurrentItem->setFace(NULL); + displayPreview( myCurrentItem->getEdge().get(), true, false, true, 5, -1, Quantity_NOC_RED); + } } else { myWire.nullify(); @@ -414,7 +417,7 @@ void BuildGUI_FaceDlg::SelectionIntoArgument() } } } - //displayPreview(true); + displayPreview(true, false, true, true, -1, -1, -1, true); } @@ -490,7 +493,7 @@ void BuildGUI_FaceDlg::onItemClicked( QTreeWidgetItem* theItem, int theColumn ) return; myCurrentItem = dynamic_cast( theItem ); - erasePreview(); + displayPreview( true ); displayPreview( myCurrentItem->getEdge().get(), true, false, true, 5, -1, Quantity_NOC_RED); } @@ -575,9 +578,9 @@ bool BuildGUI_FaceDlg::execute( ObjectList& objects ) int j = 0; for( int i = 0; i < numberOfItems; i++ ) { BuildGUI_TreeWidgetItem* item = dynamic_cast( myTreeConstraints->topLevelItem(i) ); - constraints[j++] = item->getEdge().get(); + constraints[j++] = GEOM::GEOM_Object::_duplicate(item->getEdge().get()); if ( item->getFace() ) - constraints[j++] = item->getFace().get(); + constraints[j++] = GEOM::GEOM_Object::_duplicate(item->getFace().get()); } constraints->length(j); anObj = anOper->MakeFaceWithConstraints( constraints.in() ); diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 037fd087a..439bfe7ee 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -259,7 +259,8 @@ void GEOMBase_Helper::displayPreview( const bool display, const bool toRemoveFromEngine, const double lineWidth, const int displayMode, - const int color ) + const int color, + const bool append ) { if(!display) { erasePreview( update ); @@ -275,7 +276,8 @@ void GEOMBase_Helper::displayPreview( const bool display, return; } - erasePreview( false ); + if( !append ) + erasePreview( false ); try { SUIT_OverrideCursor wc; diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index 731b63d06..1878610e2 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -79,7 +79,8 @@ protected: const bool toRemoveFromEngine = true, const double lineWidth = -1, const int displayMode = -1, - const int color = -1 ); + const int color = -1, + const bool append = false ); // This is the easiest way to show preview. It is based on execute() method. // It removes temporary GEOM::GEOM_Objects automatically. diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 6dafa5265..493aff992 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -179,6 +179,12 @@ def TestAll (geompy, math): Face3 = geompy.MakeFaceHW (100., 200., 1) #(2 Doubles, 1 Int)->GEOM_Object Face4 = geompy.MakeFaceObjHW (vz, 200., 100.) #(1 GEOM_Object, 2 Doubles)->GEOM_Object Face5 = geompy.MakeFaceFromSurface(Face, Sketcher) #(2 GEOM_Objects)->GEOM_Object + + Cut2 = geompy.MakeCutList(Sphere1, [Box1], True) + #(List of GEOM_Object)->GEOM_Object + Face6 = geompy.MakeFaceWithConstraints([geompy.GetSubShape(Cut2, [5]), geompy.GetSubShape(Cut2, [3]), + geompy.GetSubShape(Cut2, [11]), geompy.GetSubShape(Cut2, [3]), + geompy.GetSubShape(Cut2, [13]), geompy.GetSubShape(Cut2, [3])]) Disk = geompy.MakeDiskPntVecR (p0, vz, radius) #(2 GEOM_Object, 1 Double)->GEOM_Object Disk2 = geompy.MakeDiskThreePnt(p0, p200, pz) #(3 GEOM_Object)->GEOM_Object Disk3 = geompy.MakeDiskR(100., 1) #(1 Doubles, 1 Int)->GEOM_Object @@ -396,6 +402,7 @@ def TestAll (geompy, math): id_Common = geompy.addToStudy(Common, "Common") id_Cut = geompy.addToStudy(Cut, "Cut") + id_Cut2 = geompy.addToStudy(Cut2, "Cut2") id_Fuse = geompy.addToStudy(Fuse, "Fuse") id_Section = geompy.addToStudy(Section, "Section") @@ -408,6 +415,7 @@ def TestAll (geompy, math): id_Face3 = geompy.addToStudy(Face3, "Face Height Width") id_Face4 = geompy.addToStudy(Face4, "Face Plane_HW") id_Face5 = geompy.addToStudy(Face5, "Face from surface and wire") + id_Face6 = geompy.addToStudy(Face6, "Face on wire with constraints") id_Disk = geompy.addToStudy(Disk, "Disk PntVecR") id_Disk2 = geompy.addToStudy(Disk2, "Disk Three Points") id_Disk3 = geompy.addToStudy(Disk3, "Disk OXY Radius")