From: jfa Date: Fri, 28 Jul 2006 12:53:16 +0000 (+0000) Subject: PAL12781: EDF: different result between Working Plane and LCS. Implement and use... X-Git-Tag: For_OCT_611~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c3d31bd3dc09e5a149366ee324aa606619da2540;p=modules%2Fgeom.git PAL12781: EDF: different result between Working Plane and LCS. Implement and use general mechanism to obtain position from shape. --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 6f3652d8c..95391389b 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -339,7 +339,7 @@ module GEOM /*! * Create a plane, similar to the existing one, but with another size of representing face. - * \param theFace Referenced plane. + * \param theFace Referenced plane or LCS(Marker). * \param theTrimSize New half size of a side of quadrangle face, representing the plane. * \return New GEOM_Object, containing the created plane. */ @@ -616,15 +616,31 @@ module GEOM in double theFactor); /*! - * Modify the Location of the given object by LCS + * Modify the Location of the given object by LCS. + * \param theObject The object to be displaced. + * \param theStartLCS Coordinate system to perform displacement from it. + * If \a theStartLCS is NULL, displacement + * will be performed from global CS. + * If \a theObject itself is used as \a theStartLCS, + * its location will be changed to \a theEndLCS. + * \param theEndLCS Coordinate system to perform displacement to it. + * \return theObject. */ GEOM_Object PositionShape (in GEOM_Object theObject, in GEOM_Object theStartLCS, in GEOM_Object theEndLCS); /*! - * Modify the Location of the given object by LCS - * creating its copy before the setting + * Modify the Location of the given object by LCS, + * creating its copy before the setting. + * \param theObject The object to be displaced. + * \param theStartLCS Coordinate system to perform displacement from it. + * If \a theStartLCS is NULL, displacement + * will be performed from global CS. + * If \a theObject itself is used as \a theStartLCS, + * its location will be changed to \a theEndLCS. + * \param theEndLCS Coordinate system to perform displacement to it. + * \return New GEOM_Object, containing the displaced shape. */ GEOM_Object PositionShapeCopy (in GEOM_Object theObject, in GEOM_Object theStartLCS, @@ -1667,7 +1683,7 @@ module GEOM * For format of the description string see the previous method.\n * \param theCommand String, defining the sketcher in local * coordinates of the working plane. - * \param theWorkingPlane Planar Face of the working plane. + * \param theWorkingPlane Planar Face or LCS(Marker) of the working plane. * \return New GEOM_Object, containing the created wire. */ GEOM_Object MakeSketcherOnPlane (in string theCommand, in GEOM_Object theWorkingPlane); @@ -1961,6 +1977,22 @@ module GEOM */ interface GEOM_IMeasureOperations : GEOM_IOperations { + /*! + * Get position (LCS) of theShape. + * \param theShape Shape to calculate position of. + * \param Ox,Oy,Oz Output. Coordinates of shape's location origin. + * Origin of the LCS is situated at the shape's center of mass. + * \param Zx,Zy,Zz Output. Coordinates of shape's location normal(main) direction. + * \param Xx,Xy,Xz Output. Coordinates of shape's location X direction. + * Axes of the LCS are obtained from shape's location or, + * if the shape is a planar face, from position of its plane. + * \return Returns position of the shape through the last nine arguments. + */ + void GetPosition (in GEOM_Object theShape, + out double Ox, out double Oy, out double Oz, + out double Zx, out double Zy, out double Zz, + out double Xx, out double Xy, out double Xz); + /*! * Get summarized length of all wires, * area of surface and volume of the given shape. diff --git a/src/BasicGUI/BasicGUI_MarkerDlg.cxx b/src/BasicGUI/BasicGUI_MarkerDlg.cxx index d3efb5076..99e7ff9a5 100644 --- a/src/BasicGUI/BasicGUI_MarkerDlg.cxx +++ b/src/BasicGUI/BasicGUI_MarkerDlg.cxx @@ -1,23 +1,23 @@ // GEOM GEOMGUI : GUI for Geometry component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// 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 +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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 // // // @@ -37,21 +37,21 @@ #include #include "GEOMImpl_Types.hxx" + #include "utilities.h" +// OCCT Includes +#include #include #include #include #include #include -#include +#include #include -#include +#include #include #include -#include -#include -#include //================================================================================= // class : BasicGUI_MarkerDlg() @@ -114,13 +114,13 @@ BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* th myData[ DY2 ] = new DlgRef_SpinBox( anYAxisGrp ); new QLabel( tr( "DZ" ), anYAxisGrp ); myData[ DZ2 ] = new DlgRef_SpinBox( anYAxisGrp ); - + Layout1->addWidget( aMainGrp, 2, 0 ); Layout1->addWidget( Group1, 2, 0 ); Layout1->addWidget( Group2, 2, 0 ); setHelpFileName("local_coordinate_system.htm"); - + Init(); } @@ -147,7 +147,7 @@ void BasicGUI_MarkerDlg::Init() Group2->LineEdit1->setReadOnly( true ); Group2->LineEdit2->setReadOnly( true ); Group2->LineEdit3->setReadOnly( true ); - + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); @@ -166,14 +166,14 @@ void BasicGUI_MarkerDlg::Init() connect( buttonOk, SIGNAL( clicked() ), this, SLOT( onOk() ) ); connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) ); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); initName( tr( "LCS_NAME" ) ); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); - + for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) { anIter.data()->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, 3 ); @@ -267,7 +267,7 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId ) } } - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone())); onSelectionDone(); } @@ -302,7 +302,7 @@ bool BasicGUI_MarkerDlg::onApply() initName(); ConstructorsClicked( getConstructorId() ); - + return true; } @@ -314,16 +314,18 @@ void BasicGUI_MarkerDlg::onSelectionDone0() { if ( IObjectCount() == 1 ) { - Standard_Boolean aRes = Standard_False; Handle(SALOME_InteractiveObject) anIO = firstIObject(); GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + if ( aRes && !aSelectedObj->_is_nil() ) { TopoDS_Shape aShape; if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + // Existing LCS selected if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) { TopoDS_Face aFace = TopoDS::Face( aShape ); @@ -347,22 +349,21 @@ void BasicGUI_MarkerDlg::onSelectionDone0() myData[ DX2 ]->SetValue( aYDir.X() ); myData[ DY2 ]->SetValue( aYDir.Y() ); myData[ DZ2 ]->SetValue( aYDir.Z() ); - ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected(); + aSelMgr->clearSelected(); } } else { TColStd_IndexedMapOfInteger aMap; - ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap ); + aSelMgr->GetIndexes( anIO, aMap ); if ( aMap.Extent() == 1 ) { int anIndex = aMap( 1 ); TopTools_IndexedMapOfShape aShapes; TopExp::MapShapes( aShape, aShapes ); aShape = aShapes.FindKey( anIndex ); - ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected(); + aSelMgr->clearSelected(); } - if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) { @@ -386,12 +387,10 @@ void BasicGUI_MarkerDlg::onSelectionDone0() //================================================================================= void BasicGUI_MarkerDlg::onSelectionDone() { - if ( getConstructorId() == 0 ) - { + if ( getConstructorId() == 0 ) { onSelectionDone0(); return; } - myEditCurrentArgument->setText(""); QString aName; @@ -403,82 +402,60 @@ void BasicGUI_MarkerDlg::onSelectionDone() if ( !CORBA::is_nil( aSelectedObj ) && aRes ) { aName = GEOMBase::GetName( aSelectedObj ); - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) { - GEOM::short_array anIndexes; - - TColStd_IndexedMapOfInteger aMap; - ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap ); - - if ( !aMap.IsEmpty() ) { - int anIndex = aMap( 1 ); - TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); - } - if ( getConstructorId() == 1 ) { - if ( !aShape.IsNull() ) { - gp_Pnt aPnt; - if (aShape.ShapeType() == TopAbs_VERTEX) { - aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); - } - else { - GProp_GProps aSystem; - if (aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE) - BRepGProp::LinearProperties(aShape, aSystem); - else if (aShape.ShapeType() == TopAbs_FACE || aShape.ShapeType() == TopAbs_SHELL) - BRepGProp::SurfaceProperties(aShape, aSystem); - else - BRepGProp::VolumeProperties(aShape, aSystem); - - aPnt = aSystem.CentreOfMass(); - } - - gp_Ax3 anAx3; - anAx3.Transform(aShape.Location().Transformation()); - if(aShape.ShapeType() == TopAbs_FACE) { - Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShape ) ); - if (!aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) { - Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); - gp_Pln aPln = aGPlane->Pln(); - anAx3 = aPln.Position(); - } - } - - gp_Dir aDirX = anAx3.XDirection(); - gp_Dir aDirY = anAx3.YDirection(); - - myData[ X ]->SetValue( aPnt.X() ); - myData[ Y ]->SetValue( aPnt.Y() ); - myData[ Z ]->SetValue( aPnt.Z() ); - - myData[ DX1 ]->SetValue( aDirX.X() ); - myData[ DY1 ]->SetValue( aDirX.Y() ); - myData[ DZ1 ]->SetValue( aDirX.Z() ); - - myData[ DX2 ]->SetValue( aDirY.X() ); - myData[ DY2 ]->SetValue( aDirY.Y() ); - myData[ DZ2 ]->SetValue( aDirY.Z() ); - - myEditCurrentArgument->setText( aName ); - } - else { - myData[ X ]->SetValue( 0 ); - myData[ Y ]->SetValue( 0 ); - myData[ Z ]->SetValue( 0 ); - - myData[ DX1 ]->SetValue( 0 ); - myData[ DY1 ]->SetValue( 0 ); - myData[ DZ1 ]->SetValue( 0 ); - - myData[ DX2 ]->SetValue( 0 ); - myData[ DY2 ]->SetValue( 0 ); - myData[ DZ2 ]->SetValue( 0 ); - } - } - else if ( getConstructorId() == 2 ) { - if (myEditCurrentArgument == Group2->LineEdit1) { + if ( getConstructorId() == 1 ) { // by shape position + // Get shape's position + CORBA::Double Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz, Yx,Yy,Yz; + Ox = Oy = Oz = Zx = Zy = Xy = Xz = Yx = Yz = 0; + Zz = Xx = Yy = 1.; + + GEOM::GEOM_IMeasureOperations_ptr aMeasureOp = + myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId()); + aMeasureOp->GetPosition(aSelectedObj, Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz); + + // Calculate Y direction + if (aMeasureOp->IsDone()) { + gp_Pnt aPnt (Ox,Oy,Oz); + gp_Dir aDirN (Zx,Zy,Zz); + gp_Dir aDirX (Xx,Xy,Xz); + gp_Ax3 anAx3 (aPnt, aDirN, aDirX); + + gp_Dir aDirY = anAx3.YDirection(); + aDirY.Coord(Yx,Yy,Yz); + } + + // Set values + myData[ X ]->SetValue( Ox ); + myData[ Y ]->SetValue( Oy ); + myData[ Z ]->SetValue( Oz ); + + myData[ DX1 ]->SetValue( Xx ); + myData[ DY1 ]->SetValue( Xy ); + myData[ DZ1 ]->SetValue( Xz ); + + myData[ DX2 ]->SetValue( Yx ); + myData[ DY2 ]->SetValue( Yy ); + myData[ DZ2 ]->SetValue( Yz ); + + myEditCurrentArgument->setText( aName ); + } + else if ( getConstructorId() == 2 ) { // by point and two vectors + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) { + GEOM::short_array anIndexes; + + TColStd_IndexedMapOfInteger aMap; + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + aSelMgr->GetIndexes( anIO, aMap ); + + if ( !aMap.IsEmpty() ) { + int anIndex = aMap( 1 ); + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes( aShape, aShapes ); + aShape = aShapes.FindKey( anIndex ); + } + + if (myEditCurrentArgument == Group2->LineEdit1) { if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) { gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); myData[ X ]->SetValue( aPnt.X() ); @@ -497,7 +474,7 @@ void BasicGUI_MarkerDlg::onSelectionDone() gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape))); gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape))); gp_Dir aDir(gp_Vec(aP1, aP2)); - + myData[ DX1 ]->SetValue( aDir.X() ); myData[ DY1 ]->SetValue( aDir.Y() ); myData[ DZ1 ]->SetValue( aDir.Z() ); @@ -514,7 +491,7 @@ void BasicGUI_MarkerDlg::onSelectionDone() gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape))); gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape))); gp_Dir aDir(gp_Vec(aP1, aP2)); - + myData[ DX2 ]->SetValue( aDir.X() ); myData[ DY2 ]->SetValue( aDir.Y() ); myData[ DZ2 ]->SetValue( aDir.Z() ); @@ -535,11 +512,11 @@ void BasicGUI_MarkerDlg::onSelectionDone() myData[ X ]->SetValue( 0 ); myData[ Y ]->SetValue( 0 ); myData[ Z ]->SetValue( 0 ); - + myData[ DX1 ]->SetValue( 0 ); myData[ DY1 ]->SetValue( 0 ); myData[ DZ1 ]->SetValue( 0 ); - + myData[ DX2 ]->SetValue( 0 ); myData[ DY2 ]->SetValue( 0 ); myData[ DZ2 ]->SetValue( 0 ); @@ -560,9 +537,9 @@ void BasicGUI_MarkerDlg::onSelectionDone() myData[ DY2 ]->SetValue( 0 ); myData[ DZ2 ]->SetValue( 0 ); } - } + } } - + displayPreview(); } @@ -573,7 +550,7 @@ void BasicGUI_MarkerDlg::onSelectionDone() void BasicGUI_MarkerDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - + if(send == Group1->PushButton1) { myEditCurrentArgument = Group1->LineEdit1; globalSelection( GEOM_ALLGEOM ); @@ -590,7 +567,7 @@ void BasicGUI_MarkerDlg::SetEditCurrentArgument() myEditCurrentArgument = Group2->LineEdit3; globalSelection( GEOM_LINE ); } - + myEditCurrentArgument->setFocus(); onSelectionDone(); } @@ -614,7 +591,7 @@ void BasicGUI_MarkerDlg::LineEditReturnPressed() void BasicGUI_MarkerDlg::onActivate() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); ConstructorsClicked( getConstructorId() ); @@ -634,7 +611,7 @@ void BasicGUI_MarkerDlg::onDeactivate() // purpose : //================================================================================= void BasicGUI_MarkerDlg::enterEvent(QEvent* e) -{ +{ if ( !GroupConstructors->isEnabled() ) onActivate(); } @@ -674,8 +651,8 @@ bool BasicGUI_MarkerDlg::isValid( QString& msg ) case 1: return !Group1->LineEdit1->text().isEmpty() && isOk; case 2: - return !Group2->LineEdit1->text().isEmpty() && - !Group2->LineEdit2->text().isEmpty() && + return !Group2->LineEdit1->text().isEmpty() && + !Group2->LineEdit2->text().isEmpty() && !Group2->LineEdit3->text().isEmpty() && isOk; } return false; @@ -734,17 +711,3 @@ void BasicGUI_MarkerDlg::displayPreview ( const bool activate, } } } - - - - - - - - - - - - - - diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx index 42d4b17af..a48162902 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -1,22 +1,22 @@ // GEOM GEOMGUI : GUI for Geometry component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// 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 -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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 // // @@ -33,6 +33,8 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include + #include #include "GEOMImpl_Types.hxx" @@ -41,7 +43,7 @@ using namespace std; //================================================================================= // class : BasicGUI_PlaneDlg() -// purpose : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the +// purpose : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. @@ -89,20 +91,20 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(GeometryGUI* theGeometryGUI, QWidget* paren Group3Pnts->LineEdit3->setReadOnly( true ); GroupFace = new DlgRef_1Sel1Spin(this, "GroupFace"); - GroupFace->GroupBox1->setTitle(tr("GEOM_FACE")); + GroupFace->GroupBox1->setTitle(tr("GEOM_FACE_OR_LCS")); GroupFace->TextLabel1->setText(tr("GEOM_SELECTION")); GroupFace->TextLabel2->setText(tr("GEOM_PLANE_SIZE")); GroupFace->PushButton1->setPixmap(image3); GroupFace->LineEdit1->setReadOnly( true ); - + Layout1->addWidget(GroupPntDir, 2, 0); Layout1->addWidget(Group3Pnts, 2, 0); Layout1->addWidget(GroupFace, 2, 0); /***************************************************************/ setHelpFileName("plane.htm"); - + Init(); } @@ -112,7 +114,7 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(GeometryGUI* theGeometryGUI, QWidget* paren // purpose : Destroys the object and frees any allocated resources //================================================================================= BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg() -{ +{ } @@ -132,9 +134,9 @@ void BasicGUI_PlaneDlg::Init() /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); - + double aTrimSize = 2000.0; - + /* min, max, step and decimals for spin boxes */ GroupPntDir->SpinBox_DX->RangeStepAndValidator( 0.001, COORD_MAX, aStep, 3 ); GroupPntDir->SpinBox_DX->SetValue( aTrimSize ); @@ -196,7 +198,7 @@ void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId) switch ( constructorId ) { case 0: /* plane from a point and a direction (vector, edge...) */ - { + { Group3Pnts->hide(); GroupFace->hide(); resize(0, 0); @@ -225,7 +227,7 @@ void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId) /* for the first argument */ globalSelection( GEOM_POINT ); break; - } + } case 2: /* plane from a planar face selection */ { GroupPntDir->hide(); @@ -237,13 +239,17 @@ void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId) GroupFace->LineEdit1->setText(tr("")); /* for the first argument */ - globalSelection( GEOM_PLANE ); + //globalSelection( GEOM_PLANE ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_PLANE ); + aMap.Add( GEOM_MARKER ); + globalSelection( aMap ); break; } } myEditCurrentArgument->setFocus(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } @@ -289,8 +295,8 @@ void BasicGUI_PlaneDlg::ClickOnCancel() void BasicGUI_PlaneDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - - if ( IObjectCount() != 1 ) + + if ( IObjectCount() != 1 ) { if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); @@ -305,7 +311,7 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() Standard_Boolean aRes = Standard_False; GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); if ( !CORBA::is_nil( aSelectedObject ) && aRes ) - { + { myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = aSelectedObject; else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = aSelectedObject; @@ -325,7 +331,7 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() //================================================================================= void BasicGUI_PlaneDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); + QPushButton* send = (QPushButton*)sender(); if ( send == GroupPntDir->PushButton1 ) myEditCurrentArgument = GroupPntDir->LineEdit1; else if ( send == GroupPntDir->PushButton2 ) myEditCurrentArgument = GroupPntDir->LineEdit2; @@ -335,14 +341,19 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument() else if ( send == GroupFace->PushButton1 ) myEditCurrentArgument = GroupFace->LineEdit1; myEditCurrentArgument->setFocus(); - + if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) globalSelection( GEOM_LINE ); - else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) - globalSelection( GEOM_PLANE ); + else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) { + //globalSelection( GEOM_PLANE ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_PLANE ); + aMap.Add( GEOM_MARKER ); + globalSelection( aMap ); + } else - globalSelection( GEOM_POINT ); - + globalSelection( GEOM_POINT ); + SelectionIntoArgument(); } @@ -374,7 +385,7 @@ void BasicGUI_PlaneDlg::LineEditReturnPressed() void BasicGUI_PlaneDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); // myGeomGUI->SetState( 0 ); diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx index 5fc545257..4522f191d 100644 --- a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -34,24 +34,22 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" -#include -#include +// OCCT Includes +#include #include -#include #include #include #include -#include #include #include -#include -#include - -#include "GEOMImpl_Types.hxx" +#include +// QT Includes #include #include +#include "GEOMImpl_Types.hxx" + using namespace std; //================================================================================= @@ -158,7 +156,7 @@ void BasicGUI_WorkingPlaneDlg::Init() connect(Group3->GroupBox1, SIGNAL(clicked(int)), this, SLOT(GroupClicked(int))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_WPLANE" ) ); @@ -171,14 +169,19 @@ void BasicGUI_WorkingPlaneDlg::Init() //================================================================================= void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); - // myGeomGUI->SetState( 0 ); + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + + disconnect(aSelMgr, 0, this, 0); switch (constructorId) { case 0: { - globalSelection( GEOM_PLANE ); + //globalSelection( GEOM_PLANE ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_PLANE ); + aMap.Add( GEOM_MARKER ); + globalSelection( aMap ); Group2->hide(); Group3->hide(); @@ -189,8 +192,7 @@ void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) Group1->LineEdit1->setText(""); myFace = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(aSelMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } case 1: @@ -208,8 +210,7 @@ void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) myVectX = GEOM::GEOM_Object::_nil(); myVectZ = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(aSelMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } case 2: @@ -221,7 +222,7 @@ void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) Group3->RadioButton1->setChecked(true); aOriginType = 1; - break; + break; } } displayPreview(); @@ -256,87 +257,98 @@ bool BasicGUI_WorkingPlaneDlg::ClickOnApply() myGeomGUI->application()->putInfo(tr("")); const int id = getConstructorId(); - if (id == 0) { - if ( !CORBA::is_nil( myFace ) ) { - TopoDS_Face aPlaneShape; - if ( GEOMBase::GetShape( myFace, aPlaneShape, TopAbs_FACE ) ) { - Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aPlaneShape ) ); - if ( !aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) { - Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); - gp_Pln aPln = aGPlane->Pln(); - - myWPlane = aPln.Position(); - myGeomGUI->SetWorkingPlane(myWPlane); - myGeomGUI->ActiveWorkingPlane(); - return true; - } - } + if (id == 0) { // by planar face selection + if (CORBA::is_nil(myFace)) { + showError( "Face has to be selected" ); + return false; + } + + // PAL12781: set center of WPL to face's center of mass + // like it is done for LCS creation + CORBA::Double Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz; + Ox = Oy = Oz = Zx = Zy = Xy = Xz = 0.; + Zz = Xx = 1.; + + GEOM::GEOM_IMeasureOperations_ptr aMeasureOp = + myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId()); + aMeasureOp->GetPosition(myFace, Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz); + + if (aMeasureOp->IsDone()) { + gp_Pnt aPnt (Ox,Oy,Oz); + gp_Dir aDirN (Zx,Zy,Zz); + gp_Dir aDirX (Xx,Xy,Xz); + myWPlane = gp_Ax3(aPnt, aDirN, aDirX); + } else { + showError( "Wrong shape selected (has to be a planar face)" ); + return false; } - } else if (id == 1) { + + } else if (id == 1) { // by two vectors (Ox & Oz) if ( CORBA::is_nil( myVectX ) || CORBA::is_nil( myVectZ ) ) { showError( "Two vectors have to be selected" ); return false; } TopoDS_Edge aVectX, aVectZ; - TopoDS_Vertex V1, V2; + TopoDS_Vertex VX1, VX2, VZ1, VZ2; gp_Vec aVX, aVZ; - if (GEOMBase::GetShape( myVectX, aVectX, TopAbs_EDGE ) && - GEOMBase::GetShape( myVectZ, aVectZ, TopAbs_EDGE )) { - TopExp::Vertices(aVectZ, V1, V2, Standard_True); - if (!V1.IsNull() && !V2.IsNull()) - aVZ = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); - else { - showError( "Bad OZ vector" ); - return false; - } - - TopExp::Vertices(aVectX, V1, V2, Standard_True); - if (!V1.IsNull() && !V2.IsNull()) - aVX = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); - else { - showError( "Bad OX vector" ); - return false; - } - gp_Dir aDirZ = gp_Dir(aVZ.X(), aVZ.Y(), aVZ.Z()); - gp_Dir aDirX = gp_Dir(aVX.X(), aVX.Y(), aVX.Z()); - - if (aDirX.IsParallel(aDirZ, Precision::Confusion())) { - showError( "Parallel vectors selected" ); - return false; - } + if (!GEOMBase::GetShape( myVectX, aVectX, TopAbs_EDGE ) || + !GEOMBase::GetShape( myVectZ, aVectZ, TopAbs_EDGE )) { + showError( "Wrong shape selected (two vectors(edges) have to be selected)" ); + return false; + } - myWPlane = gp_Ax3(BRep_Tool::Pnt(V1), aDirZ, aDirX); + TopExp::Vertices(aVectX, VX1, VX2, Standard_True); + TopExp::Vertices(aVectZ, VZ1, VZ2, Standard_True); - myGeomGUI->SetWorkingPlane(myWPlane); - myGeomGUI->ActiveWorkingPlane(); - return true; + if (VX1.IsNull() || VX2.IsNull()) { + showError( "Bad OX vector" ); + return false; + } + if (VZ1.IsNull() || VZ2.IsNull()) { + showError( "Bad OZ vector" ); + return false; } - } else if (id == 2) { - gp_Pnt P1 = gp_Pnt(0., 0., 0.); - gp_Dir aDirZ, aDirX; - if (aOriginType == 1) { - aDirZ = gp_Dir(0., 0., 1.); - aDirX = gp_Dir(1., 0., 0.); + aVX = gp_Vec(BRep_Tool::Pnt(VX1), BRep_Tool::Pnt(VX2)); + aVZ = gp_Vec(BRep_Tool::Pnt(VZ1), BRep_Tool::Pnt(VZ2)); + + if (aVX.Magnitude() < Precision::Confusion()) { + showError( "Bad OX vector" ); + return false; } - else if (aOriginType == 2) { - aDirZ = gp_Dir(1., 0., 0.); - aDirX = gp_Dir(0., 1., 0.); + if (aVZ.Magnitude() < Precision::Confusion()) { + showError( "Bad OZ vector" ); + return false; } - else if (aOriginType == 0) { - aDirZ = gp_Dir(0., 1., 0.); - aDirX = gp_Dir(0., 0., 1.); + + gp_Dir aDirX = gp_Dir(aVX.X(), aVX.Y(), aVX.Z()); + gp_Dir aDirZ = gp_Dir(aVZ.X(), aVZ.Y(), aVZ.Z()); + + if (aDirX.IsParallel(aDirZ, Precision::Angular())) { + showError( "Parallel vectors selected" ); + return false; } - myWPlane = gp_Ax3(P1, aDirZ, aDirX); + myWPlane = gp_Ax3(BRep_Tool::Pnt(VX1), aDirZ, aDirX); - myGeomGUI->SetWorkingPlane(myWPlane); - myGeomGUI->ActiveWorkingPlane(); - return true; + } else if (id == 2) { // by selection from standard (OXY or OYZ, or OZX) + gp_Ax2 anAx2; + + if (aOriginType == 1) anAx2 = gp::XOY(); + else if (aOriginType == 2) anAx2 = gp::YOZ(); + else if (aOriginType == 0) anAx2 = gp::ZOX(); + + myWPlane = gp_Ax3(anAx2); + + } else { + return false; } - return false; + + myGeomGUI->SetWorkingPlane(myWPlane); + myGeomGUI->ActiveWorkingPlane(); + return true; } //================================================================================= @@ -425,7 +437,7 @@ void BasicGUI_WorkingPlaneDlg::LineEditReturnPressed() void BasicGUI_WorkingPlaneDlg::ActivateThisDialog( ) { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); ConstructorsClicked( getConstructorId() ); diff --git a/src/GEOM/GEOM_PythonDump.cxx b/src/GEOM/GEOM_PythonDump.cxx index d11673b2e..a3ff987bd 100644 --- a/src/GEOM/GEOM_PythonDump.cxx +++ b/src/GEOM/GEOM_PythonDump.cxx @@ -104,9 +104,13 @@ namespace GEOM TPythonDump& TPythonDump::operator<< (const Handle(GEOM_Object)& theObject) { - TCollection_AsciiString anEntry; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - myStream << anEntry.ToCString(); + if (theObject.IsNull()) { + myStream << "None"; + } else { + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + myStream << anEntry.ToCString(); + } return *this; } diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index 7d2afa1a6..b94d530eb 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -651,6 +651,10 @@ msgstr "Face" msgid "GEOM_FACES" msgstr "Faces" +#Face or LCS +msgid "GEOM_FACE_OR_LCS" +msgstr "Face or LCS" + #Line msgid "GEOM_LINE" msgstr "Line" @@ -1229,7 +1233,7 @@ msgstr "Working Plane Selection" #: GeometryGUI_WorkingPlaneDlg.cxx:107 msgid "GEOM_WPLANE_FACE" -msgstr "Plane Or Planar Face" +msgstr "Plane Or Planar Face, Or LCS" #: GeometryGUI_WorkingPlaneDlg.cxx:107 msgid "GEOM_WPLANE_VECTOR" diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index cf41d11cc..90985be6d 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -1,18 +1,18 @@ // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // 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 +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// 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 +// +// 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 +// 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 @@ -32,6 +32,7 @@ #include #include +// OCCT Includes #include #include #include @@ -62,6 +63,10 @@ #include #include +#include +#include +#include + #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= @@ -86,6 +91,102 @@ GEOMImpl_IMeasureOperations::~GEOMImpl_IMeasureOperations() } +//============================================================================= +/*! Get LCS, corresponding to the given shape. + * Origin of the LCS is situated at the shape's center of mass. + * Axes of the LCS are obtained from shape's location or, + * if the shape is a planar face, from position of its plane. + */ +//============================================================================= +gp_Ax3 GEOMImpl_IMeasureOperations::GetPosition (const TopoDS_Shape& theShape) +{ + gp_Ax3 aResult; + + if (theShape.IsNull()) + return aResult; + + // Axes + aResult.Transform(theShape.Location().Transformation()); + if (theShape.ShapeType() == TopAbs_FACE) { + Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(theShape)); + if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { + Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS); + gp_Pln aPln = aGPlane->Pln(); + aResult = aPln.Position(); + } + } + + // Origin + gp_Pnt aPnt; + if (theShape.ShapeType() == TopAbs_VERTEX) { + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape)); + } + else { + GProp_GProps aSystem; + if (theShape.ShapeType() == TopAbs_EDGE || theShape.ShapeType() == TopAbs_WIRE) + BRepGProp::LinearProperties(theShape, aSystem); + else if (theShape.ShapeType() == TopAbs_FACE || theShape.ShapeType() == TopAbs_SHELL) + BRepGProp::SurfaceProperties(theShape, aSystem); + else + BRepGProp::VolumeProperties(theShape, aSystem); + + aPnt = aSystem.CentreOfMass(); + } + + aResult.SetLocation(aPnt); + + return aResult; +} + +//============================================================================= +/*! + * GetPosition + */ +//============================================================================= +void GEOMImpl_IMeasureOperations::GetPosition + (Handle(GEOM_Object) theShape, + Standard_Real& Ox, Standard_Real& Oy, Standard_Real& Oz, + Standard_Real& Zx, Standard_Real& Zy, Standard_Real& Zz, + Standard_Real& Xx, Standard_Real& Xy, Standard_Real& Xz) +{ + SetErrorCode(KO); + + //Set default values: global CS + Ox = Oy = Oz = Zx = Zy = Xy = Xz = 0.; + Zz = Xx = 1.; + + if (theShape.IsNull()) return; + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return; + + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) { + SetErrorCode("The Objects has NULL Shape"); + return; + } + + try { + gp_Ax3 anAx3 = GetPosition(aShape); + + gp_Pnt anOri = anAx3.Location(); + gp_Dir aDirZ = anAx3.Direction(); + gp_Dir aDirX = anAx3.XDirection(); + + // Output values + anOri.Coord(Ox, Oy, Oz); + aDirZ.Coord(Zx, Zy, Zz); + aDirX.Coord(Xx, Xy, Xz); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return; + } + + SetErrorCode(OK); +} + //============================================================================= /*! * GetCentreOfMass diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx index 2edf60025..4a0cc980b 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx @@ -24,9 +24,11 @@ #include "GEOM_IOperations.hxx" #include +#include #include #include #include +#include class GEOM_Engine; class Handle(GEOM_Object); @@ -36,6 +38,11 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { Standard_EXPORT GEOMImpl_IMeasureOperations(GEOM_Engine* theEngine, int theDocID); Standard_EXPORT ~GEOMImpl_IMeasureOperations(); + Standard_EXPORT void GetPosition (Handle(GEOM_Object) theShape, + Standard_Real& Ox, Standard_Real& Oy, Standard_Real& Oz, + Standard_Real& Zx, Standard_Real& Zy, Standard_Real& Zz, + Standard_Real& Xx, Standard_Real& Xy, Standard_Real& Xz); + Standard_EXPORT Handle(GEOM_Object) GetCentreOfMass (Handle(GEOM_Object) theShape); Standard_EXPORT void GetBasicProperties (Handle(GEOM_Object) theShape, @@ -73,6 +80,9 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { Standard_EXPORT void PointCoordinates(Handle(GEOM_Object) theShape, Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ ); + public: + Standard_EXPORT static gp_Ax3 GetPosition (const TopoDS_Shape& theShape); + private: void StructuralDump (const BRepCheck_Analyzer& theAna, const TopoDS_Shape& theShape, diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index 270d78ff7..edd39c7a2 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -1,18 +1,18 @@ // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // 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 +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// 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 +// +// 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 +// 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 @@ -1019,27 +1019,28 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape { SetErrorCode(KO); - if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL; + if (theObject.IsNull() || theEndLCS.IsNull()) return NULL; Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position - // Get last functions of the arguments - Handle(GEOM_Function) aStartLCS = theStartLCS->GetLastFunction(); - Handle(GEOM_Function) aEndLCS = theEndLCS->GetLastFunction(); - //Add a Position function + Standard_Integer aType = POSITION_SHAPE; + if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL; + Handle(GEOM_Function) aFunction = - theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE); + theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL; + //Set operation arguments GEOMImpl_IPosition aTI (aFunction); aTI.SetShape(anOriginal); - aTI.SetStartLCS(aStartLCS); - aTI.SetEndLCS(aEndLCS); + aTI.SetEndLCS(theEndLCS->GetLastFunction()); + if (!theStartLCS.IsNull()) + aTI.SetStartLCS(theStartLCS->GetLastFunction()); //Compute the Position try { @@ -1072,7 +1073,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy { SetErrorCode(KO); - if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL; + if (theObject.IsNull() || theEndLCS.IsNull()) return NULL; Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position @@ -1081,8 +1082,11 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); //Add a position function + Standard_Integer aType = POSITION_SHAPE_COPY; + if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY; + Handle(GEOM_Function) aFunction = - aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE_COPY); + aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly @@ -1090,8 +1094,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy GEOMImpl_IPosition aTI (aFunction); aTI.SetShape(anOriginal); - aTI.SetStartLCS(theStartLCS->GetLastFunction()); aTI.SetEndLCS(theEndLCS->GetLastFunction()); + if (!theStartLCS.IsNull()) + aTI.SetStartLCS(theStartLCS->GetLastFunction()); //Compute the position try { diff --git a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx index bd5ccdee1..1f3e28c77 100644 --- a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx @@ -1,18 +1,18 @@ // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // 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 +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// 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 +// +// 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 +// 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 @@ -25,6 +25,9 @@ #include #include +#include + +// OCCT Includes #include #include #include @@ -53,29 +56,29 @@ //======================================================================= //function : GetID //purpose : -//======================================================================= +//======================================================================= const Standard_GUID& GEOMImpl_PlaneDriver::GetID() { static Standard_GUID aPlaneDriver("FF1BBB05-5D14-4df2-980B-3A668264EA16"); - return aPlaneDriver; + return aPlaneDriver; } //======================================================================= //function : GEOMImpl_PlaneDriver -//purpose : +//purpose : //======================================================================= -GEOMImpl_PlaneDriver::GEOMImpl_PlaneDriver() +GEOMImpl_PlaneDriver::GEOMImpl_PlaneDriver() { } //======================================================================= //function : Execute //purpose : -//======================================================================= +//======================================================================= Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const { - if (Label().IsNull()) return 0; + if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); GEOMImpl_IPlane aPI (aFunction); @@ -124,13 +127,16 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const } else if (aType == PLANE_FACE) { Handle(GEOM_Function) aRef = aPI.GetFace(); TopoDS_Shape aRefShape = aRef->GetValue(); - if (aRefShape.ShapeType() != TopAbs_FACE) return 0; - Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aRefShape)); - if (!aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { - Standard_TypeMismatch::Raise("Plane creation aborted: non-planar face given as argument"); - } - aShape = BRepBuilderAPI_MakeFace(aGS, -aSize, +aSize, -aSize, +aSize).Shape(); - } + //if (aRefShape.ShapeType() != TopAbs_FACE) return 0; + //Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aRefShape)); + //if (!aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { + // Standard_TypeMismatch::Raise("Plane creation aborted: non-planar face given as argument"); + //} + //aShape = BRepBuilderAPI_MakeFace(aGS, -aSize, +aSize, -aSize, +aSize).Shape(); + gp_Ax3 anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aRefShape); + gp_Pln aPln (anAx3); + aShape = BRepBuilderAPI_MakeFace(aPln, -aSize, +aSize, -aSize, +aSize).Shape(); + } else if (aType == PLANE_TANGENT_FACE) { Handle(GEOM_Function) aRefFace = aPI.GetFace(); @@ -138,7 +144,7 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const if(aShape1.IsNull()) Standard_TypeMismatch::Raise("Plane was not created.Basis face was not specified"); TopoDS_Face aFace = TopoDS::Face(aShape1); - + Standard_Real aKoefU = aPI.GetParameterU(); Standard_Real aKoefV = aPI.GetParameterV(); Standard_Real aUmin,aUmax,aVmin,aVmax; @@ -154,7 +160,7 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const gp_Pnt aPLoc; aSurf->D1(aParamU,aParamV,aPLoc,aVecU,aVecV); BRepTopAdaptor_FClass2d clas(aFace,Precision::PConfusion()); - + TopAbs_State stOut= clas.PerformInfinitePoint(); gp_Pnt2d aP2d(aParamU,aParamV); TopAbs_State st= clas.Perform(aP2d); @@ -167,7 +173,6 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const if(aTool.IsDone()) aShape = aTool.Shape(); } - else { } @@ -175,7 +180,7 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const aFunction->SetValue(aShape); - log.SetTouched(Label()); + log.SetTouched(Label()); return 1; } @@ -184,17 +189,17 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const //======================================================================= //function : GEOMImpl_PlaneDriver_Type_ //purpose : -//======================================================================= +//======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_PlaneDriver_Type_() { static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PlaneDriver", @@ -209,7 +214,7 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_PlaneDriver_Type_() //======================================================================= //function : DownCast //purpose : -//======================================================================= +//======================================================================= const Handle(GEOMImpl_PlaneDriver) Handle(GEOMImpl_PlaneDriver)::DownCast (const Handle(Standard_Transient)& AnObject) { diff --git a/src/GEOMImpl/GEOMImpl_PositionDriver.cxx b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx index 8e0fb508f..789575c79 100644 --- a/src/GEOMImpl/GEOMImpl_PositionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx @@ -1,30 +1,33 @@ // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // 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 +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// 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 +// +// 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 +// 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 // -#include +//#include #include #include #include #include +#include + +// OCCT Includes #include #include #include @@ -43,29 +46,29 @@ //======================================================================= //function : GetID //purpose : -//======================================================================= +//======================================================================= const Standard_GUID& GEOMImpl_PositionDriver::GetID() { static Standard_GUID aPositionDriver("FF1BBB69-5D14-4df2-980B-3A668264EA16"); - return aPositionDriver; + return aPositionDriver; } //======================================================================= //function : GEOMImpl_PositionDriver -//purpose : +//purpose : //======================================================================= -GEOMImpl_PositionDriver::GEOMImpl_PositionDriver() +GEOMImpl_PositionDriver::GEOMImpl_PositionDriver() { } //======================================================================= //function : Execute //purpose : -//======================================================================= +//======================================================================= Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const { - if (Label().IsNull()) return 0; + if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); GEOMImpl_IPosition aCI (aFunction); @@ -82,58 +85,48 @@ Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const TopoDS_Shape aShapeStartLCS = aRefStartLCS->GetValue(); TopoDS_Shape aShapeEndLCS = aRefEndLCS->GetValue(); - if (aShapeBase.IsNull() || aShapeStartLCS.IsNull() || + if (aShapeBase.IsNull() || aShapeStartLCS.IsNull() || aShapeEndLCS.IsNull() || aShapeEndLCS.ShapeType() != TopAbs_FACE) return 0; gp_Trsf aTrsf; gp_Ax3 aStartAx3, aDestAx3; - aStartAx3.Transform(aShapeStartLCS.Location().Transformation()); - aDestAx3.Transform(aShapeEndLCS.Location().Transformation()); - - Handle(Geom_Surface) aGS2 = BRep_Tool::Surface( TopoDS::Face( aShapeEndLCS ) ); - if (!aGS2.IsNull() && aGS2->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) { - Handle(Geom_Plane) aGPlane2 = Handle(Geom_Plane)::DownCast( aGS2 ); - gp_Pln aPln2 = aGPlane2->Pln(); - aDestAx3 = aPln2.Position(); - } - - if(aShapeStartLCS.ShapeType() == TopAbs_FACE) { - Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShapeStartLCS ) ); - if (!aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) { - Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); - gp_Pln aPln = aGPlane->Pln(); - aStartAx3 = aPln.Position(); - } - aTrsf.SetDisplacement(aStartAx3, aDestAx3); - } - else { - gp_Trsf aTrsf1, aTrsf2; - aTrsf1.SetDisplacement(aStartAx3, aDestAx3); - BRepBuilderAPI_Transform aBT (aShapeBase, aTrsf1, Standard_False); - TopoDS_Shape aNewShape = aBT.Shape(); - - gp_Pnt aPnt; - if (aNewShape.ShapeType() == TopAbs_VERTEX) { - aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aNewShape)); - } - else { - GProp_GProps aSystem; - if (aNewShape.ShapeType() == TopAbs_EDGE || aNewShape.ShapeType() == TopAbs_WIRE) - BRepGProp::LinearProperties(aNewShape, aSystem); - else if (aNewShape.ShapeType() == TopAbs_FACE || aNewShape.ShapeType() == TopAbs_SHELL) - BRepGProp::SurfaceProperties(aNewShape, aSystem); - else - BRepGProp::VolumeProperties(aNewShape, aSystem); - - aPnt = aSystem.CentreOfMass(); - } - - gp_Vec aVec(aPnt, aDestAx3.Location()); - aTrsf2.SetTranslation(aVec); - aTrsf = aTrsf2 * aTrsf1; - } + // End LCS + aDestAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeEndLCS); + + // Start LCS + aStartAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeStartLCS); + + // Set transformation + aTrsf.SetDisplacement(aStartAx3, aDestAx3); + + // Perform transformation + BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False); + aShape = aBRepTrsf.Shape(); + } + else if (aType == POSITION_SHAPE_FROM_GLOBAL || + aType == POSITION_SHAPE_FROM_GLOBAL_COPY) { + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + Handle(GEOM_Function) aRefEndLCS = aCI.GetEndLCS(); + + TopoDS_Shape aShapeBase = aRefShape->GetValue(); + TopoDS_Shape aShapeEndLCS = aRefEndLCS->GetValue(); + + if (aShapeBase.IsNull() || aShapeEndLCS.IsNull() || + aShapeEndLCS.ShapeType() != TopAbs_FACE) + return 0; + + gp_Trsf aTrsf; + gp_Ax3 aStartAx3, aDestAx3; + + // End LCS + aDestAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeEndLCS); + + // Set transformation + aTrsf.SetDisplacement(aStartAx3, aDestAx3); + + // Perform transformation BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False); aShape = aBRepTrsf.Shape(); } @@ -144,26 +137,26 @@ Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const aFunction->SetValue(aShape); - log.SetTouched(Label()); + log.SetTouched(Label()); - return 1; + return 1; } //======================================================================= //function : GEOMImpl_PositionDriver_Type_ //purpose : -//======================================================================= +//======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_PositionDriver_Type_() { static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PositionDriver", @@ -178,7 +171,7 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_PositionDriver_Type_() //======================================================================= //function : DownCast //purpose : -//======================================================================= +//======================================================================= const Handle(GEOMImpl_PositionDriver) Handle(GEOMImpl_PositionDriver)::DownCast(const Handle(Standard_Transient)& AnObject) { Handle(GEOMImpl_PositionDriver) _anOtherObject; diff --git a/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx b/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx index b62081d4c..2a6eb0a7b 100644 --- a/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx @@ -25,6 +25,9 @@ #include #include +#include + +// OCCT Includes #include #include #include @@ -100,13 +103,14 @@ Standard_Integer GEOMImpl_SketcherDriver::Execute(TFunction_Logbook& log) const { Handle(GEOM_Function) aRefFace = aCI.GetWorkingPlane(); TopoDS_Shape aShape = aRefFace->GetValue(); - if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_FACE ) - return 0; - Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShape )); - if ( aGS.IsNull() || !aGS->IsKind( STANDARD_TYPE( Geom_Plane ))) - return 0; - Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); - aWPlane = aGPlane->Pln().Position(); + //if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_FACE ) + // return 0; + //Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShape )); + //if ( aGS.IsNull() || !aGS->IsKind( STANDARD_TYPE( Geom_Plane ))) + // return 0; + //Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); + //aWPlane = aGPlane->Pln().Position(); + aWPlane = GEOMImpl_IMeasureOperations::GetPosition(aShape); } gp_Trsf aTrans; aTrans.SetTransformation(aWPlane); diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index a1e340e29..cc0ebb563 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -135,6 +135,8 @@ #define POSITION_SHAPE 1 #define POSITION_SHAPE_COPY 2 +#define POSITION_SHAPE_FROM_GLOBAL 3 +#define POSITION_SHAPE_FROM_GLOBAL_COPY 4 #define TORUS_RR 1 #define TORUS_PNT_VEC_RR 2 diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc index 4e7112a22..9b763dfaf 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.cc +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -1,18 +1,18 @@ // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // 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 +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// 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 +// +// 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 +// 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 @@ -51,6 +51,36 @@ GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i() } +//============================================================================= +/*! + * GetPosition + */ +//============================================================================= +void GEOM_IMeasureOperations_i::GetPosition + (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& Ox, CORBA::Double& Oy, CORBA::Double& Oz, + CORBA::Double& Zx, CORBA::Double& Zy, CORBA::Double& Zz, + CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + //Set default values: global CS + Ox = Oy = Oz = Zx = Zy = Xy = Xz = 0.; + Zz = Xx = 1.; + + if (theShape == NULL) return; + + //Get the reference shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return; + + // Get shape parameters + GetOperations()->GetPosition(aShape, Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz); +} + //============================================================================= /*! * GetCentreOfMass @@ -201,7 +231,7 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape (GEOM::GEOM_Object_ptr theS //Set a not done flag GetOperations()->SetNotDone(); - if (theShape == NULL) + if (theShape == NULL) { theDescription = CORBA::string_dup("null"); return 0; @@ -234,7 +264,7 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry (GEOM::GEOM_Obj //Set a not done flag GetOperations()->SetNotDone(); - if (theShape == NULL) + if (theShape == NULL) { theDescription = CORBA::string_dup("null"); return 0; diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.hh b/src/GEOM_I/GEOM_IMeasureOperations_i.hh index be0eda22d..f14a62236 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.hh +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.hh @@ -39,6 +39,11 @@ class GEOM_IMeasureOperations_i : ::GEOMImpl_IMeasureOperations* theImpl); ~GEOM_IMeasureOperations_i(); + void GetPosition (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& Ox, CORBA::Double& Oy, CORBA::Double& Oz, + CORBA::Double& Zx, CORBA::Double& Zy, CORBA::Double& Zz, + CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz); + void GetBasicProperties (GEOM::GEOM_Object_ptr theShape, CORBA::Double& theLength, CORBA::Double& theSurfArea, diff --git a/src/GEOM_I/GEOM_ITransformOperations_i.cc b/src/GEOM_I/GEOM_ITransformOperations_i.cc index abc3b362c..e19197e80 100644 --- a/src/GEOM_I/GEOM_ITransformOperations_i.cc +++ b/src/GEOM_I/GEOM_ITransformOperations_i.cc @@ -1,18 +1,18 @@ // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // 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 +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// 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 +// +// 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 +// 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 @@ -63,7 +63,7 @@ GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i() /*! * TranslateTwoPoints */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr thePoint1, @@ -72,7 +72,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints //Set a not done flag GetOperations()->SetNotDone(); GEOM::GEOM_Object_var aGEOMObject; - + if (thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn(); //check if the object is a subshape @@ -108,7 +108,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints /*! * TranslateTwoPointsCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr thePoint1, @@ -149,12 +149,12 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy /*! * TranslateDXDYDZ */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject, +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ) { //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); GEOM::GEOM_Object_var aGEOMObject ; if (theObject == NULL) return aGEOMObject._retn(); @@ -183,7 +183,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ (GEOM::GEOM_O /*! * TranslateDXDYDZCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy (GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ) { @@ -210,18 +210,18 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy return GetObject(anObject); } - + //============================================================================= /*! * TranslateVector */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector) { //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); GEOM::GEOM_Object_var aGEOMObject; if (theObject == NULL || theVector == NULL) return aGEOMObject._retn(); @@ -243,18 +243,18 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry()); if (aVector.IsNull()) return aGEOMObject._retn(); - + //Perform the translation - GetOperations()->TranslateVector(anObject, aVector); + GetOperations()->TranslateVector(anObject, aVector); - return aGEOMObject._retn(); + return aGEOMObject._retn(); } - + //============================================================================= /*! * TranslateVectorCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector) @@ -262,7 +262,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); if (theObject == NULL || theVector == NULL) return aGEOMObject._retn(); @@ -275,13 +275,13 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry()); if (aVector.IsNull()) return aGEOMObject._retn(); - + //Perform the translation - Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector); + Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - return GetObject(anObject); + return GetObject(anObject); } @@ -289,13 +289,13 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy /*! * Rotate */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theAxis, CORBA::Double theAngle) { //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); GEOM::GEOM_Object_var aGEOMObject; if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn(); @@ -316,18 +316,18 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry()); if (anAxis.IsNull()) return aGEOMObject._retn(); - + //Perform the rotation - GetOperations()->Rotate(anObject, anAxis, theAngle); + GetOperations()->Rotate(anObject, anAxis, theAngle); - return aGEOMObject._retn(); + return aGEOMObject._retn(); } //============================================================================= /*! * RotateCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theAxis, CORBA::Double theAngle) @@ -335,7 +335,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn(); @@ -348,13 +348,13 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry()); if (anAxis.IsNull()) return aGEOMObject._retn(); - + //Perform the rotation - Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle); + Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - return GetObject(anObject); + return GetObject(anObject); } @@ -362,7 +362,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object /*! * MirrorPlane */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr thePlane) @@ -370,7 +370,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn(); @@ -391,16 +391,16 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane if (aPlane.IsNull()) return aGEOMObject._retn(); //Perform the mirror - GetOperations()->MirrorPlane(anObject, aPlane); + GetOperations()->MirrorPlane(anObject, aPlane); - return aGEOMObject._retn(); + return aGEOMObject._retn(); } - + //============================================================================= /*! * MirrorPlaneCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr thePlane) @@ -408,7 +408,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn(); @@ -421,20 +421,20 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy Handle(GEOM_Object) aPlane = GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry()); if (aPlane.IsNull()) return aGEOMObject._retn(); - + //Perform the mirror - Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane); + Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - return GetObject(anObject); + return GetObject(anObject); } //============================================================================= /*! * MirrorAxis */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theAxis) @@ -442,7 +442,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn(); @@ -463,16 +463,16 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis if (aAxis.IsNull()) return aGEOMObject._retn(); //Perform the mirror - GetOperations()->MirrorAxis(anObject, aAxis); + GetOperations()->MirrorAxis(anObject, aAxis); - return aGEOMObject._retn(); + return aGEOMObject._retn(); } - + //============================================================================= /*! * MirrorAxisCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theAxis) @@ -480,7 +480,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn(); @@ -493,20 +493,20 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy Handle(GEOM_Object) aAxis = GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry()); if (aAxis.IsNull()) return aGEOMObject._retn(); - + //Perform the mirror - Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis); + Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - return GetObject(anObject); + return GetObject(anObject); } //============================================================================= /*! * MirrorPoint */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr thePoint) @@ -514,7 +514,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn(); @@ -535,16 +535,16 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint if (aPoint.IsNull()) return aGEOMObject._retn(); //Perform the mirror - GetOperations()->MirrorPoint(anObject, aPoint); + GetOperations()->MirrorPoint(anObject, aPoint); - return aGEOMObject._retn(); + return aGEOMObject._retn(); } - + //============================================================================= /*! * MirrorPointCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr thePoint) @@ -552,7 +552,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn(); @@ -565,13 +565,13 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry()); if (aPoint.IsNull()) return aGEOMObject._retn(); - + //Perform the mirror - Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint); + Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - return GetObject(anObject); + return GetObject(anObject); } @@ -579,7 +579,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy /*! * OffsetShape */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape (GEOM::GEOM_Object_ptr theObject, CORBA::Double theOffset) @@ -613,7 +613,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape /*! * OffsetShapeCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy (GEOM::GEOM_Object_ptr theObject, CORBA::Double theOffset) @@ -643,7 +643,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy /*! * ScaleShape */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr thePoint, @@ -682,7 +682,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape /*! * ScaleShapeCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr thePoint, @@ -718,7 +718,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy /*! * PositionShape */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theStartLCS, @@ -729,7 +729,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape //Set a not done flag GetOperations()->SetNotDone(); - if (theObject == NULL || theStartLCS == NULL || theEndLCS == NULL) + if (theObject == NULL || theEndLCS == NULL) return aGEOMObject._retn(); //check if the object is a subshape @@ -743,10 +743,12 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); if (anObject.IsNull()) return aGEOMObject._retn(); - //Get the Start LCS - Handle(GEOM_Object) aStartLCS = - GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry()); - if (aStartLCS.IsNull()) return aGEOMObject._retn(); + //Get the Start LCS (may be NULL for positioning from global LCS) + Handle(GEOM_Object) aStartLCS = NULL; + if (theStartLCS != NULL && !CORBA::is_nil(theStartLCS)) { + aStartLCS = GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry()); + if (aStartLCS.IsNull()) return aGEOMObject._retn(); + } //Get the End LCS Handle(GEOM_Object) aEndLCS = @@ -763,7 +765,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape /*! * PositionShapeCopy */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theStartLCS, @@ -774,7 +776,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy //Set a not done flag GetOperations()->SetNotDone(); - if (theObject == NULL || theStartLCS == NULL || theEndLCS == NULL) + if (theObject == NULL || theEndLCS == NULL) return aGEOMObject._retn(); //Get the basic object @@ -782,10 +784,12 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); if (aBasicObject.IsNull()) return aGEOMObject._retn(); - //Get the Start LCS - Handle(GEOM_Object) aStartLCS = - GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry()); - if (aStartLCS.IsNull()) return aGEOMObject._retn(); + //Get the Start LCS (may be NULL for positioning from global LCS) + Handle(GEOM_Object) aStartLCS = NULL; + if (theStartLCS != NULL && !CORBA::is_nil(theStartLCS)) { + aStartLCS = GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry()); + if (aStartLCS.IsNull()) return aGEOMObject._retn(); + } //Get the End LCS Handle(GEOM_Object) aEndLCS = @@ -805,14 +809,14 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy /*! * MultiTranslate1D */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector, CORBA::Double theStep, CORBA::Long theNbTimes) { //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); GEOM::GEOM_Object_var aGEOMObject; @@ -830,27 +834,27 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D //Perform the translation Handle(GEOM_Object) anObject = - GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes); + GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - return GetObject(anObject); + return GetObject(anObject); } //============================================================================= /*! * MultiTranslate2D */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr theVector1, - CORBA::Double theStep1, +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector1, + CORBA::Double theStep1, CORBA::Long theNbTimes1, - GEOM::GEOM_Object_ptr theVector2, - CORBA::Double theStep2, + GEOM::GEOM_Object_ptr theVector2, + CORBA::Double theStep2, CORBA::Long theNbTimes2) { //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); GEOM::GEOM_Object_var aGEOMObject; @@ -873,23 +877,23 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_ //Perform the translation Handle(GEOM_Object) anObject = GetOperations()->Translate2D - (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2); + (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - return GetObject(anObject); + return GetObject(anObject); } //============================================================================= /*! * MultiRotate1D */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector, CORBA::Long theNbTimes) { //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); GEOM::GEOM_Object_var aGEOMObject; @@ -906,26 +910,26 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Obj if (aVector.IsNull()) return aGEOMObject._retn(); //Perform the rotation - Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes); + Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - return GetObject(anObject); + return GetObject(anObject); } //============================================================================= /*! * MultiRotate2D */ -//============================================================================= +//============================================================================= GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector, - CORBA::Double theAngle, - CORBA::Long theNbTimes1, - CORBA::Double theStep, + CORBA::Double theAngle, + CORBA::Long theNbTimes1, + CORBA::Double theStep, CORBA::Long theNbTimes2) { //Set a not done flag - GetOperations()->SetNotDone(); + GetOperations()->SetNotDone(); GEOM::GEOM_Object_var aGEOMObject; @@ -943,8 +947,8 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Obj //Perform the rotation Handle(GEOM_Object) anObject = GetOperations()->Rotate2D - (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2); + (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - return GetObject(anObject); + return GetObject(anObject); } diff --git a/src/GEOM_SWIG/GEOM_TestMeasures.py b/src/GEOM_SWIG/GEOM_TestMeasures.py index fe10c1dad..740d1b2d8 100644 --- a/src/GEOM_SWIG/GEOM_TestMeasures.py +++ b/src/GEOM_SWIG/GEOM_TestMeasures.py @@ -119,3 +119,13 @@ def TestMeasureOperations (geompy, math): #print " On Cube (", MinDist[4], ", ", MinDist[5], ", ", MinDist[6], ")" print "\nMinimal distance between Box and Cube = ", MinDist + + ####### Position (LCS) ####### + + Pos = geompy.GetPosition(box) + print "\nPosition(LCS) of box 10x30x70:" + print "Origin: (", Pos[0], ", ", Pos[1], ", ", Pos[2], ")" + print "Z axis: (", Pos[3], ", ", Pos[4], ", ", Pos[5], ")" + print "X axis: (", Pos[6], ", ", Pos[7], ", ", Pos[8], ")" + + pass diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index 4320b52ee..318f667ab 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -273,7 +273,7 @@ def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize): return anObj ## Create a plane, similar to the existing one, but with another size of representing face. -# @param theFace Referenced plane. +# @param theFace Referenced plane or LCS(Marker). # @param theTrimSize New half size of a side of quadrangle face, representing the plane. # @return New GEOM_Object, containing the created plane. # @@ -452,7 +452,7 @@ def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]): # For format of the description string see the previous method.\n # @param theCommand String, defining the sketcher in local # coordinates of the working plane. -# @param theWorkingPlane Planar Face of the working plane. +# @param theWorkingPlane Planar Face or LCS(Marker) of the working plane. # @return New GEOM_Object, containing the created wire. def MakeSketcherOnPlane(theCommand, theWorkingPlane): anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane) @@ -1468,8 +1468,16 @@ def MakeMirrorByPoint(theObject, thePoint): print "MirrorPointCopy : ", TrsfOp.GetErrorCode() return anObj -## Modify the Location of the given object by LCS -# creating its copy before the setting +## Modify the Location of the given object by LCS, +# creating its copy before the setting. +# @param theObject The object to be displaced. +# @param theStartLCS Coordinate system to perform displacement from it. +# If \a theStartLCS is NULL, displacement +# will be performed from global CS. +# If \a theObject itself is used as \a theStartLCS, +# its location will be changed to \a theEndLCS. +# @param theEndLCS Coordinate system to perform displacement to it. +# @return New GEOM_Object, containing the displaced shape. # # Example: see GEOM_TestAll.py def MakePosition(theObject, theStartLCS, theEndLCS): @@ -1813,6 +1821,25 @@ def CheckShape(theShape, theIsCheckGeom = 0): print Status return IsValid +## Get position (LCS) of theShape. +# +# Origin of the LCS is situated at the shape's center of mass. +# Axes of the LCS are obtained from shape's location or, +# if the shape is a planar face, from position of its plane. +# +# @param theShape Shape to calculate position of. +# @return [Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz]. +# Ox,Oy,Oz: Coordinates of shape's LCS origin. +# Zx,Zy,Zz: Coordinates of shape's LCS normal(main) direction. +# Xx,Xy,Xz: Coordinates of shape's LCS X direction. +# +# Example: see GEOM_TestMeasures.py +def GetPosition(theShape): + aTuple = MeasuOp.GetPosition(theShape) + if MeasuOp.IsDone() == 0: + print "GetPosition : ", MeasuOp.GetErrorCode() + return aTuple + # ----------------------------------------------------------------------------- # Import/Export objects # -----------------------------------------------------------------------------