otherwise it will be removed.
\n <b>Select Unpublished edges</b> checkbox allows to select subshape edges on
the other objects.
-\n <b>Arguments:</b> Name + one or several objects + Translation path.
+\n <b>Reverse Direction</b> checkbox allows to REVERSE the direction of the object movement along its path.
+
+<b>Arguments:</b> Name + one or several objects + Translation path.
\n <b>Advanced option:</b>
\ref restore_presentation_parameters_page "Set presentation
parameters and subshapes from arguments".
-
+
\image html transformation13.png
-\image html transformation14.png
-
\image html transformation12.png
+\image html transformation14.png
+
\n <b>TUI Command:</b> <em>geompy.MakePosition(theObject, theStartLCS,
theEndLCS),</em> where \em theObject is a shape, location of which is
modified, \em theStartLCS is a location to move the shape from, \em
# modify the location of the given object
position = geompy.MakePosition(cylinder, cs1, cs2)
-position2 = geompy.PositionAlongPath(position, circle, 0.75, 1)
+position2 = geompy.PositionAlongPath(position, circle, 0.75, 1, 1)
# add objects in the study
id_cs1 = geompy.addToStudy(cs1, "Coordinate system 1")
* \param thePath Wire or Edge along that the object will be translated.
* \param theDistance progress of Path (0 = actual location, 1 = end of path location).
* \param theCopy is a true or false parameter. true is to create a copy, false to move the object.
+ * \param theCopy is a true or false parameter. true is to reverse direction, false is to move normal direction.
* \return New GEOM_Object, containing the displaced shape.
*/
GEOM_Object PositionAlongPath (in GEOM_Object theObject,
in GEOM_Object thePath,
in double theDistance,
- in boolean theCopy);
+ in boolean theCopy,
+ in boolean theReverse);
/*!
* Recompute the shape from its arguments.
GEOM_Object PositionAlongPath (in GEOM_Object theObject,
in GEOM_Object thePath,
in double theDistance,
- in boolean theCopy);
+ in boolean theCopy,
+ in boolean theReverse);
//-----------------------------------------------------------//
// ShapesOperations //
}
}
+//////////////////////////////////////////
+// DlgRef_4Sel1Spin3Check
+//////////////////////////////////////////
+
+DlgRef_4Sel1Spin3Check::DlgRef_4Sel1Spin3Check( QWidget* parent, Qt::WindowFlags f )
+: QWidget( parent, f )
+{
+ setupUi( this );
+}
+
+DlgRef_4Sel1Spin3Check::~DlgRef_4Sel1Spin3Check()
+{
+}
+
//////////////////////////////////////////
// DlgRef_6Sel
//////////////////////////////////////////
void ShowRows( int, int, bool = true );
};
+//////////////////////////////////////////
+// DlgRef_4Sel1Spin2Check
+//////////////////////////////////////////
+
+#include "ui_DlgRef_4Sel1Spin3Check_QTD.h"
+
+class DLGREF_EXPORT DlgRef_4Sel1Spin3Check : public QWidget,
+ public Ui::DlgRef_4Sel1Spin3Check_QTD
+{
+ Q_OBJECT
+
+public:
+ DlgRef_4Sel1Spin3Check( QWidget* = 0, Qt::WindowFlags = 0 );
+ ~DlgRef_4Sel1Spin3Check();
+};
+
//////////////////////////////////////////
// DlgRef_6Sel
//////////////////////////////////////////
HEADERS += DlgRef_3Spin1Check_QTD.h
HEADERS += DlgRef_3Sel3Spin1Check_QTD.h
HEADERS += DlgRef_4Sel1Spin2Check_QTD.h
+HEADERS += DlgRef_4Sel1Spin3Check_QTD.h
HEADERS += DlgRef_SpinBox.h
HEADERS += DlgRef_1Sel1Spin.h
HEADERS += DlgRef_1Sel2Spin.h
ui_DlgRef_4Sel1List1Check_QTD.h \
ui_DlgRef_4Sel1List_QTD.h \
ui_DlgRef_4Sel1Spin2Check_QTD.h \
+ ui_DlgRef_4Sel1Spin3Check_QTD.h \
ui_DlgRef_6Sel_QTD.h \
ui_DlgRef_Skeleton_QTD.h
<source>GEOM_REVERSE</source>
<translation>Reverse</translation>
</message>
+ <message>
+ <source>GEOM_REVERSE_DIRECTION</source>
+ <translation>Reverse Direction</translation>
+ </message>
<message>
<source>GEOM_REVERSE_PLANE</source>
<translation>Reverse the plane normal</translation>
#define POSITION_ARG_END_LCS 3
#define POSITION_ARG_PATH 5
#define POSITION_ARG_DISTANCE 6
+#define POSITION_ARG_REVERSE 7
class GEOMImpl_IPosition
{
double GetDistance() { return _func->GetReal(POSITION_ARG_DISTANCE); }
+ void SetReverse(bool theReverse) { _func->SetReal(POSITION_ARG_REVERSE, theReverse); }
+ bool GetReverse() { return _func->GetReal(POSITION_ARG_REVERSE); }
+
private:
Handle(GEOM_Function) _func;
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
(Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath,
- double theDistance, bool theCopy)
+ double theDistance, bool theCopy, bool theReverse)
{
SetErrorCode(KO);
aTI.SetShape(anOriginal);
aTI.SetPath(thePath->GetLastFunction());
aTI.SetDistance(theDistance);
+ aTI.SetReverse(theReverse);
//Compute the position
try {
//Make a Python command
if (theCopy) {
GEOM::TPythonDump(aFunction) << aCopy << " = geompy.PositionAlongPath("
- << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ")";
+ << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
SetErrorCode(OK);
return aCopy;
}
GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionAlongPath("
- << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ")";
+ << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
SetErrorCode(OK);
return theObject;
Standard_EXPORT Handle(GEOM_Object) PositionAlongPath (Handle(GEOM_Object) theObject,
Handle(GEOM_Object) thePath,
double theDistance,
- bool theCopy);
+ bool theCopy,
+ bool theReverse);
Standard_EXPORT Handle(GEOM_Object) Rotate (Handle(GEOM_Object) theObject,
Handle(GEOM_Object) theAxis,
#include <GCPnts_AbscissaPoint.hxx>
#include <ShHealOper_EdgeDivide.hxx>
#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <BRepGProp.hxx>
#include <ShapeAnalysis_Edge.hxx>
#include <GeomAdaptor_Curve.hxx>
+#include <BRepGProp.hxx>
+#include <ShapeFix_Wire.hxx>
#include <Precision.hxx>
#include <gp_Pnt.hxx>
Handle(GEOM_Function) aRefShape = aCI.GetShape();
Handle(GEOM_Function) aPathShape = aCI.GetPath();
double aValue = aCI.GetDistance();
+ bool aReversed = aCI.GetReverse();
TopoDS_Shape aShapeBase = aRefShape->GetValue();
TopoDS_Shape aPath = aPathShape->GetValue();
if (aShapeBase.IsNull() || aPath.IsNull())
return 0;
+ //Get a Center Of Mass Of Base Object
+ GProp_GProps aSystem;
+ gp_Pnt aCenterMass;
+ if (aShapeBase.ShapeType() == TopAbs_VERTEX) {
+ aCenterMass = BRep_Tool::Pnt(TopoDS::Vertex(aShapeBase));
+ } else if (aShapeBase.ShapeType() == TopAbs_EDGE || aShapeBase.ShapeType() == TopAbs_WIRE) {
+ BRepGProp::LinearProperties(aShapeBase, aSystem);
+ aCenterMass = aSystem.CentreOfMass();
+ } else if (aShapeBase.ShapeType() == TopAbs_FACE || aShapeBase.ShapeType() == TopAbs_SHELL) {
+ BRepGProp::SurfaceProperties(aShapeBase, aSystem);
+ aCenterMass = aSystem.CentreOfMass();
+ } else {
+ BRepGProp::VolumeProperties(aShapeBase, aSystem);
+ aCenterMass = aSystem.CentreOfMass();
+ }
+
TopoDS_Shape aTrimmedPath;
gp_Trsf aTrsf;
Handle(Geom_Curve) aCurve;
Standard_Real aFirst =0.,aLast=0.;
Standard_Real aParam = 0.;
Standard_Real aLength = 0.;
+
+ gp_Pnt aPFirst, aPLast;
- if ( aPath.ShapeType() == TopAbs_EDGE ) {
+ if ( aPath.ShapeType() == TopAbs_EDGE ) { // The Path is Edge
TopoDS_Edge anEdge = TopoDS::Edge(aPath);
- // Computation by Parameter
+
BRep_Tool::Range(anEdge,aFirst,aLast);
aCurve = BRep_Tool::Curve(anEdge,aFirst,aLast);
- aParam = aFirst + aValue*(aLast - aFirst);
- } else if ( aPath.ShapeType() == TopAbs_WIRE ) {
+ if (aReversed)
+ aCurve = aCurve->Reversed();
+
+ aCurve->D0(aFirst, aPFirst);
+ aCurve->D0(aLast, aPLast);
+
+ // Translate a CenterMass of Base Shape to the start of the path
+ if ( !aPFirst.IsEqual(aCenterMass, gp::Resolution()) ) {
+ gp_Trsf aCurTrsf;
+ aCurTrsf.SetTranslation(aCenterMass, aPFirst);
+ aTrsf.PreMultiply(aCurTrsf);
+ }
+ aParam = aFirst + aValue*(aLast - aFirst); // Calculate parameter
+ } else if ( aPath.ShapeType() == TopAbs_WIRE ) { // The path Shape is Wire
+ TopoDS_Wire aWire = TopoDS::Wire(aPath);
+
+ // fix edges order
+ Handle(ShapeFix_Wire) aFixWire = new ShapeFix_Wire;
+ aFixWire->Load(aWire);
+ aFixWire->FixReorder();
+ aWire = aFixWire->Wire();
+
TopExp_Explorer ex;
TopTools_SequenceOfShape Edges;
Standard_Real nbEdges = 0.;
- BRepTools_WireExplorer aWE (TopoDS::Wire(aPath));
- for (; aWE.More(); aWE.Next(), nbEdges++)
+ BRepTools_WireExplorer aWE (aWire);
+ for (; aWE.More(); aWE.Next(), nbEdges++) // Explore a Wire on Edges
Edges.Append(aWE.Current());
Standard_Real aSummOfLen =0.;
Standard_Real aCurLen =0.;
GeomAdaptor_Curve aAdC;
- for(int i=1; i<=Edges.Length(); i++) {
+
+ for(int i=1; i<=Edges.Length(); i++) { // Calculate summary Lenght of edges
TopoDS_Edge anEdge = TopoDS::Edge(Edges.Value(i));
BRep_Tool::Range(anEdge,aFirst,aLast);
aCurve = BRep_Tool::Curve(anEdge,aFirst,aLast);
aSummOfLen += aCurLen;
}
+ // Move BaseShape to the Start Of the Curve
+ TopoDS_Edge anEdge;
+ if (!aReversed)
+ anEdge = TopoDS::Edge(Edges.Value(1));
+ else
+ anEdge = TopoDS::Edge(Edges.Value(Edges.Length()));
+
+ BRep_Tool::Range(anEdge,aFirst,aLast);
+ aCurve = BRep_Tool::Curve(anEdge,aFirst,aLast);
+ aCurve->D0(aFirst, aPFirst);
+ aCurve->D0(aLast, aPLast);
+ if ( !aPFirst.IsEqual(aCenterMass, gp::Resolution()) ) {
+ gp_Trsf aCurTrsf;
+ if (aReversed && anEdge.Orientation() == TopAbs_FORWARD)
+ aPFirst = aPLast;
+
+ aCurTrsf.SetTranslation(aCenterMass, aPFirst);
+ aTrsf.PreMultiply(aCurTrsf);
+ }
+
Standard_Real aWireLen = aSummOfLen*aValue;
aSummOfLen = 0;
for(int i=1; i<=Edges.Length(); i++) {
- TopoDS_Edge anEdge = TopoDS::Edge(Edges.Value(i));
- BRep_Tool::Range(anEdge,aFirst,aLast);
+ TopoDS_Edge anEdge;
+ if (!aReversed)
+ anEdge = TopoDS::Edge(Edges.Value(i));
+ else
+ anEdge = TopoDS::Edge(Edges.Value(Edges.Length() - i + 1));
+
aCurve = BRep_Tool::Curve(anEdge,aFirst,aLast);
+ BRep_Tool::Range(anEdge,aFirst,aLast);
+
+ if (!aReversed && anEdge.Orientation() == TopAbs_REVERSED)
+ aCurve = aCurve->Reversed();
+
+ if (aReversed && anEdge.Orientation() == TopAbs_FORWARD)
+ aCurve = aCurve->Reversed();
+
aAdC.Load(aCurve,aFirst,aLast);
- aCurLen = GCPnts_AbscissaPoint::Length(aAdC,aFirst,aLast);
+ aCurLen = GCPnts_AbscissaPoint::Length(aAdC,aFirst,aLast);
- if ( aWireLen > (aSummOfLen + aCurLen) ) {
- aSummOfLen += aCurLen; // Transform a Base object along this Edge
+ if ( aWireLen > (aSummOfLen + aCurLen) ) { // Transform a Base object along this Edge
+ aSummOfLen += aCurLen;
gp_Pnt aP1, aP2;
gp_Vec aStartVec1, aStartVec2, aDestVec1, aDestVec2;
aCurve->D2(aFirst, aP1, aStartVec1, aStartVec2 );
aCurve->D2(aLast, aP2, aDestVec1, aDestVec2 );
gp_Trsf aCurTrsf;
- if (aStartVec2.Magnitude() < gp::Resolution() || aDestVec2.Magnitude() < gp::Resolution()) // one of the second derivatives is null
- aCurTrsf.SetTranslation(aP1, aP2);
- else {
+ if (aStartVec2.Magnitude() > gp::Resolution() && aDestVec2.Magnitude() > gp::Resolution()) {
gp_Ax3 aStartAx3(aP1, aStartVec1, aStartVec2);
gp_Ax3 aDestAx3(aP2, aDestVec1, aDestVec2);
aCurTrsf.SetDisplacement(aStartAx3, aDestAx3);
- }
+ } else
+ aCurTrsf.SetTranslation(aP1, aP2);
+
aTrsf.PreMultiply(aCurTrsf);
}
else {
} else
return 0; // Unknown Type
+ gp_Trsf aCurTrsf;
gp_Pnt aP1, aP2;
gp_Vec aStartVec1, aStartVec2, aDestVec1, aDestVec2;
aCurve->D2(aFirst, aP1, aStartVec1, aStartVec2 );
aCurve->D2(aParam, aP2, aDestVec1, aDestVec2 );
- gp_Trsf aCurTrsf;
- if (aStartVec2.Magnitude() < gp::Resolution() || aDestVec2.Magnitude() < gp::Resolution()) // one of the second derivatives is null
- aCurTrsf.SetTranslation(aP1, aP2);
- else {
+ if (aStartVec2.Magnitude() > gp::Resolution() && aDestVec2.Magnitude() > gp::Resolution()) {
gp_Ax3 aStartAx3(aP1, aStartVec1, aStartVec2);
gp_Ax3 aDestAx3(aP2, aDestVec1, aDestVec2);
aCurTrsf.SetDisplacement(aStartAx3, aDestAx3);
- }
-
+ } else
+ aCurTrsf.SetTranslation(aP1, aP2);
+
aTrsf.PreMultiply(aCurTrsf);
+
+ if ( !aPFirst.IsEqual(aCenterMass, gp::Resolution()) ) {
+ gp_Trsf aCurTrsf;
+ aCurTrsf.SetTranslation(aPFirst, aCenterMass);
+ aTrsf.PreMultiply(aCurTrsf);
+ }
// Perform transformation
BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False);
(GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePath,
CORBA::Double theDistance,
- CORBA::Boolean theCopy)
+ CORBA::Boolean theCopy,
+ CORBA::Boolean theReverse)
{
GEOM::GEOM_Object_var aGEOMObject;
//Perform the position
Handle(GEOM_Object) anObject =
- GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy);
+ GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
GEOM::GEOM_Object_ptr PositionAlongPath (GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePath,
CORBA::Double theDistance,
- CORBA::Boolean theCopy);
+ CORBA::Boolean theCopy,
+ CORBA::Boolean theReverse);
GEOM::GEOM_Object_ptr RotateThreePoints (GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr theCentPoint,
GEOM::GEOM_Object_ptr GEOM_Superv_i::PositionAlongPath (GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePath,
CORBA::Double theDistance,
- CORBA::Boolean theCopy)
+ CORBA::Boolean theCopy,
+ CORBA::Boolean theReverse)
{
beginService( " GEOM_Superv_i::PositionAlongPath" );
MESSAGE("GEOM_Superv_i::PositionAlongPath");
getTransfOp();
- GEOM::GEOM_Object_ptr anObj = myTransfOp->PositionAlongPath(theObject, thePath, theDistance, theCopy);
+ GEOM::GEOM_Object_ptr anObj = myTransfOp->PositionAlongPath(theObject, thePath, theDistance, theCopy, theReverse);
endService( " GEOM_Superv_i::PositionAlongPath" );
return anObj;
}
GEOM::GEOM_Object_ptr PositionAlongPath (GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePath,
CORBA::Double theDistance,
- CORBA::Boolean theCopy);
+ CORBA::Boolean theCopy,
+ CORBA::Boolean theReverse);
//-----------------------------------------------------------//
// ShapesOperations //
MirrorAxis = geompy.MakeMirrorByAxis(Box, Line1) #
MirrorPnt = geompy.MakeMirrorByPoint(Box, p200) #
Position = geompy.MakePosition(Box, cs1, cs2) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
- Position2 = geompy.PositionAlongPath(Box, Arc, 0.5, 1) #(2 GEOM_Object_ptr, 1 Double, 1 Bool)->GEOM_Object_ptr
+ Position2 = geompy.PositionAlongPath(Box, Arc, 0.5, 1, 0) #(2 GEOM_Object_ptr, 1 Double, 2 Bool)->GEOM_Object_ptr
Offset = geompy.MakeOffset(Box, 10.) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
Orientation = geompy.ChangeOrientation(Box)
# @param theObject The object to be displaced.
# @param thePath Wire or Edge along that the object will be translated.
# @param theDistance progress of Path (0 = start location, 1 = end of path location).
+ # @param theCopy is to create a copy objects if true.
+ # @param theReverse - 0 for usual direction, 1 to reverse path direction.
# @return New GEOM_Object, containing the displaced shape.
#
# @ref tui_modify_location "Example"
- def PositionAlongPath(self,theObject, thePath, theDistance, theCopy):
+ def PositionAlongPath(self,theObject, thePath, theDistance, theCopy, theReverse):
# Example: see GEOM_TestAll.py
- anObj = self.TrsfOp.PositionAlongPath(theObject, thePath, theDistance, theCopy)
+ anObj = self.TrsfOp.PositionAlongPath(theObject, thePath, theDistance, theCopy, theReverse)
RaiseIfFailed("PositionAlongPath", self.TrsfOp)
return anObj
mainFrame()->RadioButton2->setIcon(image1);
mainFrame()->RadioButton3->setIcon(image2);
- Group1 = new DlgRef_4Sel1Spin2Check(centralWidget());
+ Group1 = new DlgRef_4Sel1Spin3Check(centralWidget());
Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
Group1->TextLabel1->setText(tr("GEOM_OBJECTS"));
Group1->TextLabel2->setText(tr("GEOM_START_LCS"));
Group1->PushButton5->setIcon(imageselect);
Group1->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
Group1->CheckButton2->setText(tr("SELECT_UNPUBLISHED_EDGES"));
+ Group1->CheckButton3->setText(tr("GEOM_REVERSE_DIRECTION"));
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
Group1->LineEdit5->setText("");
initSpinBox(Group1->SpinBox_DX, 0, 1, 0.05, 6); // VSR:TODO : DBL_DIGITS_DISPLAY
- Group1->SpinBox_DX->setValue(1);
+ Group1->SpinBox_DX->setValue(0);
Group1->CheckButton2->setEnabled(false);
connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(Group1->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(SelectionTypeButtonClicked()));
+ connect(Group1->CheckButton3, SIGNAL(toggled(bool)), this, SLOT(ValueChangedInSpinBox()));
initName(tr("GEOM_POSITION"));
Group1->PushButton1->click();
Group1->CheckButton2->hide();
+ Group1->CheckButton3->hide();
}
break;
case 1:
Group1->PushButton1->click();
Group1->CheckButton2->hide();
+ Group1->CheckButton3->hide();
}
break;
case 2:
Group1->PushButton1->click();
Group1->CheckButton2->show();
+ Group1->CheckButton3->show();
}
break;
}
return;
else
myEditCurrentArgument->setText(aName);
+
+ if (getConstructorId() == 2)
+ Group1->PushButton5->click();
}
else if (myEditCurrentArgument == Group1->LineEdit2) {
if (aSelList.Extent() != 1)
aName = GEOMBase::GetName(myEndLCS);
myEditCurrentArgument->setText(aName);
- if (!myEndLCS->_is_nil() && !myObjects.length() && getConstructorId() != 2)
+ if (!myEndLCS->_is_nil() && !myObjects.length())
Group1->PushButton1->click();
- else if (getConstructorId() == 2 && !myObjects.length())
- Group1->PushButton5->click();
}
else if (myEditCurrentArgument == Group1->LineEdit5) {
myPath = GEOM::GEOM_Object::_nil();
myEditCurrentArgument->setText(aName);
myPath = aSelectedObject;
+
+ if (!myPath->_is_nil() && !myObjects.length())
+ Group1->PushButton1->click();
}
// clear selection
case 2:
{
double aDistance = Group1->SpinBox_DX->value();
+ bool toReverse = Group1->CheckButton3->isChecked();
for (int i = 0; i < myObjects.length(); i++) {
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
- PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy);
+ PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy, toReverse);
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
#include <GEOMBase_Skeleton.h>
-class DlgRef_4Sel1Spin2Check;
+class DlgRef_4Sel1Spin3Check;
//=================================================================================
// class : TransformationGUI_PositionDlg
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
- DlgRef_4Sel1Spin2Check* Group1;
+ DlgRef_4Sel1Spin3Check* Group1;
private slots:
void ClickOnOk();