Implement MakeSurfaceFromFace (GUI only)

This commit is contained in:
skv 2014-10-28 13:19:15 +03:00
parent a2b342ad25
commit 5e18b23da7
17 changed files with 505 additions and 1 deletions

View File

@ -2573,6 +2573,17 @@ module GEOM
in double theVMin, in double theVMin,
in double theVMax); in double theVMax);
/*!
* \brief Make a surface from a face. This function takes some face as
* input parameter and create new GEOM_Object, i.e. topological shape
* by extracting underlying surface of the source face and limiting it
* by the Umin, Umax, Vmin, Vmax parameters of the source face (in the
* parametrical space).
* \param theFace the input face.
* \return a newly created face.
*/
GEOM_Object MakeSurfaceFromFace(in GEOM_Object theFace);
}; };
// # GEOM_IBlocksOperations: // # GEOM_IBlocksOperations:

View File

@ -94,6 +94,7 @@ SET( _res_files
eraseall.png eraseall.png
extruded_boss.png extruded_boss.png
extruded_cut.png extruded_cut.png
facetosurface.png
faceextension.png faceextension.png
face_hw.png face_hw.png
face_vechw.png face_vechw.png

BIN
resources/facetosurface.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

View File

@ -105,6 +105,7 @@ SET(EntityGUI_HEADERS
EntityGUI_SketcherDlg.h EntityGUI_SketcherDlg.h
EntityGUI_3DSketcherDlg.h EntityGUI_3DSketcherDlg.h
EntityGUI_IsolineDlg.h EntityGUI_IsolineDlg.h
EntityGUI_SurfFromFaceDlg.h
EntityGUI_SubShapeDlg.h EntityGUI_SubShapeDlg.h
EntityGUI_FeatureDetectorDlg.h EntityGUI_FeatureDetectorDlg.h
EntityGUI_PictureImportDlg.h EntityGUI_PictureImportDlg.h
@ -117,6 +118,7 @@ SET(_moc_HEADERS
EntityGUI_SketcherDlg.h EntityGUI_SketcherDlg.h
EntityGUI_3DSketcherDlg.h EntityGUI_3DSketcherDlg.h
EntityGUI_IsolineDlg.h EntityGUI_IsolineDlg.h
EntityGUI_SurfFromFaceDlg.h
EntityGUI_SubShapeDlg.h EntityGUI_SubShapeDlg.h
EntityGUI_PictureImportDlg.h EntityGUI_PictureImportDlg.h
${FeatureDetectorDlg_moc_h} ${FeatureDetectorDlg_moc_h}
@ -137,6 +139,7 @@ SET(EntityGUI_SOURCES
EntityGUI_SketcherDlg.cxx EntityGUI_SketcherDlg.cxx
EntityGUI_3DSketcherDlg.cxx EntityGUI_3DSketcherDlg.cxx
EntityGUI_IsolineDlg.cxx EntityGUI_IsolineDlg.cxx
EntityGUI_SurfFromFaceDlg.cxx
EntityGUI_SubShapeDlg.cxx EntityGUI_SubShapeDlg.cxx
EntityGUI_PictureImportDlg.cxx EntityGUI_PictureImportDlg.cxx
${FeatureDetectorDlg_Sources} ${FeatureDetectorDlg_Sources}

View File

@ -55,6 +55,7 @@
#include "EntityGUI_SketcherDlg.h" // Sketcher #include "EntityGUI_SketcherDlg.h" // Sketcher
#include "EntityGUI_3DSketcherDlg.h" // Sketcher #include "EntityGUI_3DSketcherDlg.h" // Sketcher
#include "EntityGUI_IsolineDlg.h" // Isoline #include "EntityGUI_IsolineDlg.h" // Isoline
#include "EntityGUI_SurfFromFaceDlg.h" // Surface From Face
#include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE #include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE
#include "EntityGUI_FeatureDetectorDlg.h" // Feature Detection #include "EntityGUI_FeatureDetectorDlg.h" // Feature Detection
#include "EntityGUI_PictureImportDlg.h" // Import Picture in viewer #include "EntityGUI_PictureImportDlg.h" // Import Picture in viewer
@ -105,6 +106,9 @@ bool EntityGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
case GEOMOp::OpIsoline: // ISOLINE case GEOMOp::OpIsoline: // ISOLINE
aDlg = new EntityGUI_IsolineDlg( getGeometryGUI(), parent ); aDlg = new EntityGUI_IsolineDlg( getGeometryGUI(), parent );
break; break;
case GEOMOp::OpSurfaceFromFace: // SURFACE FROM FACE
aDlg = new EntityGUI_SurfFromFaceDlg( getGeometryGUI(), parent );
break;
case GEOMOp::OpExplode: // EXPLODE case GEOMOp::OpExplode: // EXPLODE
aDlg = new EntityGUI_SubShapeDlg( getGeometryGUI(), parent ); aDlg = new EntityGUI_SubShapeDlg( getGeometryGUI(), parent );
break; break;

View File

@ -0,0 +1,225 @@
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component
// File : EntityGUI_SurfFromFaceDlg.cxx
#include "EntityGUI_SurfFromFaceDlg.h"
#include <GeometryGUI.h>
#include <DlgRef.h>
#include <GEOMBase.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
//=================================================================================
// class : EntityGUI_SurfFromFaceDlg
// purpose :
//=================================================================================
EntityGUI_SurfFromFaceDlg::EntityGUI_SurfFromFaceDlg
(GeometryGUI *theGeometryGUI,
QWidget *parent,
bool modal,
Qt::WindowFlags fl)
: GEOMBase_Skeleton (theGeometryGUI, parent, modal, fl),
myGroup (0)
{
QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SURFACE_FROM_FACE")));
QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle(tr("GEOM_SURF_FROM_FACE_TITLE"));
/***************************************************************/
mainFrame()->GroupConstructors->setTitle(tr("GEOM_SURF_FROM_FACE"));
mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->close();
// Construct a group.
myGroup = new DlgRef_1Sel(centralWidget());
myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
myGroup->TextLabel1->setText(tr("GEOM_FACE"));
myGroup->PushButton1->setIcon(image1);
myGroup->LineEdit1->setReadOnly(true);
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(myGroup);
setHelpFileName("create_surface_from_face_page.html");
Init();
}
//=================================================================================
// function : ~EntityGUI_SurfFromFaceDlg()
// purpose :
//=================================================================================
EntityGUI_SurfFromFaceDlg::~EntityGUI_SurfFromFaceDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void EntityGUI_SurfFromFaceDlg::Init()
{
initName(tr("GEOM_SURF_FROM_FACE_NAME"));
showOnlyPreviewControl();
/* signals and slots connections */
connect(myGroup->PushButton1, SIGNAL(clicked()),
this, SLOT(SetEditCurrentArgument()));
connect(myGeomGUI->getApp()->selectionMgr(),
SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()),
this, SLOT(DeactivateActiveDialog()));
connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()),
this, SLOT(ClickOnCancel()));
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
myEditCurrentArgument = myGroup->LineEdit1;
myGroup->LineEdit1->setReadOnly(true);
SelectionIntoArgument();
}
//=================================================================================
// function : SelectionIntoArgument
// purpose : Called when selection is changed
//=================================================================================
void EntityGUI_SurfFromFaceDlg::SelectionIntoArgument()
{
erasePreview();
myEditCurrentArgument->setText("");
myFace.nullify();
GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_FACE);
if (aSelectedObject) {
myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject.get()));
myFace = aSelectedObject;
}
processPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void EntityGUI_SurfFromFaceDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
if (send == myGroup->PushButton1) {
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
}
}
//=================================================================================
// function : ActivateThisDialog
// purpose :
//=================================================================================
void EntityGUI_SurfFromFaceDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect(myGeomGUI->getApp()->selectionMgr(),
SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
SelectionIntoArgument();
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void EntityGUI_SurfFromFaceDlg::enterEvent (QEvent*)
{
if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr EntityGUI_SurfFromFaceDlg::createOperation()
{
return myGeomGUI->GetGeomGen()->GetIShapesOperations(getStudyId());
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool EntityGUI_SurfFromFaceDlg::isValid (QString& msg)
{
return myFace;
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
bool EntityGUI_SurfFromFaceDlg::execute (ObjectList& objects)
{
GEOM::GEOM_IShapesOperations_var anOper =
GEOM::GEOM_IShapesOperations::_narrow(getOperation());
GEOM::GEOM_Object_var anObj = anOper->MakeSurfaceFromFace(myFace.get());
if (!anObj->_is_nil()) {
objects.push_back(anObj._retn());
}
return true;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void EntityGUI_SurfFromFaceDlg::ClickOnOk()
{
setIsApplyAndClose(true);
if (ClickOnApply())
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool EntityGUI_SurfFromFaceDlg::ClickOnApply()
{
if (!onAccept())
return false;
initName();
return true;
}

View File

@ -0,0 +1,75 @@
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component
// File : EntityGUI_SurfFromFaceDlg.h
#ifndef ENTITYGUI_SURFFROMFACEDLG_H
#define ENTITYGUI_SURFFROMFACEDLG_H
#include <GEOMBase_Skeleton.h>
class DlgRef_1Sel;
//=================================================================================
// class : EntityGUI_SurfFromFaceDlg
// purpose :
//=================================================================================
class EntityGUI_SurfFromFaceDlg : public GEOMBase_Skeleton
{
Q_OBJECT
public:
EntityGUI_SurfFromFaceDlg (GeometryGUI *theGeometryGUI,
QWidget *parent = 0,
bool modal = false,
Qt::WindowFlags fl = 0);
~EntityGUI_SurfFromFaceDlg();
protected:
// redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& );
private:
void Init();
void enterEvent( QEvent* );
private:
DlgRef_1Sel *myGroup;
GEOM::GeomObjPtr myFace;
private slots:
void ClickOnOk();
bool ClickOnApply();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ActivateThisDialog();
};
#endif // ENTITYGUI_SURFFROMFACEDLG_H

View File

@ -819,6 +819,10 @@
<source>ICON_VERTEX_MARKER_13</source> <source>ICON_VERTEX_MARKER_13</source>
<translation>marker_13.png</translation> <translation>marker_13.png</translation>
</message> </message>
<message>
<source>ICON_SURFACE_FROM_FACE</source>
<translation>facetosurface.png</translation>
</message>
<message> <message>
<source>ICO_ARC</source> <source>ICO_ARC</source>
<translation>arc.png</translation> <translation>arc.png</translation>
@ -1251,6 +1255,10 @@
<source>ICO_ISOLINE_V</source> <source>ICO_ISOLINE_V</source>
<translation>isoline_v.png</translation> <translation>isoline_v.png</translation>
</message> </message>
<message>
<source>ICO_SURFACE_FROM_FACE</source>
<translation>facetosurface.png</translation>
</message>
<message> <message>
<source>ICO_SOLID</source> <source>ICO_SOLID</source>
<translation>build_solid.png</translation> <translation>build_solid.png</translation>

View File

@ -2996,6 +2996,10 @@ Please, select face, shell or solid and try again</translation>
<source>MEN_ISOLINE</source> <source>MEN_ISOLINE</source>
<translation>Isoline</translation> <translation>Isoline</translation>
</message> </message>
<message>
<source>MEN_SURFACE_FROM_FACE</source>
<translation>Surface From Face</translation>
</message>
<message> <message>
<source>MEN_SOLID</source> <source>MEN_SOLID</source>
<translation>Solid</translation> <translation>Solid</translation>
@ -3880,6 +3884,10 @@ Please, select face, shell or solid and try again</translation>
<source>STB_ISOLINE</source> <source>STB_ISOLINE</source>
<translation>Create U- or V-Isoline</translation> <translation>Create U- or V-Isoline</translation>
</message> </message>
<message>
<source>STB_SURFACE_FROM_FACE</source>
<translation>Create a Surface From Face</translation>
</message>
<message> <message>
<source>STB_SOLID</source> <source>STB_SOLID</source>
<translation>Build a solid</translation> <translation>Build a solid</translation>
@ -4444,6 +4452,10 @@ Please, select face, shell or solid and try again</translation>
<source>TOP_ISOLINE</source> <source>TOP_ISOLINE</source>
<translation>Isoline</translation> <translation>Isoline</translation>
</message> </message>
<message>
<source>TOP_SURFACE_FROM_FACE</source>
<translation>Surface From Face</translation>
</message>
<message> <message>
<source>TOP_SOLID</source> <source>TOP_SOLID</source>
<translation>Build solid</translation> <translation>Build solid</translation>
@ -7093,4 +7105,19 @@ Do you want to create new material?</translation>
<translation>ExtendedFace</translation> <translation>ExtendedFace</translation>
</message> </message>
</context> </context>
<context>
<name>EntityGUI_SurfFromFaceDlg</name>
<message>
<source>GEOM_SURF_FROM_FACE_TITLE</source>
<translation>Surface From Face Construction</translation>
</message>
<message>
<source>GEOM_SURF_FROM_FACE</source>
<translation>Surface From Face</translation>
</message>
<message>
<source>GEOM_SURF_FROM_FACE_NAME</source>
<translation>SurfaceFromFace</translation>
</message>
</context>
</TS> </TS>

View File

@ -554,6 +554,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
case GEOMOp::OpIsoline: // MENU BASIC - ISOLINE case GEOMOp::OpIsoline: // MENU BASIC - ISOLINE
case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
case GEOMOp::OpSurfaceFromFace: // MENU ENTITY - SURFACE FROM FACE
#ifdef WITH_OPENCV #ifdef WITH_OPENCV
case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
#endif #endif
@ -905,6 +906,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpPlane, "PLANE" ); createGeomAction( GEOMOp::OpPlane, "PLANE" );
createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" ); createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" ); createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
createGeomAction( GEOMOp::OpSurfaceFromFace, "SURFACE_FROM_FACE" );
createGeomAction( GEOMOp::OpBox, "BOX" ); createGeomAction( GEOMOp::OpBox, "BOX" );
createGeomAction( GEOMOp::OpCylinder, "CYLINDER" ); createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
@ -936,7 +938,6 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" ); createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" ); createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
createGeomAction( GEOMOp::OpIsoline, "ISOLINE" );
createGeomAction( GEOMOp::OpExplode, "EXPLODE" ); createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
#ifdef WITH_OPENCV #ifdef WITH_OPENCV
createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" ); createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
@ -1117,6 +1118,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createMenu( GEOMOp::Op2dSketcher, basicId, -1 ); createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
createMenu( GEOMOp::Op3dSketcher, basicId, -1 ); createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
createMenu( GEOMOp::OpIsoline, basicId, -1 ); createMenu( GEOMOp::OpIsoline, basicId, -1 );
createMenu( GEOMOp::OpSurfaceFromFace, basicId, -1 );
createMenu( separator(), basicId, -1 ); createMenu( separator(), basicId, -1 );
createMenu( GEOMOp::OpVector, basicId, -1 ); createMenu( GEOMOp::OpVector, basicId, -1 );
createMenu( GEOMOp::OpPlane, basicId, -1 ); createMenu( GEOMOp::OpPlane, basicId, -1 );
@ -1332,6 +1334,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
createTool( GEOMOp::OpIsoline, basicTbId ); createTool( GEOMOp::OpIsoline, basicTbId );
createTool( GEOMOp::OpSurfaceFromFace, basicTbId );
createTool( GEOMOp::OpPlane, basicTbId ); createTool( GEOMOp::OpPlane, basicTbId );
createTool( GEOMOp::OpLCS, basicTbId ); createTool( GEOMOp::OpLCS, basicTbId );
createTool( GEOMOp::OpOriginAndVectors, basicTbId ); createTool( GEOMOp::OpOriginAndVectors, basicTbId );

View File

@ -94,6 +94,7 @@ namespace GEOMOp {
OpLCS = 3008, // MENU NEW ENTITY - BASIC - LOCAL COORDINATE SYSTEM OpLCS = 3008, // MENU NEW ENTITY - BASIC - LOCAL COORDINATE SYSTEM
OpOriginAndVectors = 3009, // MENU NEW ENTITY - BASIC - ORIGIN AND BASE VECTORS OpOriginAndVectors = 3009, // MENU NEW ENTITY - BASIC - ORIGIN AND BASE VECTORS
OpIsoline = 3010, // MENU NEW ENTITY - BASIC - ISOLINE OpIsoline = 3010, // MENU NEW ENTITY - BASIC - ISOLINE
OpSurfaceFromFace = 3011, // MENU NEW ENTITY - BASIC - SURFACE FROM FACE
// PrimitiveGUI ----------------//-------------------------------- // PrimitiveGUI ----------------//--------------------------------
OpBox = 3100, // MENU NEW ENTITY - PRIMITIVES - BOX OpBox = 3100, // MENU NEW ENTITY - PRIMITIVES - BOX
OpCylinder = 3101, // MENU NEW ENTITY - PRIMITIVES - CYLINDER OpCylinder = 3101, // MENU NEW ENTITY - PRIMITIVES - CYLINDER

View File

@ -4968,3 +4968,64 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ExtendFace
return aResFace; return aResFace;
} }
//=======================================================================
//function : MakeSurfaceFromFace
//purpose :
//=======================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeSurfaceFromFace
(const Handle(GEOM_Object) &theFace)
{
SetErrorCode(KO);
if (theFace.IsNull()) {
return NULL;
}
//Add a new Face object
Handle(GEOM_Object) aResFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
//Add a new Vector function
Handle(GEOM_Function) aFunction =
aResFace->AddFunction(GEOMImpl_ShapeDriver::GetID(), SURFACE_FROM_FACE);
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) {
return NULL;
}
GEOMImpl_IShapeExtend aCI (aFunction);
Handle(GEOM_Function) aFace = theFace->GetLastFunction();
if (aFace.IsNull()) {
return NULL;
}
aCI.SetShape(aFace);
//Compute the Face value
try {
OCC_CATCH_SIGNALS;
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed");
return NULL;
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
//Make a Python command
GEOM::TPythonDump(aFunction)
<< aResFace << " = geompy.MakeSurfaceFromFace("
<< theFace << ")";
SetErrorCode(OK);
return aResFace;
}

View File

@ -396,6 +396,9 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations
const Standard_Real theVMin, const Standard_Real theVMin,
const Standard_Real theVMax); const Standard_Real theVMax);
Standard_EXPORT Handle(GEOM_Object)
MakeSurfaceFromFace(const Handle(GEOM_Object) &theFace);
private: private:
Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes, Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
const Standard_Integer theObjectType, const Standard_Integer theObjectType,

