DCQ : Add MakeFaces Method

This commit is contained in:
dcq 2004-04-08 08:14:25 +00:00
parent 9c483772d1
commit bc58667418
11 changed files with 130 additions and 51 deletions

View File

@ -238,7 +238,9 @@ module GEOM
GEOM_Shape MakeWire (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeWire (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ;
GEOM_Shape MakeCompound (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeCompound (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ;
GEOM_Shape MakeFace (in GEOM_Shape shapeWire, GEOM_Shape MakeFace (in GEOM_Shape shapeWire,
in boolean wantplanarface ) raises (SALOME::SALOME_Exception) ; in boolean wantplanarface) raises (SALOME::SALOME_Exception) ;
GEOM_Shape MakeFaces (in ListOfIOR ListShape,
in boolean wantplanarface) raises (SALOME::SALOME_Exception) ;
GEOM_Shape MakeShell (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeShell (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ;
GEOM_Shape MakeSolid (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeSolid (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ;

View File

@ -164,10 +164,11 @@ void BuildGUI::MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR)
// function : MakeFaceAndDisplay() // function : MakeFaceAndDisplay()
// purpose : // purpose :
//===================================================================================== //=====================================================================================
void BuildGUI::MakeFaceAndDisplay(GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar) void BuildGUI::MakeFaceAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
const Standard_Boolean wantPlanar)
{ {
try { try {
GEOM::GEOM_Shape_var result = myGeom->MakeFace(aWire, wantPlanar); GEOM::GEOM_Shape_var result = myGeom->MakeFaces(listShapesIOR, wantPlanar);
if(result->_is_nil()) { if(result->_is_nil()) {
QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
return; return;

View File

@ -48,7 +48,8 @@ public :
void MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2); void MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2);
void MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); void MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR);
void MakeFaceAndDisplay(GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar); void MakeFaceAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
const Standard_Boolean wantPlanar);
void MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); void MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR);
void MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); void MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR);
void MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); void MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR);

View File

@ -52,7 +52,7 @@ BuildGUI_FaceDlg::BuildGUI_FaceDlg(QWidget* parent, const char* name, BuildGUI*
GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints"); GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints");
GroupPoints->GroupBox1->setTitle(tr("GEOM_FACE_FFW")); GroupPoints->GroupBox1->setTitle(tr("GEOM_FACE_FFW"));
GroupPoints->TextLabel1->setText(tr("GEOM_WIRE")); GroupPoints->TextLabel1->setText(tr("GEOM_WIRES"));
GroupPoints->CheckButton1->setText(tr("GEOM_FACE_OPT")); GroupPoints->CheckButton1->setText(tr("GEOM_FACE_OPT"));
GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton1->setPixmap(image1);
@ -85,7 +85,7 @@ void BuildGUI_FaceDlg::Init()
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->CheckButton1->setChecked(TRUE); GroupPoints->CheckButton1->setChecked(TRUE);
myOkShape = false; myOkListShapes = false;
myWireFilter = new GEOM_ShapeTypeFilter(TopAbs_WIRE, myGeom); myWireFilter = new GEOM_ShapeTypeFilter(TopAbs_WIRE, myGeom);
mySelection->AddFilter(myWireFilter); /* first filter used */ mySelection->AddFilter(myWireFilter); /* first filter used */
@ -124,8 +124,8 @@ void BuildGUI_FaceDlg::ClickOnOk()
void BuildGUI_FaceDlg::ClickOnApply() void BuildGUI_FaceDlg::ClickOnApply()
{ {
QAD_Application::getDesktop()->putInfo(tr("")); QAD_Application::getDesktop()->putInfo(tr(""));
if(myOkShape) if(myOkListShapes)
myBuildGUI->MakeFaceAndDisplay(myGeomShape, GroupPoints->CheckButton1->isChecked()); myBuildGUI->MakeFaceAndDisplay(myListShapes, GroupPoints->CheckButton1->isChecked());
return; return;
} }
@ -139,24 +139,17 @@ void BuildGUI_FaceDlg::SelectionIntoArgument()
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
QString aString = ""; /* name of selection */ QString aString = ""; /* name of selection */
myOkShape = false; myOkListShapes = false;
int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
if(nbSel != 1) { if(nbSel == 0)
return; return;
} if(nbSel != 1)
aString = tr("%1_objects").arg(nbSel);
myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes);
// nbSel == 1!
Standard_Boolean testResult;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
if(!myGeomBase->GetTopoFromSelection(mySelection, myShape))
return;
myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult);
if(!testResult)
return;
myEditCurrentArgument->setText(aString); myEditCurrentArgument->setText(aString);
myOkShape = true; myOkListShapes = true;
/* no simulation */ /* no simulation */
return; return;
} }
@ -176,23 +169,6 @@ void BuildGUI_FaceDlg::SetEditCurrentArgument()
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BuildGUI_FaceDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if(send == GroupPoints->LineEdit1)
myEditCurrentArgument = GroupPoints->LineEdit1;
else
return;
GEOMBase_Skeleton::LineEditReturnPressed();
return;
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :

View File

@ -57,9 +57,8 @@ private:
/* Filter selection */ /* Filter selection */
Handle(GEOM_ShapeTypeFilter) myWireFilter; Handle(GEOM_ShapeTypeFilter) myWireFilter;
TopoDS_Shape myShape; /* topology used to fuse */ GEOM::GEOM_Gen::ListOfIOR myListShapes;
GEOM::GEOM_Shape_var myGeomShape; /* is myShape */ bool myOkListShapes; /* to check when arguments is defined */
bool myOkShape; /* to check when arguments is defined */
DlgRef_1Sel1Check_QTD* GroupPoints; DlgRef_1Sel1Check_QTD* GroupPoints;
@ -67,7 +66,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
void ClickOnApply(); void ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();

View File

@ -63,6 +63,7 @@ using namespace std;
#else #else
#include <BRepAlgoAPI.hxx> #include <BRepAlgoAPI.hxx>
#endif #endif
#include <BRepAlgo_FaceRestrictor.hxx>
#include <BRepAdaptor_Surface.hxx> #include <BRepAdaptor_Surface.hxx>
#include <BRepBuilderAPI_Copy.hxx> #include <BRepBuilderAPI_Copy.hxx>
#include <BRepAlgoAPI_Common.hxx> #include <BRepAlgoAPI_Common.hxx>
@ -3684,6 +3685,69 @@ GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFace( GEOM::GEOM_Shape_ptr wire,
} }
//=================================================================================
// function : MakeFaces()
// purpose :
//=================================================================================
GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFaces(const GEOM::GEOM_Gen::ListOfIOR& ListShapes,
CORBA::Boolean wantplanarface)
throw (SALOME::SALOME_Exception)
{
GEOM::GEOM_Shape_var result;
try {
GEOM::GEOM_Shape_var aShape = GetIORFromString(ListShapes[0]);
TopoDS_Shape Shape = GetTopoShape(aShape);
if(Shape.IsNull() || Shape.ShapeType() != TopAbs_WIRE) {
THROW_SALOME_CORBA_EXCEPTION("Shell aborted : null shape during operation", SALOME::BAD_PARAM);
}
TopoDS_Wire W = TopoDS::Wire(Shape);
TopoDS_Shape FFace = BRepBuilderAPI_MakeFace(W, wantplanarface).Shape();
if(!FFace.IsNull()) {
if(ListShapes.length() == 1) {
result = CreateObject(FFace);
InsertInLabelMoreArguments(FFace, result, ListShapes, myCurrentOCAFDoc);
}
else if(ListShapes.length() >= 2) {
TopoDS_Compound C;
BRep_Builder aBuilder;
aBuilder.MakeCompound(C);
BRepAlgo_FaceRestrictor FR;
TopAbs_Orientation OriF = FFace.Orientation();
TopoDS_Shape aLocalS = FFace.Oriented(TopAbs_FORWARD);
FR.Init(TopoDS::Face(aLocalS), Standard_False, Standard_True);
for(unsigned int i = 0; i < ListShapes.length(); i++) {
GEOM::GEOM_Shape_var aShape = GetIORFromString(ListShapes[i]);
TopoDS_Shape Shape = GetTopoShape(aShape);
if(Shape.IsNull()) {
THROW_SALOME_CORBA_EXCEPTION("Shell aborted : null shape during operation", SALOME::BAD_PARAM);
}
FR.Add(TopoDS::Wire(Shape));
}
FR.Perform();
if(FR.IsDone()) {
for(; FR.More(); FR.Next())
aBuilder.Add(C, FR.Current().Oriented(OriF));
result = CreateObject(C);
InsertInLabelMoreArguments(C, result, ListShapes, myCurrentOCAFDoc);
}
}
}
else {
THROW_SALOME_CORBA_EXCEPTION("Null result in GEOM_Gen_i::MakeFace", SALOME::BAD_PARAM);
}
}
catch (Standard_Failure) {
THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeFace", SALOME::BAD_PARAM);
}
return result;
}
//================================================================================= //=================================================================================
// function : MakeShell() // function : MakeShell()
// purpose : Make a compound from a list containing one or more shapes // purpose : Make a compound from a list containing one or more shapes

View File

@ -586,6 +586,9 @@ class GEOM_Gen_i: public POA_GEOM::GEOM_Gen,
throw (SALOME::SALOME_Exception) ; throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeFace (GEOM::GEOM_Shape_ptr wire, CORBA::Boolean wantplanarface) GEOM::GEOM_Shape_ptr MakeFace (GEOM::GEOM_Shape_ptr wire, CORBA::Boolean wantplanarface)
throw (SALOME::SALOME_Exception) ; throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeFaces (const GEOM::GEOM_Gen::ListOfIOR& ListShapes,
CORBA::Boolean wantplanarface)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeShell (const GEOM::GEOM_Gen::ListOfIOR& ListShapes) GEOM::GEOM_Shape_ptr MakeShell (const GEOM::GEOM_Gen::ListOfIOR& ListShapes)
throw (SALOME::SALOME_Exception) ; throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeSolid (const GEOM::GEOM_Gen::ListOfIOR& ListShapes) GEOM::GEOM_Shape_ptr MakeSolid (const GEOM::GEOM_Gen::ListOfIOR& ListShapes)

