0022759: [EDF] Creation of a surface from several edges: added test and example

This commit is contained in:
mpa 2014-12-09 11:06:01 +03:00
parent 34cab1d897
commit aafd2e3f32
5 changed files with 35 additions and 8 deletions

View File

@ -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") sketcher3 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
isPlanarFace = 1 isPlanarFace = 1
sphere = geompy.MakeSphereR(100)
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
cut = geompy.MakeCutList(sphere, [box], True)
# create a face from the wire # create a face from the wire
face1 = geompy.MakeFace(wire, isPlanarFace) face1 = geompy.MakeFace(wire, isPlanarFace)
@ -38,11 +42,17 @@ face2 = geompy.MakeFaceWires([wire, sketcher1],isPlanarFace)
face3 = geompy.MakeFaces([sketcher2, sketcher3],isPlanarFace) face3 = geompy.MakeFaces([sketcher2, sketcher3],isPlanarFace)
face4 = geompy.MakeFaceFromSurface(face1, sketcher1) 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 # add objects in the study
id_face1 = geompy.addToStudy(face1,"Face1") id_face1 = geompy.addToStudy(face1,"Face1")
id_face2 = geompy.addToStudy(face2,"Face2") id_face2 = geompy.addToStudy(face2,"Face2")
id_face3 = geompy.addToStudy(face3,"Face3") id_face3 = geompy.addToStudy(face3,"Face3")
id_face4 = geompy.addToStudy(face4,"Face4") id_face4 = geompy.addToStudy(face4,"Face4")
id_face5 = geompy.addToStudy(face5,"Face5")
# display the faces # display the faces
gg.createAndDisplayGO(id_face1) gg.createAndDisplayGO(id_face1)
@ -57,3 +67,6 @@ gg.setTransparency(id_face3,0.2)
gg.createAndDisplayGO(id_face4) gg.createAndDisplayGO(id_face4)
gg.setDisplayMode(id_face4,1) gg.setDisplayMode(id_face4,1)
gg.setTransparency(id_face4,0.2) gg.setTransparency(id_face4,0.2)
gg.createAndDisplayGO(id_face5)
gg.setDisplayMode(id_face5,1)
gg.setTransparency(id_face5,0.2)

View File