View File

@ -681,6 +681,47 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
aShape = ExtendFace(aFace, aSE.GetUMin(), aSE.GetUMax(), aShape = ExtendFace(aFace, aSE.GetUMin(), aSE.GetUMax(),
aSE.GetVMin(), aSE.GetVMax()); aSE.GetVMin(), aSE.GetVMax());
} }
} else if (aType == SURFACE_FROM_FACE) {
#ifdef RESULT_TYPE_CHECK
anExpectedType = TopAbs_FACE;
#endif
GEOMImpl_IShapeExtend aSE (aFunction);
Handle(GEOM_Function) aRefFace = aSE.GetShape();
TopoDS_Shape aShapeFace = aRefFace->GetValue();
if (aShapeFace.ShapeType() == TopAbs_FACE) {
TopoDS_Face aFace = TopoDS::Face(aShapeFace);
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
if (aSurface.IsNull() == Standard_False) {
Handle(Standard_Type) aType = aSurface->DynamicType();
Standard_Real aU1;
Standard_Real aU2;
Standard_Real aV1;
Standard_Real aV2;
// Get U, V bounds of the face.
aFace.Orientation(TopAbs_FORWARD);
ShapeAnalysis::GetFaceUVBounds(aFace, aU1, aU2, aV1, aV2);
// Get the surface of original type
while (aType == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
Handle(Geom_RectangularTrimmedSurface) aTrSurface =
Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
aSurface = aTrSurface->BasisSurface();
aType = aSurface->DynamicType();
}
const Standard_Real aTol = BRep_Tool::Tolerance(aFace);
BRepBuilderAPI_MakeFace aMF(aSurface, aU1, aU2, aV1, aV2, aTol);
if (aMF.IsDone()) {
aShape = aMF.Shape();
}
}
}
} }
else { else {
} }
@ -1573,6 +1614,14 @@ GetCreationInformation(std::string& theOperationName,
AddParam(theParams, "VMax", aSE.GetVMax()); AddParam(theParams, "VMax", aSE.GetVMax());
break; break;
} }
case SURFACE_FROM_FACE:
{
GEOMImpl_IShapeExtend aSE (function);
theOperationName = "SURFACE_FROM_FACE";
AddParam(theParams, "Face", aSE.GetShape());
break;
}
default: default:
return false; return false;
} }

