mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-18 12:50:37 +05:00
PAL12781: EDF: different result between Working Plane and LCS. Implement and use general mechanism to obtain position from shape.
This commit is contained in:
parent
5c5319be31
commit
c3d31bd3dc
@ -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.
|
||||
|
@ -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
|
||||
//
|
||||
//
|
||||
//
|
||||
@ -37,21 +37,21 @@
|
||||
#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()
|
||||
@ -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,23 +349,22 @@ 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 )
|
||||
{
|
||||
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
|
||||
@ -386,13 +387,11 @@ 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 ( 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.;
|
||||
|
||||
if ( !aMap.IsEmpty() ) {
|
||||
int anIndex = aMap( 1 );
|
||||
TopTools_IndexedMapOfShape aShapes;
|
||||
TopExp::MapShapes( aShape, aShapes );
|
||||
aShape = aShapes.FindKey( anIndex );
|
||||
}
|
||||
GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
|
||||
myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId());
|
||||
aMeasureOp->GetPosition(aSelectedObj, Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz);
|
||||
|
||||
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);
|
||||
// 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);
|
||||
|
||||
aPnt = aSystem.CentreOfMass();
|
||||
}
|
||||
gp_Dir aDirY = anAx3.YDirection();
|
||||
aDirY.Coord(Yx,Yy,Yz);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
// Set values
|
||||
myData[ X ]->SetValue( Ox );
|
||||
myData[ Y ]->SetValue( Oy );
|
||||
myData[ Z ]->SetValue( Oz );
|
||||
|
||||
gp_Dir aDirX = anAx3.XDirection();
|
||||
gp_Dir aDirY = anAx3.YDirection();
|
||||
myData[ DX1 ]->SetValue( Xx );
|
||||
myData[ DY1 ]->SetValue( Xy );
|
||||
myData[ DZ1 ]->SetValue( Xz );
|
||||
|
||||
myData[ X ]->SetValue( aPnt.X() );
|
||||
myData[ Y ]->SetValue( aPnt.Y() );
|
||||
myData[ Z ]->SetValue( aPnt.Z() );
|
||||
myData[ DX2 ]->SetValue( Yx );
|
||||
myData[ DY2 ]->SetValue( Yy );
|
||||
myData[ DZ2 ]->SetValue( Yz );
|
||||
|
||||
myData[ DX1 ]->SetValue( aDirX.X() );
|
||||
myData[ DY1 ]->SetValue( aDirX.Y() );
|
||||
myData[ DZ1 ]->SetValue( aDirX.Z() );
|
||||
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;
|
||||
|
||||
myData[ DX2 ]->SetValue( aDirY.X() );
|
||||
myData[ DY2 ]->SetValue( aDirY.Y() );
|
||||
myData[ DZ2 ]->SetValue( aDirY.Z() );
|
||||
TColStd_IndexedMapOfInteger aMap;
|
||||
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
||||
aSelMgr->GetIndexes( anIO, aMap );
|
||||
|
||||
myEditCurrentArgument->setText( aName );
|
||||
}
|
||||
else {
|
||||
myData[ X ]->SetValue( 0 );
|
||||
myData[ Y ]->SetValue( 0 );
|
||||
myData[ Z ]->SetValue( 0 );
|
||||
if ( !aMap.IsEmpty() ) {
|
||||
int anIndex = aMap( 1 );
|
||||
TopTools_IndexedMapOfShape aShapes;
|
||||
TopExp::MapShapes( aShape, aShapes );
|
||||
aShape = aShapes.FindKey( anIndex );
|
||||
}
|
||||
|
||||
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 (myEditCurrentArgument == Group2->LineEdit1) {
|
||||
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
|
||||
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
|
||||
myData[ X ]->SetValue( aPnt.X() );
|
||||
@ -734,17 +711,3 @@ void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "SalomeApp_Application.h"
|
||||
#include "LightApp_SelectionMgr.h"
|
||||
|
||||
#include <TColStd_MapOfInteger.hxx>
|
||||
|
||||
#include <qlabel.h>
|
||||
|
||||
#include "GEOMImpl_Types.hxx"
|
||||
@ -89,7 +91,7 @@ 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);
|
||||
@ -237,7 +239,11 @@ 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;
|
||||
}
|
||||
}
|
||||
@ -338,10 +344,15 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument()
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -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 <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;
|
||||
|
||||
//=================================================================================
|
||||
@ -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;
|
||||
}
|
||||
} else if (id == 1) {
|
||||
|
||||
// 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) { // 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;
|
||||
}
|
||||
|
||||
myWPlane = gp_Ax3(BRep_Tool::Pnt(V1), aDirZ, aDirX);
|
||||
|
||||
myGeomGUI->SetWorkingPlane(myWPlane);
|
||||
myGeomGUI->ActiveWorkingPlane();
|
||||
return true;
|
||||
}
|
||||
} 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.);
|
||||
}
|
||||
else if (aOriginType == 2) {
|
||||
aDirZ = gp_Dir(1., 0., 0.);
|
||||
aDirX = gp_Dir(0., 1., 0.);
|
||||
}
|
||||
else if (aOriginType == 0) {
|
||||
aDirZ = gp_Dir(0., 1., 0.);
|
||||
aDirX = gp_Dir(0., 0., 1.);
|
||||
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(P1, 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (aVZ.Magnitude() < Precision::Confusion()) {
|
||||
showError( "Bad OZ vector" );
|
||||
return false;
|
||||
}
|
||||
|
||||
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(BRep_Tool::Pnt(VX1), aDirZ, aDirX);
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <OpUtil.hxx>
|
||||
#include <Utils_ExceptHandlers.hxx>
|
||||
|
||||
// OCCT Includes
|
||||
#include <TFunction_DriverTable.hxx>
|
||||
#include <TFunction_Driver.hxx>
|
||||
#include <TFunction_Logbook.hxx>
|
||||
@ -62,6 +63,10 @@
|
||||
#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
|
||||
|
||||
//=============================================================================
|
||||
@ -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
|
||||
|
@ -24,9 +24,11 @@
|
||||
#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);
|
||||
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -25,6 +25,9 @@
|
||||
#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>
|
||||
@ -124,12 +127,15 @@ 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)
|
||||
{
|
||||
@ -167,7 +173,6 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const
|
||||
if(aTool.IsDone())
|
||||
aShape = aTool.Shape();
|
||||
}
|
||||
|
||||
else {
|
||||
}
|
||||
|
||||
|
@ -18,13 +18,16 @@
|
||||
// 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>
|
||||
@ -88,52 +91,42 @@ Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const
|
||||
|
||||
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();
|
||||
}
|
||||
// End LCS
|
||||
aDestAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeEndLCS);
|
||||
|
||||
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();
|
||||
// Start LCS
|
||||
aStartAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeStartLCS);
|
||||
|
||||
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);
|
||||
// Set transformation
|
||||
aTrsf.SetDisplacement(aStartAx3, aDestAx3);
|
||||
|
||||
aPnt = aSystem.CentreOfMass();
|
||||
}
|
||||
// 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();
|
||||
|
||||
gp_Vec aVec(aPnt, aDestAx3.Location());
|
||||
aTrsf2.SetTranslation(aVec);
|
||||
aTrsf = aTrsf2 * aTrsf1;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
@ -25,6 +25,9 @@
|
||||
#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>
|
||||
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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 =
|
||||
@ -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 =
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
# -----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user