typedef sequence<ListOfDouble> ListOfListOfDouble;
typedef sequence<ListOfLong> ListOfListOfLong;
+ interface GEOM_Gen;
interface GEOM_Object;
interface GEOM_BaseObject;
interface GEOM_Field;
* \brief Return name of operation and values of parameters used for object creation
*/
CreationInformationSeq GetCreationInformation();
+
+ /*!
+ * \brief Return the engine creating this object
+ */
+ GEOM_Gen GetGen();
};
//# GEOM_Object
GEOM_Object GetCentreOfMass (in GEOM_Object theShape);
/*
- * Get the vertex by index for 1D objects depends the edge/wire orientation
+ * Get the vertex by index for 1D objects
* \param theShape Shape (wire or edge) to find the vertex on it
* \param theIndex Index of vertex sub-shape
+ * \param theUseOri To consider edge/wire orientation or not
* \return New GEOM_Object, vertex.
*/
- GEOM_Object GetVertexByIndex( in GEOM_Object theShape, in long index );
+ GEOM_Object GetVertexByIndex( in GEOM_Object theShape, in long theIndex, in boolean theUseOri );
/*!
* \brief Get a vector, representing the normal of theFace.
//
#include "GEOM_Function.hxx"
-//#define MEASURE_ARG_BASE 1
-//#define MEASURE_ARG_POINT 2
-
class GEOMImpl_IMeasure
{
enum {
MEASURE_ARG_BASE = 1,
MEASURE_ARG_POINT = 2,
- MEASURE_INDEX = 3
+ MEASURE_INDEX = 3,
+ MEASURE_USE_ORI = 4
};
public:
int GetIndex() { return _func->GetInteger(MEASURE_INDEX); }
+ void SetUseOri(int theIndex) { _func->SetInteger(MEASURE_USE_ORI, theIndex); }
+
+ bool GetUseOri() { return ( _func->GetInteger(MEASURE_USE_ORI) ||
+ !_func->IsDone() ); // old behavior was to useOri
+ }
+
private:
Handle(GEOM_Function) _func;
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex
(Handle(GEOM_Object) theShape,
- Standard_Integer theIndex)
+ Standard_Integer theIndex,
+ Standard_Boolean theUseOri)
{
SetErrorCode(KO);
GEOMImpl_IMeasure aCI (aFunction);
aCI.SetBase(aRefShape);
aCI.SetIndex(theIndex);
+ aCI.SetUseOri(theUseOri);
//Compute
try {
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << aVertex << " = geompy.GetVertexByIndex(" << theShape << ", " << theIndex << ")";
+ GEOM::TPythonDump(aFunction) << aVertex << " = geompy.GetVertexByIndex("
+ << theShape << ", "
+ << theIndex << ", "
+ << theUseOri << ")";
SetErrorCode(OK);
return aVertex;
for (int i = 1; i <= nbSolutions; i++) {
P1 = dst.PointOnShape1(i);
P2 = dst.PointOnShape2(i);
-
+
theDoubles->Append(P1.X());
theDoubles->Append(P1.Y());
theDoubles->Append(P1.Z());
theDoubles->Append(P2.X());
theDoubles->Append(P2.Y());
theDoubles->Append(P2.Z());
-
- Standard_Real Dist = P1.Distance(P2);
- singularBetter = singularBetter && dist < Dist;
+
+ Standard_Real Dist = P1.Distance(P2);
+ singularBetter = singularBetter && dist < Dist;
}
}
Standard_EXPORT Handle(GEOM_Object) GetCentreOfMass (Handle(GEOM_Object) theShape);
Standard_EXPORT Handle(GEOM_Object) GetVertexByIndex (Handle(GEOM_Object) theShape,
- Standard_Integer theIndex);
+ Standard_Integer theIndex,
+ Standard_Boolean theUseOri);
Standard_EXPORT Handle(GEOM_Object) GetNormal (Handle(GEOM_Object) theFace,
Handle(GEOM_Object) theOptionalPoint);
Handle(TColStd_HSequenceOfInteger)& theIntersections);
Standard_EXPORT bool CheckSelfIntersectionsFast (Handle(GEOM_Object) theShape,
- float deflection,
- double tolerance,
- Handle(TColStd_HSequenceOfInteger)& theIntersections);
+ float deflection,
+ double tolerance,
+ Handle(TColStd_HSequenceOfInteger)& theIntersections);
Standard_EXPORT bool CheckBOPArguments (const Handle(GEOM_Object) &theShape);
}
int index = aCI.GetIndex();
+ bool useOri = aCI.GetUseOri();
gp_Pnt aVertex;
if (aShapeBase.ShapeType() == TopAbs_VERTEX) {
Standard_NullObject::Raise("Vertex index is out of range");
else
aVertex = BRep_Tool::Pnt(TopoDS::Vertex(aShapeBase));
- } else if (aShapeBase.ShapeType() == TopAbs_EDGE) {
- TopoDS_Vertex aV1, aV2;
- TopoDS_Edge anEdgeE = TopoDS::Edge(aShapeBase);
-
- TopExp::Vertices(anEdgeE, aV1, aV2);
- gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
- gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
-
+ }
+ else if (aShapeBase.ShapeType() == TopAbs_EDGE) {
if (index < 0 || index > 1)
Standard_NullObject::Raise("Vertex index is out of range");
- if ( ( anEdgeE.Orientation() == TopAbs_FORWARD && index == 0 ) ||
- ( anEdgeE.Orientation() == TopAbs_REVERSED && index == 1 ) )
- aVertex = aP1;
- else
- aVertex = aP2;
- } else if (aShapeBase.ShapeType() == TopAbs_WIRE) {
+ TopoDS_Edge anEdgeE = TopoDS::Edge(aShapeBase);
+ if ( anEdgeE.Orientation() != TopAbs_FORWARD &&
+ anEdgeE.Orientation() != TopAbs_REVERSED )
+ anEdgeE.Orientation( TopAbs_FORWARD );
+
+ TopoDS_Vertex aV[2];
+ TopExp::Vertices(anEdgeE, aV[0], aV[1], useOri );
+ aVertex = BRep_Tool::Pnt( aV[ index ]);
+ }
+ else if (aShapeBase.ShapeType() == TopAbs_WIRE) {
TopTools_IndexedMapOfShape anEdgeShapes;
TopTools_IndexedMapOfShape aVertexShapes;
TopoDS_Vertex aV1, aV2;
if (index < 0 || index > aVertexShapes.Extent())
Standard_NullObject::Raise("Vertex index is out of range");
- if (aWire.Orientation() == TopAbs_FORWARD)
+ if ( aWire.Orientation() == TopAbs_FORWARD || !useOri )
aVertex = BRep_Tool::Pnt(TopoDS::Vertex(aVertexShapes(index+1)));
else
aVertex = BRep_Tool::Pnt(TopoDS::Vertex(aVertexShapes(aVertexShapes.Extent() - index)));
- } else {
+ }
+ else {
Standard_NullObject::Raise("Shape for vertex calculation is not an edge or wire");
}
theOperationName = "GetVertexByIndex";
AddParam( theParams, "Object", aCI.GetBase() );
AddParam( theParams, "Index", aCI.GetIndex() );
+ AddParam( theParams, "Oriented", aCI.GetUseOri() );
break;
case VECTOR_FACE_NORMALE:
theOperationName = "NORMALE";
return info._retn();
}
+
+//================================================================================
+/*!
+ * \brief Return the engine creating this object
+ */
+//================================================================================
+
+GEOM::GEOM_Gen_ptr GEOM_BaseObject_i::GetGen()
+{
+ return GEOM::GEOM_Gen::_duplicate( _engine );
+}
virtual GEOM::CreationInformationSeq* GetCreationInformation();
+ virtual GEOM::GEOM_Gen_ptr GetGen();
+
Handle(::GEOM_BaseObject) GetImpl() { return _impl; }
protected:
* GetVertexByIndex
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetVertexByIndex
- (GEOM::GEOM_Object_ptr theShape, CORBA::Long theIndex)
+GEOM::GEOM_Object_ptr
+GEOM_IMeasureOperations_i::GetVertexByIndex( GEOM::GEOM_Object_ptr theShape,
+ CORBA::Long theIndex,
+ CORBA::Boolean theUseOri )
{
GEOM::GEOM_Object_var aGEOMObject;
if ( aShape.IsNull() ) return aGEOMObject._retn();
// Get vertex by index
- Handle(::GEOM_Object) anObject = GetOperations()->GetVertexByIndex(aShape, theIndex);
+ Handle(::GEOM_Object) anObject = GetOperations()->GetVertexByIndex(aShape, theIndex, theUseOri);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
GEOM::GEOM_Object_ptr theOptionalPoint);
GEOM::GEOM_Object_ptr GetVertexByIndex (GEOM::GEOM_Object_ptr theObject,
- CORBA::Long theIndex);
+ CORBA::Long theIndex,
+ CORBA::Boolean theUseOri);
void GetInertia (GEOM::GEOM_Object_ptr theShape,
CORBA::Double& I11, CORBA::Double& I12, CORBA::Double& I13,
self._autoPublish(anObj, theName, "centerOfMass")
return anObj
- ## Get a vertex sub-shape by index depended with orientation.
+ ## Get a vertex sub-shape by index.
# @param theShape Shape to find sub-shape.
# @param theIndex Index to find vertex by this index (starting from zero)
+ # @param theUseOri To consider edge/wire orientation or not
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
# @ref tui_measurement_tools_page "Example"
@ManageTransactions("MeasuOp")
- def GetVertexByIndex(self, theShape, theIndex, theName=None):
+ def GetVertexByIndex(self, theShape, theIndex, theUseOri=True, theName=None):
"""
- Get a vertex sub-shape by index depended with orientation.
+ Get a vertex sub-shape by index.
Parameters:
theShape Shape to find sub-shape.
theIndex Index to find vertex by this index (starting from zero)
+ theUseOri To consider edge/wire orientation or not
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
New GEOM.GEOM_Object, containing the created vertex.
"""
# Example: see GEOM_TestMeasures.py
- anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex)
+ if isinstance( theUseOri, str ): # theUseOri was inserted before theName
+ theUseOri, theName = True, theUseOri
+ anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex, theUseOri)
RaiseIfFailed("GetVertexByIndex", self.MeasuOp)
self._autoPublish(anObj, theName, "vertex")
return anObj
"""
# Example: see GEOM_TestMeasures.py
# note: auto-publishing is done in self.GetVertexByIndex()
- return self.GetVertexByIndex(theShape, 0, theName)
+ return self.GetVertexByIndex(theShape, 0, True, theName)
## Get the last vertex of wire/edge depended orientation.
# @param theShape Shape to find last vertex.
# Example: see GEOM_TestMeasures.py
nb_vert = self.NumberOfSubShapes(theShape, self.ShapeType["VERTEX"])
# note: auto-publishing is done in self.GetVertexByIndex()
- return self.GetVertexByIndex(theShape, (nb_vert-1), theName)
+ return self.GetVertexByIndex(theShape, (nb_vert-1), True, theName)
## Get a normale to the given face. If the point is not given,
# the normale is calculated at the center of mass.