View File

@ -302,6 +302,7 @@
#define FACE_FROM_SURFACE 15 #define FACE_FROM_SURFACE 15
#define EDGE_UV 16 #define EDGE_UV 16
#define FACE_UV 17 #define FACE_UV 17
#define SURFACE_FROM_FACE 18
#define ARCHIMEDE_TYPE 1 #define ARCHIMEDE_TYPE 1

View File

@ -2000,3 +2000,33 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendFace
return GetObject(aNewFace); return GetObject(aNewFace);
} }
//=============================================================================
/*!
* MakeSurfaceFromFace
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSurfaceFromFace
(GEOM::GEOM_Object_ptr theFace)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference object
Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
if (aFace.IsNull()) {
return aGEOMObject._retn();
}
//Get Shapes in place of aShapeWhat
Handle(GEOM_Object) aNewFace = GetOperations()->MakeSurfaceFromFace(aFace);
if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
return aGEOMObject._retn();
}
return GetObject(aNewFace);
}

View File

@ -284,6 +284,8 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i :
CORBA::Double theVMin, CORBA::Double theVMin,
CORBA::Double theVMax); CORBA::Double theVMax);
GEOM::GEOM_Object_ptr MakeSurfaceFromFace(GEOM::GEOM_Object_ptr theFace);
::GEOMImpl_IShapesOperations* GetOperations() ::GEOMImpl_IShapesOperations* GetOperations()
{ return (::GEOMImpl_IShapesOperations*)GetImpl(); } { return (::GEOMImpl_IShapesOperations*)GetImpl(); }
}; };