@ -346,6 +346,7 @@ bool BuildGUI_FaceDlg::ClickOnApply()
//================================================================================= //=================================================================================
void BuildGUI_FaceDlg::SelectionIntoArgument() void BuildGUI_FaceDlg::SelectionIntoArgument()
{ {
erasePreview();
if( myEditCurrentArgument == myGroupWire->LineEdit1 ) { if( myEditCurrentArgument == myGroupWire->LineEdit1 ) {
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
@ -394,8 +395,10 @@ void BuildGUI_FaceDlg::SelectionIntoArgument()
myCurrentItem->setFace( aSelectedObject ); myCurrentItem->setFace( aSelectedObject );
findEmptyTreeItem(); findEmptyTreeItem();
} }
else else {
myCurrentItem->setFace(NULL); myCurrentItem->setFace(NULL);
displayPreview( myCurrentItem->getEdge().get(), true, false, true, 5, -1, Quantity_NOC_RED);
}
} }
else { else {
myWire.nullify(); 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; return;
myCurrentItem = dynamic_cast<BuildGUI_TreeWidgetItem*>( theItem ); myCurrentItem = dynamic_cast<BuildGUI_TreeWidgetItem*>( theItem );
erasePreview(); displayPreview( true );
displayPreview( myCurrentItem->getEdge().get(), true, false, true, 5, -1, Quantity_NOC_RED); 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; int j = 0;
for( int i = 0; i < numberOfItems; i++ ) { for( int i = 0; i < numberOfItems; i++ ) {
BuildGUI_TreeWidgetItem* item = dynamic_cast<BuildGUI_TreeWidgetItem*>( myTreeConstraints->topLevelItem(i) ); BuildGUI_TreeWidgetItem* item = dynamic_cast<BuildGUI_TreeWidgetItem*>( myTreeConstraints->topLevelItem(i) );
constraints[j++] = item->getEdge().get(); constraints[j++] = GEOM::GEOM_Object::_duplicate(item->getEdge().get());
if ( item->getFace() ) if ( item->getFace() )
constraints[j++] = item->getFace().get(); constraints[j++] = GEOM::GEOM_Object::_duplicate(item->getFace().get());
} }
constraints->length(j); constraints->length(j);
anObj = anOper->MakeFaceWithConstraints( constraints.in() ); anObj = anOper->MakeFaceWithConstraints( constraints.in() );

View File

@ -259,7 +259,8 @@ void GEOMBase_Helper::displayPreview( const bool display,
const bool toRemoveFromEngine, const bool toRemoveFromEngine,
const double lineWidth, const double lineWidth,
const int displayMode, const int displayMode,
const int color ) const int color,
const bool append )
{ {
if(!display) { if(!display) {
erasePreview( update ); erasePreview( update );
@ -275,6 +276,7 @@ void GEOMBase_Helper::displayPreview( const bool display,
return; return;
} }
if( !append )
erasePreview( false ); erasePreview( false );
try { try {

View File

@ -79,7 +79,8 @@ protected:
const bool toRemoveFromEngine = true, const bool toRemoveFromEngine = true,
const double lineWidth = -1, const double lineWidth = -1,
const int displayMode = -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. // This is the easiest way to show preview. It is based on execute() method.
// It removes temporary GEOM::GEOM_Objects automatically. // It removes temporary GEOM::GEOM_Objects automatically.

View File

@ -179,6 +179,12 @@ def TestAll (geompy, math):
Face3 = geompy.MakeFaceHW (100., 200., 1) #(2 Doubles, 1 Int)->GEOM_Object 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 Face4 = geompy.MakeFaceObjHW (vz, 200., 100.) #(1 GEOM_Object, 2 Doubles)->GEOM_Object
Face5 = geompy.MakeFaceFromSurface(Face, Sketcher) #(2 GEOM_Objects)->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 Disk = geompy.MakeDiskPntVecR (p0, vz, radius) #(2 GEOM_Object, 1 Double)->GEOM_Object
Disk2 = geompy.MakeDiskThreePnt(p0, p200, pz) #(3 GEOM_Object)->GEOM_Object Disk2 = geompy.MakeDiskThreePnt(p0, p200, pz) #(3 GEOM_Object)->GEOM_Object
Disk3 = geompy.MakeDiskR(100., 1) #(1 Doubles, 1 Int)->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_Common = geompy.addToStudy(Common, "Common")
id_Cut = geompy.addToStudy(Cut, "Cut") id_Cut = geompy.addToStudy(Cut, "Cut")
id_Cut2 = geompy.addToStudy(Cut2, "Cut2")
id_Fuse = geompy.addToStudy(Fuse, "Fuse") id_Fuse = geompy.addToStudy(Fuse, "Fuse")
id_Section = geompy.addToStudy(Section, "Section") id_Section = geompy.addToStudy(Section, "Section")
@ -408,6 +415,7 @@ def TestAll (geompy, math):
id_Face3 = geompy.addToStudy(Face3, "Face Height Width") id_Face3 = geompy.addToStudy(Face3, "Face Height Width")
id_Face4 = geompy.addToStudy(Face4, "Face Plane_HW") id_Face4 = geompy.addToStudy(Face4, "Face Plane_HW")
id_Face5 = geompy.addToStudy(Face5, "Face from surface and wire") 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_Disk = geompy.addToStudy(Disk, "Disk PntVecR")
id_Disk2 = geompy.addToStudy(Disk2, "Disk Three Points") id_Disk2 = geompy.addToStudy(Disk2, "Disk Three Points")
id_Disk3 = geompy.addToStudy(Disk3, "Disk OXY Radius") id_Disk3 = geompy.addToStudy(Disk3, "Disk OXY Radius")