/*!
* 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.
*/
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,
* 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);
*/
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.
// 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
//
//
//
#include <qlabel.h>
#include "GEOMImpl_Types.hxx"
+
#include "utilities.h"
+// OCCT Includes
+#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Face.hxx>
-#include <TColStd_IndexedMapOfInteger.hxx>
+#include <Geom_Plane.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
-#include <BRep_Tool.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
-#include <Geom_Plane.hxx>
-#include <GProp_GProps.hxx>
-#include <BRepGProp.hxx>
//=================================================================================
// class : BasicGUI_MarkerDlg()
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();
}
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()));
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 );
}
}
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone()));
onSelectionDone();
}
initName();
ConstructorsClicked( getConstructorId() );
-
+
return true;
}
{
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 );
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 )
{
//=================================================================================
void BasicGUI_MarkerDlg::onSelectionDone()
{
- if ( getConstructorId() == 0 )
- {
+ if ( getConstructorId() == 0 ) {
onSelectionDone0();
return;
}
-
myEditCurrentArgument->setText("");
QString aName;
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() );
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() );
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() );
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 );
myData[ DY2 ]->SetValue( 0 );
myData[ DZ2 ]->SetValue( 0 );
}
- }
+ }
}
-
+
displayPreview();
}
void BasicGUI_MarkerDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
-
+
if(send == Group1->PushButton1) {
myEditCurrentArgument = Group1->LineEdit1;
globalSelection( GEOM_ALLGEOM );
myEditCurrentArgument = Group2->LineEdit3;
globalSelection( GEOM_LINE );
}
-
+
myEditCurrentArgument->setFocus();
onSelectionDone();
}
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() );
// purpose :
//=================================================================================
void BasicGUI_MarkerDlg::enterEvent(QEvent* e)
-{
+{
if ( !GroupConstructors->isEnabled() )
onActivate();
}
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;
}
}
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// 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
//
//
#include "SalomeApp_Application.h"
#include "LightApp_SelectionMgr.h"
+#include <TColStd_MapOfInteger.hxx>
+
#include <qlabel.h>
#include "GEOMImpl_Types.hxx"
//=================================================================================
// 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.
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();
}
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
-{
+{
}
/* 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 );
switch ( constructorId )
{
case 0: /* plane from a point and a direction (vector, edge...) */
- {
+ {
Group3Pnts->hide();
GroupFace->hide();
resize(0, 0);
/* for the first argument */
globalSelection( GEOM_POINT );
break;
- }
+ }
case 2: /* plane from a planar face selection */
{
GroupPntDir->hide();
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()));
}
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();
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;
//=================================================================================
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;
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();
}
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 );
// 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
//
//
//
#include "SalomeApp_Application.h"
#include "LightApp_SelectionMgr.h"
-#include <Geom_Surface.hxx>
-#include <Geom_Plane.hxx>
+// OCCT Includes
+#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
-#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
-#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
-#include <gp_Pln.hxx>
-#include <V3d_View.hxx>
-
-#include "GEOMImpl_Types.hxx"
+#include <TColStd_MapOfInteger.hxx>
+// QT Includes
#include <qcheckbox.h>
#include <qlabel.h>
+#include "GEOMImpl_Types.hxx"
+
using namespace std;
//=================================================================================
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" ) );
//=================================================================================
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();
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:
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:
Group3->RadioButton1->setChecked(true);
aOriginType = 1;
- break;
+ break;
}
}
displayPreview();
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;
}
//=================================================================================
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() );
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;
}
msgid "GEOM_FACES"
msgstr "Faces"
+#Face or LCS
+msgid "GEOM_FACE_OR_LCS"
+msgstr "Face or LCS"
+
#Line
msgid "GEOM_LINE"
msgstr "Line"
#: 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"
// 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 <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx>
+// OCCT Includes
#include <TFunction_DriverTable.hxx>
#include <TFunction_Driver.hxx>
#include <TFunction_Logbook.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
+#include <gp_Pln.hxx>
+
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
//=============================================================================
}
+//=============================================================================
+/*! 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
#include "GEOM_IOperations.hxx"
#include <BRepCheck_Analyzer.hxx>
+#include <TopoDS_Shape.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TCollection_AsciiString.hxx>
+#include <gp_Ax3.hxx>
class GEOM_Engine;
class Handle(GEOM_Object);
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,
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,
// 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
{
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 {
{
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
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
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 {
// 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 <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
+#include <GEOMImpl_IMeasureOperations.hxx>
+
+// OCCT Includes
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRep_Tool.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
//=======================================================================
//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);
} 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();
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;
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);
if(aTool.IsDone())
aShape = aTool.Shape();
}
-
else {
}
aFunction->SetValue(aShape);
- log.SetTouched(Label());
+ log.SetTouched(Label());
return 1;
}
//=======================================================================
//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",
//=======================================================================
//function : DownCast
//purpose :
-//=======================================================================
+//=======================================================================
const Handle(GEOMImpl_PlaneDriver) Handle(GEOMImpl_PlaneDriver)::DownCast
(const Handle(Standard_Transient)& AnObject)
{
// 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 <Standard_Stream.hxx>
+//#include <Standard_Stream.hxx>
#include <GEOMImpl_PositionDriver.hxx>
#include <GEOMImpl_IPosition.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
+#include <GEOMImpl_IMeasureOperations.hxx>
+
+// OCCT Includes
#include <BRepBuilderAPI_Transform.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
//=======================================================================
//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);
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();
}
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",
//=======================================================================
//function : DownCast
//purpose :
-//=======================================================================
+//=======================================================================
const Handle(GEOMImpl_PositionDriver) Handle(GEOMImpl_PositionDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOMImpl_PositionDriver) _anOtherObject;
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
+#include <GEOMImpl_IMeasureOperations.hxx>
+
+// OCCT Includes
#include <BRepBuilderAPI_Transform.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Plane.hxx>
{
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);
#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
// 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
}
+//=============================================================================
+/*!
+ * 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
//Set a not done flag
GetOperations()->SetNotDone();
- if (theShape == NULL)
+ if (theShape == NULL)
{
theDescription = CORBA::string_dup("null");
return 0;
//Set a not done flag
GetOperations()->SetNotDone();
- if (theShape == NULL)
+ if (theShape == NULL)
{
theDescription = CORBA::string_dup("null");
return 0;
::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,
// 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
/*!
* TranslateTwoPoints
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints
(GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePoint1,
//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
/*!
* TranslateTwoPointsCopy
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy
(GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePoint1,
/*!
* 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();
/*!
* TranslateDXDYDZCopy
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy
(GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
{
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();
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)
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
- GetOperations()->SetNotDone();
+ GetOperations()->SetNotDone();
if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
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);
}
/*!
* 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();
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)
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
- GetOperations()->SetNotDone();
+ GetOperations()->SetNotDone();
if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
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);
}
/*!
* MirrorPlane
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
(GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePlane)
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();
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)
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
- GetOperations()->SetNotDone();
+ GetOperations()->SetNotDone();
if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn();
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)
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();
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)
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
- GetOperations()->SetNotDone();
+ GetOperations()->SetNotDone();
if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
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)
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();
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)
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
- GetOperations()->SetNotDone();
+ GetOperations()->SetNotDone();
if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn();
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);
}
/*!
* OffsetShape
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
(GEOM::GEOM_Object_ptr theObject,
CORBA::Double theOffset)
/*!
* OffsetShapeCopy
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
(GEOM::GEOM_Object_ptr theObject,
CORBA::Double theOffset)
/*!
* ScaleShape
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
(GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePoint,
/*!
* ScaleShapeCopy
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
(GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePoint,
/*!
* PositionShape
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
(GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr theStartLCS,
//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
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 =
/*!
* PositionShapeCopy
*/
-//=============================================================================
+//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
(GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr theStartLCS,
//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
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 =
/*!
* 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;
//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;
//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;
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;
//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);
}
#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
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.
#
# 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)
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):
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
# -----------------------------------------------------------------------------