mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-26 01:10:36 +05:00
0022757: [EDF] Vertex on Edge
This commit is contained in:
parent
d632c33a6e
commit
0c260c9c89
@ -6,6 +6,8 @@ import GEOM
|
|||||||
from salome.geom import geomBuilder
|
from salome.geom import geomBuilder
|
||||||
geompy = geomBuilder.New(salome.myStudy)
|
geompy = geomBuilder.New(salome.myStudy)
|
||||||
|
|
||||||
|
# Variant 1: using DivideEdge()
|
||||||
|
|
||||||
# create vertices
|
# create vertices
|
||||||
p1 = geompy.MakeVertex(0,0,50)
|
p1 = geompy.MakeVertex(0,0,50)
|
||||||
p2 = geompy.MakeVertex(60,0,50)
|
p2 = geompy.MakeVertex(60,0,50)
|
||||||
@ -27,4 +29,14 @@ edge_points = geompy.SubShapeAllSortedCentres(divide, geompy.ShapeType["VERTEX"]
|
|||||||
for point in edge_points:
|
for point in edge_points:
|
||||||
geompy.addToStudyInFather(divide, point, "Edge's point after divide")
|
geompy.addToStudyInFather(divide, point, "Edge's point after divide")
|
||||||
|
|
||||||
|
|
||||||
|
# Variant 2: using DivideEdgeByPoint()
|
||||||
|
|
||||||
|
box = geompy.MakeBox(0,0,0, 10,10,10, theName="box")
|
||||||
|
p = geompy.MakeVertex( 3, -2, 1, theName="point to project" )
|
||||||
|
edge = geompy.GetEdgeNearPoint( box, p, theName="edge to split")
|
||||||
|
|
||||||
|
div = geompy.DivideEdgeByPoint( box, edge, p, theName="box (edge divided)")
|
||||||
|
|
||||||
|
|
||||||
salome.sg.updateObjBrowser(1)
|
salome.sg.updateObjBrowser(1)
|
||||||
|
BIN
doc/salome/gui/GEOM/images/divedgebypoint.png
Normal file
BIN
doc/salome/gui/GEOM/images/divedgebypoint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
doc/salome/gui/GEOM/images/repair8.png
Executable file → Normal file
BIN
doc/salome/gui/GEOM/images/repair8.png
Executable file → Normal file
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 19 KiB |
@ -5,25 +5,29 @@
|
|||||||
\n To <b>Add Point on Edge</b> in the <b>Main Menu</b> select
|
\n To <b>Add Point on Edge</b> in the <b>Main Menu</b> select
|
||||||
<b>Repair - > Add Point on Edge</b>.
|
<b>Repair - > Add Point on Edge</b>.
|
||||||
|
|
||||||
\n This operation splits an edge in two new edges in accordance with the
|
This operation splits an edge in two new edges.
|
||||||
specified mode (by length or by parameter) and a value specifying the
|
This operation is available in <b>OCC Viewer</b> only.
|
||||||
position of the point on edge (for example val =0.5; mode =
|
|
||||||
by length). This operation is available in <b>OCC Viewer</b> only.
|
|
||||||
|
|
||||||
\n The \b Result will be a \b GEOM_Object.
|
The \b Result will be a \b GEOM_Object.
|
||||||
|
|
||||||
\n <b>TUI Command:</b> <em>geompy.DivideEdge(Shape, EdgeID, Value,
|
\n Location of a new vertex on a selected edge can be defined two ways:
|
||||||
|
<ol>
|
||||||
|
<li> We can specify a position (ranging from 0.0 to 1.0) of the
|
||||||
|
vertex on the selected edge either by length or by parameter.
|
||||||
|
<p>
|
||||||
|
<b>TUI Command:</b> <em>geompy.DivideEdge(Shape, EdgeID, Value,
|
||||||
IsByParameter)</em>
|
IsByParameter)</em>
|
||||||
- \em Shape is a shape which contains an edge to be divided
|
<ul>
|
||||||
- \em EdgeID is the ID of the edge to be divided, if it is = -1,
|
<li> \em Shape is a shape which contains an edge to be divided</li>
|
||||||
then \em Shape should be an edge itself
|
<li>\em EdgeID is the ID of the edge to be divided, if it is = -1,
|
||||||
- \em Value is a value of parameter on edge or length parameter,
|
then \em Shape should be an edge itself.</li>
|
||||||
depending on \em IsByParameter.
|
<li> \em Value is a value of parameter on edge or length parameter,
|
||||||
- \em IsByParameter is a boolean flag, specifying operation mode:
|
depending on \em IsByParameter. </li>
|
||||||
|
<li> \em IsByParameter is a boolean flag, specifying operation mode:
|
||||||
- \c True: \em Value is treated as a curve parameter [0..1]
|
- \c True: \em Value is treated as a curve parameter [0..1]
|
||||||
- \c False: \em Value is treated as a length parameter [0..1]
|
- \c False: \em Value is treated as a length parameter [0..1] </li>
|
||||||
|
</ul>
|
||||||
<b>Arguments:</b> Name + 1 Edge + 1 Value setting the position of
|
\b Arguments: Name + 1 Edge + 1 Value setting the position of
|
||||||
the point according to one of the selected modes.
|
the point according to one of the selected modes.
|
||||||
|
|
||||||
The difference between "by parameter" and "by length" modes becomes
|
The difference between "by parameter" and "by length" modes becomes
|
||||||
@ -35,6 +39,24 @@ in the middle of this edge (equidistant from both its ends); the same
|
|||||||
one of the ends (depending on the actual parametrization).
|
one of the ends (depending on the actual parametrization).
|
||||||
|
|
||||||
\image html repair8.png
|
\image html repair8.png
|
||||||
|
\n\n
|
||||||
|
</li>
|
||||||
|
<li>We can select a point that will be projected to the selected
|
||||||
|
edge to find the location of the new vertex.
|
||||||
|
<p>
|
||||||
|
<b>TUI Command:</b> <em>geompy.DivideEdgeByPoint(Shape, Edge, Point)</em>
|
||||||
|
<ul>
|
||||||
|
<li> \em Shape is a shape which contains an edge to be divided</li>
|
||||||
|
<li>\em Edge is an edge to be divided (or it's ID, if it is = -1,
|
||||||
|
then \em Shape should be an edge itself).</li>
|
||||||
|
<li> \em Point is a point to project to \a Edge. </li>
|
||||||
|
</ul>
|
||||||
|
\b Arguments: Name + 1 Edge + 1 Point.
|
||||||
|
|
||||||
|
\image html divedgebypoint.png
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
\n <b>Example:</b>
|
\n <b>Example:</b>
|
||||||
|
|
||||||
|
@ -3722,7 +3722,7 @@ module GEOM
|
|||||||
GEOM_Object RemoveInternalFaces (in ListOfGO theSolids);
|
GEOM_Object RemoveInternalFaces (in ListOfGO theSolids);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Addition of a point to a given edge object.
|
* \brief Addition of a point to a given edge of \a theObject.
|
||||||
* \param theObject Shape to be processed.
|
* \param theObject Shape to be processed.
|
||||||
* \param theEdgeIndex Index of edge to be divided within theObject's shape,
|
* \param theEdgeIndex Index of edge to be divided within theObject's shape,
|
||||||
* if -1, then theObject itself is the edge.
|
* if -1, then theObject itself is the edge.
|
||||||
@ -3730,11 +3730,24 @@ module GEOM
|
|||||||
* depending on \a isByParameter.
|
* depending on \a isByParameter.
|
||||||
* \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
|
* \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
|
||||||
* if FALSE : \a theValue is treated as a length parameter [0..1]
|
* if FALSE : \a theValue is treated as a length parameter [0..1]
|
||||||
* \return New GEOM_Object, containing processed shape.
|
* \return New GEOM_Object, containing the processed shape.
|
||||||
*/
|
*/
|
||||||
GEOM_Object DivideEdge (in GEOM_Object theObject, in short theEdgeIndex,
|
GEOM_Object DivideEdge (in GEOM_Object theObject, in short theEdgeIndex,
|
||||||
in double theValue, in boolean isByParameter);
|
in double theValue, in boolean isByParameter);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Addition of a point to a given edge of \a theObject by projecting
|
||||||
|
* another point to the given edge.
|
||||||
|
* \param theObject Shape to be processed.
|
||||||
|
* \param theEdgeIndex Index of edge to be divided within theObject's shape,
|
||||||
|
* if -1, then theObject itself is the edge.
|
||||||
|
* \param thePoint Point to project to theEdgeIndex-th edge.
|
||||||
|
* \return New GEOM_Object, containing the processed shape.
|
||||||
|
*/
|
||||||
|
GEOM_Object DivideEdgeByPoint (in GEOM_Object theObject,
|
||||||
|
in short theEdgeIndex,
|
||||||
|
in GEOM_Object thePoint);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Suppress the vertices in the wire in case if adjacent edges are C1 continuous.
|
* \brief Suppress the vertices in the wire in case if adjacent edges are C1 continuous.
|
||||||
* \param theWire Wire to minimize the number of C1 continuous edges in.
|
* \param theWire Wire to minimize the number of C1 continuous edges in.
|
||||||
|
@ -145,6 +145,7 @@ SET( _res_files
|
|||||||
planeworkingorigin.png
|
planeworkingorigin.png
|
||||||
point2.png
|
point2.png
|
||||||
pointonedge.png
|
pointonedge.png
|
||||||
|
pointonedgebypoint.png
|
||||||
pointonface.png
|
pointonface.png
|
||||||
point_line_intersection.png
|
point_line_intersection.png
|
||||||
polyline.png
|
polyline.png
|
||||||
|
BIN
resources/pointonedgebypoint.png
Normal file
BIN
resources/pointonedgebypoint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 444 B |
@ -291,6 +291,10 @@
|
|||||||
<source>ICON_DLG_DIVIDE_EDGE</source>
|
<source>ICON_DLG_DIVIDE_EDGE</source>
|
||||||
<translation>pointonedge.png</translation>
|
<translation>pointonedge.png</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>ICON_DLG_DIVIDE_EDGE_BY_PNT</source>
|
||||||
|
<translation>pointonedgebypoint.png</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>ICON_DLG_ELLIPSE_PV</source>
|
<source>ICON_DLG_ELLIPSE_PV</source>
|
||||||
<translation>ellipsepointvector.png</translation>
|
<translation>ellipsepointvector.png</translation>
|
||||||
|
@ -38,6 +38,14 @@ Do you still want to delete these objects?</translation>
|
|||||||
<source>DEVIDE_EDGE_NEW_OBJECT_NAME</source>
|
<source>DEVIDE_EDGE_NEW_OBJECT_NAME</source>
|
||||||
<translation>NewObject</translation>
|
<translation>NewObject</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>DEVIDE_EDGE_BAD_PROJ_MSG</source>
|
||||||
|
<translation>Projection outside the edge</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>DEVIDE_EDGE_BY_PROJ_POINT</source>
|
||||||
|
<translation>Point to project</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>ERROR_SHAPE_TYPE</source>
|
<source>ERROR_SHAPE_TYPE</source>
|
||||||
<translation>Object of incorrect type selected!
|
<translation>Object of incorrect type selected!
|
||||||
|
@ -145,6 +145,7 @@ Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
|
|||||||
RemoveInternalFaces(&HI, anOriginalShape, aShape);
|
RemoveInternalFaces(&HI, anOriginalShape, aShape);
|
||||||
break;
|
break;
|
||||||
case DIVIDE_EDGE:
|
case DIVIDE_EDGE:
|
||||||
|
case DIVIDE_EDGE_BY_POINT:
|
||||||
AddPointOnEdge(&HI, anOriginalShape, aShape);
|
AddPointOnEdge(&HI, anOriginalShape, aShape);
|
||||||
break;
|
break;
|
||||||
case CHANGE_ORIENTATION:
|
case CHANGE_ORIENTATION:
|
||||||
@ -541,18 +542,36 @@ Standard_Boolean GEOMImpl_HealingDriver::AddPointOnEdge (GEOMImpl_IHealing* theH
|
|||||||
Standard_Integer anIndex = theHI->GetIndex();
|
Standard_Integer anIndex = theHI->GetIndex();
|
||||||
Standard_Real aValue = theHI->GetDevideEdgeValue();
|
Standard_Real aValue = theHI->GetDevideEdgeValue();
|
||||||
|
|
||||||
|
TopoDS_Shape pointToProject;
|
||||||
|
{
|
||||||
|
Handle(TColStd_HSequenceOfTransient) funs = theHI->GetShapes();
|
||||||
|
if ( !funs.IsNull() && funs->Length() > 0 ) {
|
||||||
|
Handle(GEOM_Function) fun = Handle(GEOM_Function)::DownCast( funs->Value(1) );
|
||||||
|
if ( !fun.IsNull() )
|
||||||
|
pointToProject = fun->GetValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ShHealOper_EdgeDivide aHealer (theOriginalShape);
|
ShHealOper_EdgeDivide aHealer (theOriginalShape);
|
||||||
|
|
||||||
Standard_Boolean aResult = Standard_False;
|
Standard_Boolean aResult = Standard_False;
|
||||||
if (anIndex == -1) { // apply algorythm for the whole shape which is EDGE
|
if (anIndex == -1) { // apply algorithm for the whole shape which is EDGE
|
||||||
if (theOriginalShape.ShapeType() == TopAbs_EDGE)
|
if (theOriginalShape.ShapeType() == TopAbs_EDGE) {
|
||||||
|
if ( pointToProject.IsNull() )
|
||||||
aResult = aHealer.Perform(TopoDS::Edge(theOriginalShape), aValue, isByParameter);
|
aResult = aHealer.Perform(TopoDS::Edge(theOriginalShape), aValue, isByParameter);
|
||||||
|
else
|
||||||
|
aResult = aHealer.Perform(TopoDS::Edge(theOriginalShape), pointToProject);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
TopTools_IndexedMapOfShape aShapes;
|
TopTools_IndexedMapOfShape aShapes;
|
||||||
TopExp::MapShapes(theOriginalShape, aShapes);
|
TopExp::MapShapes(theOriginalShape, aShapes);
|
||||||
TopoDS_Shape aEdgeShape = aShapes.FindKey(anIndex);
|
TopoDS_Shape aEdgeShape = aShapes.FindKey(anIndex);
|
||||||
if (aEdgeShape.ShapeType() == TopAbs_EDGE)
|
if (aEdgeShape.ShapeType() == TopAbs_EDGE) {
|
||||||
|
if ( pointToProject.IsNull() )
|
||||||
aResult = aHealer.Perform(TopoDS::Edge(aEdgeShape), aValue, isByParameter);
|
aResult = aHealer.Perform(TopoDS::Edge(aEdgeShape), aValue, isByParameter);
|
||||||
|
else
|
||||||
|
aResult = aHealer.Perform(TopoDS::Edge(aEdgeShape), pointToProject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aResult)
|
if (aResult)
|
||||||
@ -946,6 +965,14 @@ GetCreationInformation(std::string& theOperationName,
|
|||||||
AddParam( theParams, "By parameter", aCI.GetIsByParameter() );
|
AddParam( theParams, "By parameter", aCI.GetIsByParameter() );
|
||||||
AddParam( theParams, "Value", aCI.GetDevideEdgeValue() );
|
AddParam( theParams, "Value", aCI.GetDevideEdgeValue() );
|
||||||
break;
|
break;
|
||||||
|
case DIVIDE_EDGE_BY_POINT:
|
||||||
|
theOperationName = "POINT_ON_EDGE";
|
||||||
|
if ( aCI.GetIndex() > 0 )
|
||||||
|
AddParam( theParams, "Edge", "#" ) << aCI.GetIndex() << " of " << aCI.GetOriginal();
|
||||||
|
else
|
||||||
|
AddParam( theParams, "Edge", aCI.GetOriginal() );
|
||||||
|
AddParam( theParams, "Point", aCI.GetShapes() );
|
||||||
|
break;
|
||||||
case CHANGE_ORIENTATION:
|
case CHANGE_ORIENTATION:
|
||||||
theOperationName = "CHANGE_ORIENTATION";
|
theOperationName = "CHANGE_ORIENTATION";
|
||||||
AddParam( theParams, "Selected shape", aCI.GetOriginal() );
|
AddParam( theParams, "Selected shape", aCI.GetOriginal() );
|
||||||
|
@ -764,6 +764,70 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object)
|
|||||||
return aNewObject;
|
return aNewObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* DivideEdgeByPoint
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
Handle(GEOM_Object)
|
||||||
|
GEOMImpl_IHealingOperations::DivideEdgeByPoint (Handle(GEOM_Object) theObject,
|
||||||
|
int theIndex,
|
||||||
|
Handle(GEOM_Object) thePoint)
|
||||||
|
{
|
||||||
|
// set error code, check parameters
|
||||||
|
SetErrorCode(KO);
|
||||||
|
|
||||||
|
if (theObject.IsNull() || thePoint.IsNull())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
|
||||||
|
Handle(GEOM_Function) aPointFunc = thePoint->GetLastFunction();
|
||||||
|
if (aLastFunction.IsNull() || aPointFunc.IsNull())
|
||||||
|
return NULL; //There is no function which creates an object to be processed
|
||||||
|
|
||||||
|
// Add a new object
|
||||||
|
Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
|
||||||
|
|
||||||
|
//Add the function
|
||||||
|
aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE_BY_POINT);
|
||||||
|
|
||||||
|
if (aFunction.IsNull()) return NULL;
|
||||||
|
|
||||||
|
//Check if the function is set correctly
|
||||||
|
if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
|
||||||
|
|
||||||
|
// prepare "data container" class IHealing
|
||||||
|
GEOMImpl_IHealing HI(aFunction);
|
||||||
|
HI.SetIndex( theIndex );
|
||||||
|
HI.SetOriginal( aLastFunction );
|
||||||
|
|
||||||
|
Handle(TColStd_HSequenceOfTransient) funSeq = new TColStd_HSequenceOfTransient;
|
||||||
|
funSeq->Append( aPointFunc );
|
||||||
|
HI.SetShapes( funSeq );
|
||||||
|
|
||||||
|
//Compute the translation
|
||||||
|
try {
|
||||||
|
OCC_CATCH_SIGNALS;
|
||||||
|
if (!GetSolver()->ComputeFunction(aFunction)) {
|
||||||
|
SetErrorCode("Healing driver failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Standard_Failure) {
|
||||||
|
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||||
|
SetErrorCode(aFail->GetMessageString());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Make a Python command
|
||||||
|
GEOM::TPythonDump(aFunction)
|
||||||
|
<< aNewObject << " = geompy.DivideEdgeByPoint(" << theObject
|
||||||
|
<< ", " << theIndex << ", " << thePoint << ")";
|
||||||
|
|
||||||
|
SetErrorCode(OK);
|
||||||
|
return aNewObject;
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* FuseCollinearEdgesWithinWire
|
* FuseCollinearEdgesWithinWire
|
||||||
|
@ -81,6 +81,10 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
|
|||||||
double theValue,
|
double theValue,
|
||||||
bool isByParameter );
|
bool isByParameter );
|
||||||
|
|
||||||
|
Standard_EXPORT Handle(GEOM_Object) DivideEdgeByPoint( Handle(GEOM_Object) theObject,
|
||||||
|
int theIndex,
|
||||||
|
Handle(GEOM_Object) thePoint );
|
||||||
|
|
||||||
Standard_EXPORT Handle(GEOM_Object) FuseCollinearEdgesWithinWire
|
Standard_EXPORT Handle(GEOM_Object) FuseCollinearEdgesWithinWire
|
||||||
(Handle(GEOM_Object) theWire,
|
(Handle(GEOM_Object) theWire,
|
||||||
std::list<Handle(GEOM_Object)> theVertices);
|
std::list<Handle(GEOM_Object)> theVertices);
|
||||||
|
@ -321,6 +321,7 @@
|
|||||||
#define FUSE_COLLINEAR_EDGES 10
|
#define FUSE_COLLINEAR_EDGES 10
|
||||||
#define SEWING_NON_MANIFOLD 11
|
#define SEWING_NON_MANIFOLD 11
|
||||||
#define REMOVE_INTERNAL_FACES 12
|
#define REMOVE_INTERNAL_FACES 12
|
||||||
|
#define DIVIDE_EDGE_BY_POINT 13
|
||||||
|
|
||||||
#define BASIC_FILLING 1
|
#define BASIC_FILLING 1
|
||||||
|
|
||||||
|
@ -431,6 +431,40 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::DivideEdge (GEOM::GEOM_Object_p
|
|||||||
return GetObject(aNewObject);
|
return GetObject(aNewObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* DivideEdgeByPoint
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
GEOM::GEOM_Object_ptr
|
||||||
|
GEOM_IHealingOperations_i::DivideEdgeByPoint (GEOM::GEOM_Object_ptr theObject,
|
||||||
|
CORBA::Short theIndex,
|
||||||
|
GEOM::GEOM_Object_ptr thePoint)
|
||||||
|
{
|
||||||
|
GEOM::GEOM_Object_var aGEOMObject;
|
||||||
|
|
||||||
|
// Set a not done flag
|
||||||
|
GetOperations()->SetNotDone();
|
||||||
|
|
||||||
|
// Get the object itself
|
||||||
|
Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
|
||||||
|
if (anObject.IsNull())
|
||||||
|
return aGEOMObject._retn();
|
||||||
|
|
||||||
|
// Get the point
|
||||||
|
Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
|
||||||
|
if (aPoint.IsNull())
|
||||||
|
return aGEOMObject._retn();
|
||||||
|
|
||||||
|
// Perform
|
||||||
|
Handle(GEOM_Object) aNewObject =
|
||||||
|
GetOperations()->DivideEdgeByPoint( anObject, theIndex, aPoint );
|
||||||
|
if (!GetOperations()->IsDone() || aNewObject.IsNull())
|
||||||
|
return aGEOMObject._retn();
|
||||||
|
|
||||||
|
return GetObject(aNewObject);
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* FuseCollinearEdgesWithinWire
|
* FuseCollinearEdgesWithinWire
|
||||||
|
@ -82,6 +82,10 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i :
|
|||||||
CORBA::Double theValue,
|
CORBA::Double theValue,
|
||||||
CORBA::Boolean isByParameter);
|
CORBA::Boolean isByParameter);
|
||||||
|
|
||||||
|
GEOM::GEOM_Object_ptr DivideEdgeByPoint (GEOM::GEOM_Object_ptr theObject,
|
||||||
|
CORBA::Short theIndex,
|
||||||
|
GEOM::GEOM_Object_ptr thePoint);
|
||||||
|
|
||||||
GEOM::GEOM_Object_ptr FuseCollinearEdgesWithinWire (GEOM::GEOM_Object_ptr theWire,
|
GEOM::GEOM_Object_ptr FuseCollinearEdgesWithinWire (GEOM::GEOM_Object_ptr theWire,
|
||||||
const GEOM::ListOfGO& theVertices);
|
const GEOM::ListOfGO& theVertices);
|
||||||
|
|
||||||
|
@ -323,6 +323,12 @@ def TestDivideEdge (geompy):
|
|||||||
Id_Box = geompy.addToStudy(Box, "Box")
|
Id_Box = geompy.addToStudy(Box, "Box")
|
||||||
Id_Divide = geompy.addToStudy(Divide, "Box with Divided Edge")
|
Id_Divide = geompy.addToStudy(Divide, "Box with Divided Edge")
|
||||||
|
|
||||||
|
# using geompy.DivideEdgeByPoint()
|
||||||
|
p = geompy.MakeVertex( 30, -5, 10, theName="Point to project" )
|
||||||
|
edge = geompy.GetEdgeNearPoint( Box, p, theName="Edge to split")
|
||||||
|
div = geompy.DivideEdgeByPoint( Box, edge, p, theName="Box (edge divided)")
|
||||||
|
assert geompy.NumberOfEdges( Box ) == geompy.NumberOfEdges( div ) - 1
|
||||||
|
|
||||||
def TestFuseEdges (geompy):
|
def TestFuseEdges (geompy):
|
||||||
|
|
||||||
# create vertices
|
# create vertices
|
||||||
|
@ -6609,6 +6609,45 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
|||||||
self._autoPublish(anObj, theName, "divideEdge")
|
self._autoPublish(anObj, theName, "divideEdge")
|
||||||
return anObj
|
return anObj
|
||||||
|
|
||||||
|
## Addition of a point to a given edge of \a theObject by projecting
|
||||||
|
# another point to the given edge.
|
||||||
|
# @param theObject Shape to be processed.
|
||||||
|
# @param theEdgeIndex Index of edge to be divided within theObject's shape,
|
||||||
|
# if -1, then theObject itself is the edge.
|
||||||
|
# @param thePoint Point to project to theEdgeIndex-th edge.
|
||||||
|
# @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.
|
||||||
|
#
|
||||||
|
# @return New GEOM.GEOM_Object, containing processed shape.
|
||||||
|
#
|
||||||
|
# @ref tui_add_point_on_edge "Example"
|
||||||
|
@ManageTransactions("HealOp")
|
||||||
|
def DivideEdgeByPoint(self, theObject, theEdgeIndex, thePoint, theName=None):
|
||||||
|
"""
|
||||||
|
Addition of a point to a given edge of \a theObject by projecting
|
||||||
|
another point to the given edge.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
theObject Shape to be processed.
|
||||||
|
theEdgeIndex The edge or its index to be divided within theObject's shape,
|
||||||
|
if -1, then theObject itself is the edge.
|
||||||
|
thePoint Point to project to theEdgeIndex-th edge.
|
||||||
|
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.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
New GEOM.GEOM_Object, containing processed shape.
|
||||||
|
"""
|
||||||
|
# Example: see GEOM_TestHealing.py
|
||||||
|
if isinstance( theEdgeIndex, GEOM._objref_GEOM_Object ):
|
||||||
|
theEdgeIndex = self.GetSubShapeID( theObject, theEdgeIndex )
|
||||||
|
anObj = self.HealOp.DivideEdgeByPoint(theObject, theEdgeIndex, thePoint)
|
||||||
|
RaiseIfFailed("DivideEdgeByPoint", self.HealOp)
|
||||||
|
self._autoPublish(anObj, theName, "divideEdge")
|
||||||
|
return anObj
|
||||||
|
|
||||||
## Suppress the vertices in the wire in case if adjacent edges are C1 continuous.
|
## Suppress the vertices in the wire in case if adjacent edges are C1 continuous.
|
||||||
# @param theWire Wire to minimize the number of C1 continuous edges in.
|
# @param theWire Wire to minimize the number of C1 continuous edges in.
|
||||||
# @param theVertices A list of vertices to suppress. If the list
|
# @param theVertices A list of vertices to suppress. If the list
|
||||||
@ -9707,7 +9746,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
|||||||
## Perform an Archimde operation on the given shape with given parameters.
|
## Perform an Archimde operation on the given shape with given parameters.
|
||||||
# The object presenting the resulting face is returned.
|
# The object presenting the resulting face is returned.
|
||||||
# @param theShape Shape to be put in water.
|
# @param theShape Shape to be put in water.
|
||||||
# @param theWeight Weight og the shape.
|
# @param theWeight Weight of the shape.
|
||||||
# @param theWaterDensity Density of the water.
|
# @param theWaterDensity Density of the water.
|
||||||
# @param theMeshDeflection Deflection of the mesh, using to compute the section.
|
# @param theMeshDeflection Deflection of the mesh, using to compute the section.
|
||||||
# @param theName Object name; when specified, this parameter is used
|
# @param theName Object name; when specified, this parameter is used
|
||||||
@ -9726,7 +9765,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
theShape Shape to be put in water.
|
theShape Shape to be put in water.
|
||||||
theWeight Weight og the shape.
|
theWeight Weight of the shape.
|
||||||
theWaterDensity Density of the water.
|
theWaterDensity Density of the water.
|
||||||
theMeshDeflection Deflection of the mesh, using to compute the section.
|
theMeshDeflection Deflection of the mesh, using to compute the section.
|
||||||
theName Object name; when specified, this parameter is used
|
theName Object name; when specified, this parameter is used
|
||||||
|
@ -38,16 +38,23 @@
|
|||||||
|
|
||||||
#include <GEOMImpl_Types.hxx>
|
#include <GEOMImpl_Types.hxx>
|
||||||
|
|
||||||
#include <TopAbs.hxx>
|
|
||||||
#include <Geom_Curve.hxx>
|
|
||||||
#include <gp_Pnt.hxx>
|
|
||||||
#include <TopoDS.hxx>
|
|
||||||
#include <TopExp.hxx>
|
|
||||||
#include <TopoDS_Edge.hxx>
|
|
||||||
#include <BRep_Tool.hxx>
|
|
||||||
#include <TopTools_IndexedMapOfShape.hxx>
|
|
||||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
#include <TColStd_IndexedMapOfInteger.hxx>
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
||||||
|
#include <TopAbs.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
enum { BY_PARAM, BY_POINT_PROJ };
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// class : RepairGUI_DivideEdgeDlg()
|
// class : RepairGUI_DivideEdgeDlg()
|
||||||
@ -61,6 +68,7 @@ RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg( GeometryGUI* theGeometryGUI, Q
|
|||||||
: GEOMBase_Skeleton( theGeometryGUI, parent, modal )
|
: GEOMBase_Skeleton( theGeometryGUI, parent, modal )
|
||||||
{
|
{
|
||||||
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DIVIDE_EDGE" ) ) );
|
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DIVIDE_EDGE" ) ) );
|
||||||
|
QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DIVIDE_EDGE_BY_PNT" ) ) );
|
||||||
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
|
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
|
||||||
|
|
||||||
setWindowTitle( tr( "GEOM_DIVIDE_EDGE_TITLE" ) );
|
setWindowTitle( tr( "GEOM_DIVIDE_EDGE_TITLE" ) );
|
||||||
@ -68,16 +76,18 @@ RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg( GeometryGUI* theGeometryGUI, Q
|
|||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
mainFrame()->GroupConstructors->setTitle(tr("GEOM_DIVIDE_EDGE_TITLE"));
|
mainFrame()->GroupConstructors->setTitle(tr("GEOM_DIVIDE_EDGE_TITLE"));
|
||||||
mainFrame()->RadioButton1->setIcon( image0 );
|
mainFrame()->RadioButton1->setIcon( image0 );
|
||||||
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
|
mainFrame()->RadioButton2->setIcon( image2 );
|
||||||
mainFrame()->RadioButton2->close();
|
|
||||||
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
|
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
|
||||||
mainFrame()->RadioButton3->close();
|
mainFrame()->RadioButton3->close();
|
||||||
|
|
||||||
GroupPoints = new DlgRef_1SelExt( centralWidget() );
|
GroupPoints = new DlgRef_2SelExt( centralWidget() );
|
||||||
GroupPoints->GroupBox1->setTitle( tr( "GEOM_ADD_POINT" ) );
|
GroupPoints->GroupBox1->setTitle( tr( "GEOM_ADD_POINT" ) );
|
||||||
GroupPoints->TextLabel1->setText( tr( "GEOM_EDGE" ) );
|
GroupPoints->TextLabel1->setText( tr( "GEOM_EDGE" ) );
|
||||||
GroupPoints->PushButton1->setIcon( image1 );
|
GroupPoints->PushButton1->setIcon( image1 );
|
||||||
GroupPoints->LineEdit1->setReadOnly( true );
|
GroupPoints->LineEdit1->setReadOnly( true );
|
||||||
|
GroupPoints->TextLabel2->setText( tr( "DEVIDE_EDGE_BY_PROJ_POINT" ) );
|
||||||
|
GroupPoints->PushButton2->setIcon( image1 );
|
||||||
|
GroupPoints->LineEdit2->setReadOnly( true );
|
||||||
|
|
||||||
QRadioButton* rb1 = new QRadioButton( tr( "GEOM_BY_PARAMETER" ), GroupPoints->Box );
|
QRadioButton* rb1 = new QRadioButton( tr( "GEOM_BY_PARAMETER" ), GroupPoints->Box );
|
||||||
QRadioButton* rb2 = new QRadioButton( tr( "GEOM_BY_LENGTH" ), GroupPoints->Box );
|
QRadioButton* rb2 = new QRadioButton( tr( "GEOM_BY_LENGTH" ), GroupPoints->Box );
|
||||||
@ -90,13 +100,13 @@ RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg( GeometryGUI* theGeometryGUI, Q
|
|||||||
myValEdt = new SalomeApp_DoubleSpinBox( GroupPoints->Box );
|
myValEdt = new SalomeApp_DoubleSpinBox( GroupPoints->Box );
|
||||||
initSpinBox( myValEdt, 0., 1., 0.1, "parametric_precision" );
|
initSpinBox( myValEdt, 0., 1., 0.1, "parametric_precision" );
|
||||||
myValEdt->setValue( 0.5 );
|
myValEdt->setValue( 0.5 );
|
||||||
QLabel* aLbl1 = new QLabel( tr( "GEOM_VALUE" ), GroupPoints->Box );
|
myValLbl = new QLabel( tr( "GEOM_VALUE" ), GroupPoints->Box );
|
||||||
|
|
||||||
QGridLayout* l = new QGridLayout( GroupPoints->Box );
|
QGridLayout* l = new QGridLayout( GroupPoints->Box );
|
||||||
l->setMargin( 0 ); l->setSpacing( 6 );
|
l->setMargin( 0 ); l->setSpacing( 6 );
|
||||||
l->addWidget( rb1, 0, 0, 1, 2 );
|
l->addWidget( rb1, 0, 0, 1, 2 );
|
||||||
l->addWidget( rb2, 1, 0, 1, 2 );
|
l->addWidget( rb2, 1, 0, 1, 2 );
|
||||||
l->addWidget( aLbl1, 2, 0 );
|
l->addWidget( myValLbl, 2, 0 );
|
||||||
l->addWidget( myValEdt, 2, 1 );
|
l->addWidget( myValEdt, 2, 1 );
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
||||||
@ -110,6 +120,29 @@ RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg( GeometryGUI* theGeometryGUI, Q
|
|||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ConstructorsClicked
|
||||||
|
//purpose : hide/show widgets depending on a selected constructor
|
||||||
|
//=======================================================================
|
||||||
|
void RepairGUI_DivideEdgeDlg::ConstructorsClicked( int constructorId )
|
||||||
|
{
|
||||||
|
myIsParameterGr->button( 0 )->setShown( constructorId == BY_PARAM );
|
||||||
|
myIsParameterGr->button( 1 )->setShown( constructorId == BY_PARAM );
|
||||||
|
myValEdt ->setShown( constructorId == BY_PARAM );
|
||||||
|
myValLbl ->setShown( constructorId == BY_PARAM );
|
||||||
|
GroupPoints->TextLabel2 ->setShown( constructorId == BY_POINT_PROJ );
|
||||||
|
GroupPoints->PushButton2 ->setShown( constructorId == BY_POINT_PROJ );
|
||||||
|
GroupPoints->LineEdit2 ->setShown( constructorId == BY_POINT_PROJ );
|
||||||
|
|
||||||
|
initSelection();
|
||||||
|
|
||||||
|
if ( constructorId == BY_PARAM &&
|
||||||
|
!GroupPoints->PushButton1->isDown() )
|
||||||
|
GroupPoints->PushButton1->click();
|
||||||
|
|
||||||
|
displayPreview();
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : ~RepairGUI_DivideEdgeDlg()
|
// function : ~RepairGUI_DivideEdgeDlg()
|
||||||
// purpose : Destroys the object and frees any allocated resources
|
// purpose : Destroys the object and frees any allocated resources
|
||||||
@ -128,25 +161,31 @@ void RepairGUI_DivideEdgeDlg::Init()
|
|||||||
myEditCurrentArgument = GroupPoints->LineEdit1;
|
myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||||
|
|
||||||
myObject = GEOM::GEOM_Object::_nil();
|
myObject = GEOM::GEOM_Object::_nil();
|
||||||
|
myPoint.nullify();
|
||||||
myIndex = -1;
|
myIndex = -1;
|
||||||
|
myProjectionOK = false;
|
||||||
|
|
||||||
//myGeomGUI->SetState( 0 );
|
//myGeomGUI->SetState( 0 );
|
||||||
initSelection();
|
|
||||||
|
|
||||||
/* signals and slots connections */
|
/* signals and slots connections */
|
||||||
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
|
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
|
||||||
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
|
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
|
||||||
|
|
||||||
|
connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
|
||||||
|
|
||||||
connect( myValEdt, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
|
connect( myValEdt, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
|
||||||
|
|
||||||
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
||||||
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
||||||
|
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
||||||
|
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
||||||
|
|
||||||
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
|
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
|
||||||
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
|
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
|
||||||
|
|
||||||
initName( tr( "DEVIDE_EDGE_NEW_OBJECT_NAME" ) );
|
initName( tr( "DEVIDE_EDGE_NEW_OBJECT_NAME" ) );
|
||||||
resize(100,100);
|
resize(100,100);
|
||||||
|
ConstructorsClicked( BY_PARAM );
|
||||||
SelectionIntoArgument();
|
SelectionIntoArgument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +204,7 @@ void RepairGUI_DivideEdgeDlg::ValueChangedInSpinBox()
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
void RepairGUI_DivideEdgeDlg::displayPreview()
|
void RepairGUI_DivideEdgeDlg::displayPreview()
|
||||||
{
|
{
|
||||||
|
myProjectionOK = false;
|
||||||
erasePreview();
|
erasePreview();
|
||||||
if ( myObject->_is_nil() )
|
if ( myObject->_is_nil() )
|
||||||
return;
|
return;
|
||||||
@ -182,10 +222,50 @@ void RepairGUI_DivideEdgeDlg::displayPreview()
|
|||||||
if (aShape.ShapeType() == TopAbs_EDGE) {
|
if (aShape.ShapeType() == TopAbs_EDGE) {
|
||||||
Standard_Real aFP, aLP, aP;
|
Standard_Real aFP, aLP, aP;
|
||||||
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aShape), aFP, aLP);
|
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aShape), aFP, aLP);
|
||||||
|
if ( aCurve.IsNull() ) return;
|
||||||
|
|
||||||
|
if ( getConstructorId() == BY_PARAM )
|
||||||
|
{
|
||||||
aP = aFP + (aLP - aFP) * myValEdt->value();
|
aP = aFP + (aLP - aFP) * myValEdt->value();
|
||||||
aPnt = aCurve->Value(aP);
|
aPnt = aCurve->Value(aP);
|
||||||
BRepBuilderAPI_MakeVertex mkVertex (aPnt);
|
BRepBuilderAPI_MakeVertex mkVertex (aPnt);
|
||||||
aShape = mkVertex.Shape();
|
aShape = mkVertex.Shape();
|
||||||
|
}
|
||||||
|
else if ( getConstructorId() == BY_POINT_PROJ && myPoint )
|
||||||
|
{
|
||||||
|
TopoDS_Shape aPoints;
|
||||||
|
GEOMBase::GetShape( myPoint.get(), aPoints, TopAbs_SHAPE );
|
||||||
|
|
||||||
|
BRep_Builder builder;
|
||||||
|
TopoDS_Compound compoundOfVV;
|
||||||
|
builder.MakeCompound(compoundOfVV);
|
||||||
|
aShape = compoundOfVV;
|
||||||
|
|
||||||
|
GeomAPI_ProjectPointOnCurve aProjector;
|
||||||
|
aProjector.Init( aCurve, aFP, aLP );
|
||||||
|
|
||||||
|
TopTools_MapOfShape vMap;
|
||||||
|
TopExp_Explorer vertex( aPoints, TopAbs_VERTEX );
|
||||||
|
for ( ; vertex.More(); vertex.Next() )
|
||||||
|
{
|
||||||
|
if ( !vMap.Add( vertex.Current() )) continue;
|
||||||
|
gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( vertex.Current() ));
|
||||||
|
aProjector.Perform( p );
|
||||||
|
if ( aProjector.NbPoints() > 0 )
|
||||||
|
{
|
||||||
|
double u = aProjector.LowerDistanceParameter();
|
||||||
|
if ( Min( u - aFP, aLP - u ) > Precision::Confusion() )
|
||||||
|
{
|
||||||
|
builder.Add( compoundOfVV, BRepBuilderAPI_MakeVertex( aProjector.NearestPoint()));
|
||||||
|
myProjectionOK = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Build prs
|
// Build prs
|
||||||
SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aShape );
|
SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aShape );
|
||||||
if ( aPrs != 0 && !aPrs->IsNull() )
|
if ( aPrs != 0 && !aPrs->IsNull() )
|
||||||
@ -218,9 +298,11 @@ bool RepairGUI_DivideEdgeDlg::ClickOnApply()
|
|||||||
|
|
||||||
myEditCurrentArgument->setText( "" );
|
myEditCurrentArgument->setText( "" );
|
||||||
myObject = GEOM::GEOM_Object::_nil();
|
myObject = GEOM::GEOM_Object::_nil();
|
||||||
|
myPoint.nullify();
|
||||||
myIndex = -1;
|
myIndex = -1;
|
||||||
|
myProjectionOK = false;
|
||||||
|
|
||||||
initSelection();
|
ConstructorsClicked(getConstructorId());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -235,8 +317,17 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument()
|
|||||||
{
|
{
|
||||||
myEditCurrentArgument->setText( "" );
|
myEditCurrentArgument->setText( "" );
|
||||||
|
|
||||||
|
const bool toSelectObject = ( myEditCurrentArgument == GroupPoints->LineEdit1 );
|
||||||
|
if ( toSelectObject )
|
||||||
|
{
|
||||||
myObject = GEOM::GEOM_Object::_nil();
|
myObject = GEOM::GEOM_Object::_nil();
|
||||||
myIndex = -1;
|
myIndex = -1;
|
||||||
|
}
|
||||||
|
else //if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
|
||||||
|
{
|
||||||
|
myPoint.nullify();
|
||||||
|
myProjectionOK = false;
|
||||||
|
}
|
||||||
|
|
||||||
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
||||||
SALOME_ListIO aSelList;
|
SALOME_ListIO aSelList;
|
||||||
@ -252,7 +343,7 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument()
|
|||||||
if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
|
if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
|
||||||
{
|
{
|
||||||
const int aType = aShape.ShapeType();
|
const int aType = aShape.ShapeType();
|
||||||
if ( aType <= TopAbs_EDGE ) // edge, wire, face, shell, solid, compound
|
if ( aType <= TopAbs_EDGE || !toSelectObject ) // edge, wire, face, shell, solid, compound
|
||||||
{
|
{
|
||||||
GEOM::short_array anIndexes;
|
GEOM::short_array anIndexes;
|
||||||
|
|
||||||
@ -263,20 +354,29 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument()
|
|||||||
|
|
||||||
if ( !aMap.IsEmpty() ) // sub-shape selection
|
if ( !aMap.IsEmpty() ) // sub-shape selection
|
||||||
{
|
{
|
||||||
|
if ( toSelectObject ) {
|
||||||
myIndex = aMap( 1 );
|
myIndex = aMap( 1 );
|
||||||
myObject = aSelectedObj;
|
myObject = aSelectedObj;
|
||||||
myEditCurrentArgument->setText( aName += QString( ":edge_%1" ).arg( myIndex ) );
|
myEditCurrentArgument->setText( aName += QString( ":edge_%1" ).arg( myIndex ) );
|
||||||
}
|
}
|
||||||
else if ( aType == TopAbs_EDGE ) // single shape selection
|
else if (( myPoint = getSelected( TopAbs_VERTEX )))
|
||||||
|
{
|
||||||
|
myEditCurrentArgument->setText( aName += QString( ":vertex_%1" ).arg( aMap( 1 )));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( aType == TopAbs_EDGE && toSelectObject ) // single shape selection
|
||||||
{
|
{
|
||||||
myIndex = -1;
|
myIndex = -1;
|
||||||
myObject = aSelectedObj;
|
myObject = aSelectedObj;
|
||||||
myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) );
|
myEditCurrentArgument->setText( aName );
|
||||||
|
}
|
||||||
|
else if ( aType == TopAbs_VERTEX && !toSelectObject ) // single shape selection
|
||||||
|
{
|
||||||
|
myPoint = aSelectedObj;
|
||||||
|
myEditCurrentArgument->setText( aName );
|
||||||
}
|
}
|
||||||
else // face, shell, solid or compound was selected, and NOT its sub-shape.
|
else // face, shell, solid or compound was selected, and NOT its sub-shape.
|
||||||
{
|
{
|
||||||
myIndex = -1;
|
|
||||||
myObject = GEOM::GEOM_Object::_nil();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,10 +392,29 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument()
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
void RepairGUI_DivideEdgeDlg::SetEditCurrentArgument()
|
void RepairGUI_DivideEdgeDlg::SetEditCurrentArgument()
|
||||||
{
|
{
|
||||||
if ( sender() == GroupPoints->PushButton1 ) {
|
QPushButton* send = (QPushButton*)sender();
|
||||||
|
|
||||||
|
if ( send == GroupPoints->PushButton1 ) {
|
||||||
GroupPoints->LineEdit1->setFocus();
|
GroupPoints->LineEdit1->setFocus();
|
||||||
myEditCurrentArgument = GroupPoints->LineEdit1;
|
myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||||
|
|
||||||
|
GroupPoints->PushButton2->setDown(false);
|
||||||
|
GroupPoints->LineEdit2->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
if ( send == GroupPoints->PushButton2 ) {
|
||||||
|
GroupPoints->LineEdit2->setFocus();
|
||||||
|
myEditCurrentArgument = GroupPoints->LineEdit2;
|
||||||
|
|
||||||
|
GroupPoints->PushButton1->setDown(false);
|
||||||
|
GroupPoints->LineEdit1->setEnabled(false);
|
||||||
|
}
|
||||||
|
// enable line edit
|
||||||
|
myEditCurrentArgument->setEnabled(true);
|
||||||
|
myEditCurrentArgument->setFocus();
|
||||||
|
// after setFocus(), because it will be setDown(false) when loses focus
|
||||||
|
send->setDown(true);
|
||||||
|
|
||||||
|
initSelection();
|
||||||
SelectionIntoArgument();
|
SelectionIntoArgument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,6 +429,11 @@ void RepairGUI_DivideEdgeDlg::LineEditReturnPressed()
|
|||||||
myEditCurrentArgument = GroupPoints->LineEdit1;
|
myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||||
GEOMBase_Skeleton::LineEditReturnPressed();
|
GEOMBase_Skeleton::LineEditReturnPressed();
|
||||||
}
|
}
|
||||||
|
if ( sender() == GroupPoints->LineEdit2 &&
|
||||||
|
!GroupPoints->LineEdit2->isHidden() ) {
|
||||||
|
myEditCurrentArgument = GroupPoints->LineEdit2;
|
||||||
|
GEOMBase_Skeleton::LineEditReturnPressed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -327,7 +451,7 @@ void RepairGUI_DivideEdgeDlg::ActivateThisDialog()
|
|||||||
myIndex = -1;
|
myIndex = -1;
|
||||||
|
|
||||||
//myGeomGUI->SetState( 0 );
|
//myGeomGUI->SetState( 0 );
|
||||||
initSelection();
|
ConstructorsClicked(getConstructorId());
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
@ -356,7 +480,16 @@ GEOM::GEOM_IOperations_ptr RepairGUI_DivideEdgeDlg::createOperation()
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
bool RepairGUI_DivideEdgeDlg::isValid( QString& msg )
|
bool RepairGUI_DivideEdgeDlg::isValid( QString& msg )
|
||||||
{
|
{
|
||||||
bool ok = myValEdt->isValid( msg, !IsPreview() );
|
bool ok = false;
|
||||||
|
if ( getConstructorId() == BY_PARAM )
|
||||||
|
{
|
||||||
|
ok = myValEdt->isValid( msg, !IsPreview() );
|
||||||
|
}
|
||||||
|
else if ( getConstructorId() == BY_POINT_PROJ )
|
||||||
|
{
|
||||||
|
if (( ok = myPoint ) && !( ok = myProjectionOK ))
|
||||||
|
msg = tr("DEVIDE_EDGE_BAD_PROJ_MSG");
|
||||||
|
}
|
||||||
return !myObject->_is_nil() && ok;
|
return !myObject->_is_nil() && ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,11 +500,16 @@ bool RepairGUI_DivideEdgeDlg::isValid( QString& msg )
|
|||||||
bool RepairGUI_DivideEdgeDlg::execute( ObjectList& objects )
|
bool RepairGUI_DivideEdgeDlg::execute( ObjectList& objects )
|
||||||
{
|
{
|
||||||
GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() );
|
GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() );
|
||||||
GEOM::GEOM_Object_var anObj = anOper->DivideEdge( myObject, myIndex, myValEdt->value(), getIsByParameter() );
|
GEOM::GEOM_Object_var anObj;
|
||||||
|
if ( getConstructorId() == BY_PARAM )
|
||||||
|
anObj = anOper->DivideEdge( myObject, myIndex, myValEdt->value(), getIsByParameter() );
|
||||||
|
else
|
||||||
|
anObj = anOper->DivideEdgeByPoint( myObject, myIndex, myPoint.get() );
|
||||||
|
|
||||||
bool aResult = !anObj->_is_nil();
|
bool aResult = !anObj->_is_nil();
|
||||||
if ( aResult )
|
if ( aResult )
|
||||||
{
|
{
|
||||||
if ( !IsPreview() )
|
if ( !IsPreview() && ( getConstructorId() == BY_PARAM ))
|
||||||
{
|
{
|
||||||
QStringList aParameters;
|
QStringList aParameters;
|
||||||
aParameters << "";
|
aParameters << "";
|
||||||
@ -400,6 +538,19 @@ bool RepairGUI_DivideEdgeDlg::getIsByParameter() const
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
void RepairGUI_DivideEdgeDlg::initSelection()
|
void RepairGUI_DivideEdgeDlg::initSelection()
|
||||||
{
|
{
|
||||||
GEOM::GEOM_Object_var aNullGeomObject;
|
TopAbs_ShapeEnum type = TopAbs_EDGE;
|
||||||
localSelection( aNullGeomObject, TopAbs_EDGE ); // load local selection on ALL objects
|
if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
|
||||||
|
type = TopAbs_VERTEX;
|
||||||
|
|
||||||
|
globalSelection(); // close local contexts, if any
|
||||||
|
localSelection( GEOM::GEOM_Object::_nil(), type ); // load local selection on ALL objects
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : addSubshapeToStudy
|
||||||
|
// purpose : virtual method to add new SubObjects if local selection
|
||||||
|
//=================================================================================
|
||||||
|
void RepairGUI_DivideEdgeDlg::addSubshapesToStudy()
|
||||||
|
{
|
||||||
|
GEOMBase::PublishSubObject( myPoint.get() );
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <GEOMBase_Skeleton.h>
|
#include <GEOMBase_Skeleton.h>
|
||||||
|
|
||||||
class DlgRef_1SelExt;
|
class DlgRef_2SelExt;
|
||||||
class SalomeApp_DoubleSpinBox;
|
class SalomeApp_DoubleSpinBox;
|
||||||
class QButtonGroup;
|
class QButtonGroup;
|
||||||
|
|
||||||
@ -50,6 +50,7 @@ protected:
|
|||||||
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
||||||
virtual bool isValid( QString& );
|
virtual bool isValid( QString& );
|
||||||
virtual bool execute( ObjectList& );
|
virtual bool execute( ObjectList& );
|
||||||
|
virtual void addSubshapesToStudy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init();
|
void Init();
|
||||||
@ -61,10 +62,13 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
GEOM::GEOM_Object_var myObject;
|
GEOM::GEOM_Object_var myObject;
|
||||||
|
GEOM::GeomObjPtr myPoint;
|
||||||
|
bool myProjectionOK;
|
||||||
|
|
||||||
DlgRef_1SelExt* GroupPoints;
|
DlgRef_2SelExt* GroupPoints;
|
||||||
QButtonGroup* myIsParameterGr;
|
QButtonGroup* myIsParameterGr;
|
||||||
SalomeApp_DoubleSpinBox* myValEdt;
|
SalomeApp_DoubleSpinBox* myValEdt;
|
||||||
|
QLabel* myValLbl;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void ClickOnOk();
|
void ClickOnOk();
|
||||||
@ -76,6 +80,7 @@ protected slots:
|
|||||||
void LineEditReturnPressed();
|
void LineEditReturnPressed();
|
||||||
void SelectionIntoArgument();
|
void SelectionIntoArgument();
|
||||||
void SetEditCurrentArgument();
|
void SetEditCurrentArgument();
|
||||||
|
void ConstructorsClicked( int );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REPAIRGUI_DIVIDEEDGEDLG_H
|
#endif // REPAIRGUI_DIVIDEEDGEDLG_H
|
||||||
|
@ -24,24 +24,28 @@
|
|||||||
// Created: 30.04.04 16:44:47
|
// Created: 30.04.04 16:44:47
|
||||||
// Author: Galina KULIKOVA
|
// Author: Galina KULIKOVA
|
||||||
//
|
//
|
||||||
#include <ShHealOper_EdgeDivide.hxx>
|
|
||||||
#include <ShapeUpgrade_WireDivide.hxx>
|
|
||||||
#include <ShHealOper_SplitCurve3d.hxx>
|
|
||||||
#include <ShHealOper_SplitCurve2d.hxx>
|
|
||||||
#include <TopTools_ListOfShape.hxx>
|
|
||||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
#include <ShapeFix_Edge.hxx>
|
|
||||||
#include <ShapeAnalysis_Edge.hxx>
|
|
||||||
#include <GeomAdaptor_Curve.hxx>
|
|
||||||
#include <Geom2dAdaptor_Curve.hxx>
|
|
||||||
#include <TopoDS.hxx>
|
|
||||||
#include <Geom_Curve.hxx>
|
|
||||||
#include <TopoDS_Face.hxx>
|
|
||||||
#include <Geom2d_Curve.hxx>
|
|
||||||
#include <GCPnts_AbscissaPoint.hxx>
|
#include <GCPnts_AbscissaPoint.hxx>
|
||||||
#include <TopExp.hxx>
|
#include <Geom2dAdaptor_Curve.hxx>
|
||||||
|
#include <Geom2d_Curve.hxx>
|
||||||
|
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||||
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
|
#include <ShHealOper_EdgeDivide.hxx>
|
||||||
|
#include <ShHealOper_SplitCurve2d.hxx>
|
||||||
|
#include <ShHealOper_SplitCurve3d.hxx>
|
||||||
|
#include <ShapeAnalysis_Edge.hxx>
|
||||||
|
#include <ShapeFix_Edge.hxx>
|
||||||
|
#include <ShapeUpgrade_WireDivide.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
|
||||||
//#include <.hxx>
|
//#include <.hxx>
|
||||||
//#include <.hxx>
|
//#include <.hxx>
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -113,6 +117,47 @@ Standard_Boolean ShHealOper_EdgeDivide::Perform(const TopoDS_Shape& theEdge,
|
|||||||
return myDone;
|
return myDone;
|
||||||
}
|
}
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean ShHealOper_EdgeDivide::Perform(const TopoDS_Shape& theEdge,
|
||||||
|
const TopoDS_Shape& thePoints)
|
||||||
|
{
|
||||||
|
myDone = Standard_False;
|
||||||
|
myErrorStatus = ShHealOper_NotError;
|
||||||
|
if(theEdge.ShapeType() != TopAbs_EDGE) {
|
||||||
|
myErrorStatus = ShHealOper_InvalidParameters;
|
||||||
|
return myDone;
|
||||||
|
}
|
||||||
|
myDivideParamMode = true;
|
||||||
|
myEdge = TopoDS::Edge(theEdge);
|
||||||
|
Handle(TColStd_HSequenceOfReal) aSeqValues = new TColStd_HSequenceOfReal;
|
||||||
|
|
||||||
|
double aFirst,aLast;
|
||||||
|
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(myEdge,aFirst,aLast);
|
||||||
|
if ( aCurve.IsNull() ) return false;
|
||||||
|
GeomAPI_ProjectPointOnCurve aProjector;
|
||||||
|
aProjector.Init( aCurve, aFirst, aLast );
|
||||||
|
|
||||||
|
TopTools_MapOfShape vMap;
|
||||||
|
TopExp_Explorer vertex( thePoints, TopAbs_VERTEX );
|
||||||
|
for ( ; vertex.More(); vertex.Next() )
|
||||||
|
{
|
||||||
|
if ( !vMap.Add( vertex.Current() )) continue;
|
||||||
|
gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( vertex.Current() ));
|
||||||
|
aProjector.Perform( p );
|
||||||
|
if ( aProjector.NbPoints() > 0 )
|
||||||
|
{
|
||||||
|
double u = double( aProjector.LowerDistanceParameter() );
|
||||||
|
double param = ( u - aFirst ) / ( aLast - aFirst );
|
||||||
|
aSeqValues->Append( param );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myDone = build(aSeqValues);
|
||||||
|
return myDone;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
//function : build
|
//function : build
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -27,12 +27,11 @@
|
|||||||
#ifndef ShHealOper_EdgeDivide_HeaderFile
|
#ifndef ShHealOper_EdgeDivide_HeaderFile
|
||||||
#define ShHealOper_EdgeDivide_HeaderFile
|
#define ShHealOper_EdgeDivide_HeaderFile
|
||||||
|
|
||||||
|
#include <ShHealOper_Tool.hxx>
|
||||||
#include <TColStd_HSequenceOfReal.hxx>
|
#include <TColStd_HSequenceOfReal.hxx>
|
||||||
|
#include <TColStd_SequenceOfReal.hxx>
|
||||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
#include <TopoDS_Edge.hxx>
|
#include <TopoDS_Edge.hxx>
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
#include <ShHealOper_Tool.hxx>
|
|
||||||
#include <TColStd_SequenceOfReal.hxx>
|
|
||||||
|
|
||||||
/// Class ShHealOper_EdgeDivide
|
/// Class ShHealOper_EdgeDivide
|
||||||
//Intended for spitting edge in accordance to the specified mode and value.
|
//Intended for spitting edge in accordance to the specified mode and value.
|
||||||
@ -59,7 +58,7 @@ class ShHealOper_EdgeDivide : public ShHealOper_Tool
|
|||||||
//specified mode and value.
|
//specified mode and value.
|
||||||
//If theDivideParamMode is equal to true edge will be splitted by parameter.
|
//If theDivideParamMode is equal to true edge will be splitted by parameter.
|
||||||
//Else edge will be spliited by length (default true).
|
//Else edge will be spliited by length (default true).
|
||||||
//theValue is koefficient for splitting from 0 to 1.
|
//theValue is coefficient for splitting from 0 to 1.
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean Perform(const TopoDS_Shape& theEdge,
|
Standard_EXPORT Standard_Boolean Perform(const TopoDS_Shape& theEdge,
|
||||||
const TColStd_SequenceOfReal& theValues,
|
const TColStd_SequenceOfReal& theValues,
|
||||||
@ -67,6 +66,10 @@ class ShHealOper_EdgeDivide : public ShHealOper_Tool
|
|||||||
//Performs spitting of the specified edge in the accoradnce to
|
//Performs spitting of the specified edge in the accoradnce to
|
||||||
//specified mode and sequence of values the same way as previous.
|
//specified mode and sequence of values the same way as previous.
|
||||||
|
|
||||||
|
Standard_EXPORT Standard_Boolean Perform(const TopoDS_Shape& theEdge,
|
||||||
|
const TopoDS_Shape& thePoint);
|
||||||
|
//Performs spitting of the specified edge by projecting a point to it.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ---------- PROTECTED METHODS ----------
|
// ---------- PROTECTED METHODS ----------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user