Merge branch 'shaper2smesh'

This commit is contained in:
vsr 2020-02-21 14:50:40 +03:00
commit d05f7ac43d
12 changed files with 97 additions and 42 deletions

View File

@ -258,6 +258,7 @@ module GEOM
typedef sequence<ListOfDouble> ListOfListOfDouble;
typedef sequence<ListOfLong> ListOfListOfLong;
interface GEOM_Gen;
interface GEOM_Object;
interface GEOM_BaseObject;
interface GEOM_Field;
@ -359,6 +360,11 @@ module GEOM
* \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
@ -503,6 +509,12 @@ module GEOM
*/
GEOM_Object GetMainShape();
/*
* \brief Returns true if the current object has connection to a parametrical model
* which can be modified by parameters change.
*/
boolean IsParametrical();
};
//# GEOM_Field
@ -4366,12 +4378,13 @@ module GEOM
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.
@ -5136,6 +5149,11 @@ module GEOM
inout string_array theSubEntries,
inout string_array theOtherEntries);
/*
* \brief Breaks links to parametrical mode for parametrical shape
*/
void BreakLink(in string theEntry);
};
};

View File

@ -24,15 +24,13 @@
//
#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:
@ -52,6 +50,12 @@ class GEOMImpl_IMeasure
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;

View File

@ -850,7 +850,8 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex
(Handle(GEOM_Object) theShape,
Standard_Integer theIndex)
Standard_Integer theIndex,
Standard_Boolean theUseOri)
{
SetErrorCode(KO);
@ -873,6 +874,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex
GEOMImpl_IMeasure aCI (aFunction);
aCI.SetBase(aRefShape);
aCI.SetIndex(theIndex);
aCI.SetUseOri(theUseOri);
//Compute
try {
@ -888,7 +890,10 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex
}
//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;
@ -2139,16 +2144,16 @@ Standard_Integer GEOMImpl_IMeasureOperations::ClosestPoints (Handle(GEOM_Object)
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;
}
}

View File

@ -113,7 +113,8 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
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);
@ -162,9 +163,9 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
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);

View File

@ -154,6 +154,7 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(Handle(TFunction_Logbook)& log)
}
int index = aCI.GetIndex();
bool useOri = aCI.GetUseOri();
gp_Pnt aVertex;
if (aShapeBase.ShapeType() == TopAbs_VERTEX) {
@ -161,23 +162,21 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(Handle(TFunction_Logbook)& log)
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;
@ -198,11 +197,12 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(Handle(TFunction_Logbook)& log)
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");
}
@ -352,6 +352,7 @@ GetCreationInformation(std::string& theOperationName,
theOperationName = "GetVertexByIndex";
AddParam( theParams, "Object", aCI.GetBase() );
AddParam( theParams, "Index", aCI.GetIndex() );
AddParam( theParams, "Oriented", aCI.GetUseOri() );
break;
case VECTOR_FACE_NORMALE:
theOperationName = "NORMALE";

View File

@ -312,3 +312,14 @@ GEOM::CreationInformationSeq* GEOM_BaseObject_i::GetCreationInformation()
return info._retn();
}
//================================================================================
/*!
* \brief Return the engine creating this object
*/
//================================================================================
GEOM::GEOM_Gen_ptr GEOM_BaseObject_i::GetGen()
{
return GEOM::GEOM_Gen::_duplicate( _engine );
}

View File

@ -66,6 +66,8 @@ class GEOM_I_EXPORT GEOM_BaseObject_i : public virtual POA_GEOM::GEOM_BaseObject
virtual GEOM::CreationInformationSeq* GetCreationInformation();
virtual GEOM::GEOM_Gen_ptr GetGen();
Handle(::GEOM_BaseObject) GetImpl() { return _impl; }
protected:

View File

@ -385,6 +385,9 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
void LoadPlugin(const std::string& theLibName);
virtual void BreakLink(const char*) {}
private:
::GEOMImpl_Gen* _impl;

View File

@ -440,8 +440,10 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetCentreOfMass
* 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;
@ -453,7 +455,7 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetVertexByIndex
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();

View File

@ -63,7 +63,8 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
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,

View File

@ -81,6 +81,9 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public
virtual bool IsShape();
virtual bool IsParametrical() { return false; }
Handle(::GEOM_Object) GetImpl() { return _impl; }
private:

View File

@ -11325,9 +11325,10 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
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.
@ -11336,13 +11337,14 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
#
# @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.
@ -11351,7 +11353,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
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
@ -11380,7 +11384,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
"""
# 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.
@ -11407,7 +11411,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
# 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.