View File

@ -662,6 +662,10 @@ msgstr "Vertex"
msgid "GEOM_WIRE" msgid "GEOM_WIRE"
msgstr "Wire" msgstr "Wire"
#Wire(s)
msgid "GEOM_WIRES"
msgstr "Wire(s)"
#Parameter #Parameter
msgid "GEOM_PARAMETER" msgid "GEOM_PARAMETER"
msgstr "Parameter :" msgstr "Parameter :"

View File

@ -635,6 +635,10 @@ msgstr "Vertex"
#Wire #Wire
msgid "GEOM_WIRE" msgid "GEOM_WIRE"
msgstr "Wire" msgstr "Wire"
#Wire(s)
msgid "GEOM_WIRES"
msgstr "Wire(s)"
#Parameter #Parameter
msgid "GEOM_PARAMETER" msgid "GEOM_PARAMETER"

View File

@ -152,6 +152,12 @@ def MakeCircle(p1,d1,radius):
anObj._set_Name(ior) anObj._set_Name(ior)
return anObj return anObj
def MakeEllipse(p1,d1,radiusMaj,radiusMin):
anObj = geom.MakeEllipse(p1,d1,radiusMaj, radiusMin)
ior = orb.object_to_string(anObj)
anObj._set_Name(ior)
return anObj
def MakePlane(p1,d1,trimsize): def MakePlane(p1,d1,trimsize):
anObj = geom.MakePlane(p1,d1,trimsize) anObj = geom.MakePlane(p1,d1,trimsize)
ior = orb.object_to_string(anObj) ior = orb.object_to_string(anObj)
@ -214,6 +220,12 @@ def MakeFace(aShapeWire,WantPlanarFace):
anObj._set_Name(ior) anObj._set_Name(ior)
return anObj return anObj
def MakeFaces(ListShape,WantPlanarFace):
anObj = geom.MakeFaces(ListShape,WantPlanarFace)
ior = orb.object_to_string(anObj)
anObj._set_Name(ior)
return anObj
def MakeCompound(ListShape): def MakeCompound(ListShape):
anObj = geom.MakeCompound(ListShape) anObj = geom.MakeCompound(ListShape)
ior = orb.object_to_string(anObj) ior = orb.object_to_string(anObj)
@ -356,10 +368,11 @@ def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
return anObj return anObj
def SuppressFaces(aShape,ListOfId): def SuppressFaces(aShape,ListOfId):
anObj = geom.SuppressFaces(aShape,ListOfId) ListObj = geom.SuppressFaces(aShape,ListOfId)
ior = orb.object_to_string(anObj) for anObj in ListObj :
anObj._set_Name(ior) ior = orb.object_to_string(anObj)
return anObj anObj._set_Name(ior)
return ListObj
def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace): def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace):
anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace) anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace)

View File

@ -178,6 +178,12 @@ def MakeCircle(p1,d1,radius):
anObj._set_Name(ior) anObj._set_Name(ior)
return anObj return anObj
def MakeEllipse(p1,d1,radiusMaj,radiusMin):
anObj = geom.MakeEllipse(p1,d1,radiusMaj, radiusMin)
ior = orb.object_to_string(anObj)
anObj._set_Name(ior)
return anObj
def MakePlane(p1,d1,trimsize): def MakePlane(p1,d1,trimsize):
anObj = geom.MakePlane(p1,d1,trimsize) anObj = geom.MakePlane(p1,d1,trimsize)
ior = salome.orb.object_to_string(anObj) ior = salome.orb.object_to_string(anObj)
@ -240,6 +246,12 @@ def MakeFace(aShapeWire,WantPlanarFace):
anObj._set_Name(ior) anObj._set_Name(ior)
return anObj return anObj
def MakeFaces(ListShape,WantPlanarFace):
anObj = geom.MakeFaces(ListShape,WantPlanarFace)
ior = salome.orb.object_to_string(anObj)
anObj._set_Name(ior)
return anObj
def MakeCompound(ListShape): def MakeCompound(ListShape):
anObj = geom.MakeCompound(ListShape) anObj = geom.MakeCompound(ListShape)
ior = salome.orb.object_to_string(anObj) ior = salome.orb.object_to_string(anObj)
@ -382,10 +394,11 @@ def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
return anObj return anObj
def SuppressFaces(aShape,ListOfId): def SuppressFaces(aShape,ListOfId):
anObj = geom.SuppressFaces(aShape,ListOfId) ListObj = geom.SuppressFaces(aShape,ListOfId)
ior = salome.orb.object_to_string(anObj) for anObj in ListObj :
anObj._set_Name(ior) ior = salome.orb.object_to_string(anObj)
return anObj anObj._set_Name(ior)
return ListObj
def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace): def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace):
anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace) anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace)