mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-28 18:30:36 +05:00
22747: [EDF] Improvement of Get Shared Shapes operation
This commit is contained in:
parent
e4a7d5ed70
commit
2bb925ff23
@ -5,7 +5,8 @@
|
||||
This operation is a special case of <b>Explode</b> operation. It
|
||||
produces sub-shapes of the exploded shape (the first shape in the list
|
||||
of argument shapes), which are shared with all other shapes in the
|
||||
arguments.
|
||||
arguments. The argument shapes can also be contained in a compound or
|
||||
group.
|
||||
|
||||
To use this operation, select in the Main Menu <b>Operations -> Get
|
||||
Shared Shapes.</b> The following dialog box will appear.
|
||||
@ -13,15 +14,15 @@ Shared Shapes.</b> The following dialog box will appear.
|
||||
\image html shared_shapes.png
|
||||
|
||||
<ul>
|
||||
<li> <b>Name</b> is the base name of the resulting shapes; </li>
|
||||
<li> <b>Shapes</b> are the shapes to fing shared sub-shapes of; </li>
|
||||
<li> <b>Sub-shapes Type</b> is the type of required sub-shapes; </li>
|
||||
<li> <b>Name</b> is the base name of the resulting shapes. </li>
|
||||
<li> <b>Shapes</b> are the shapes to fing shared sub-shapes of. </li>
|
||||
<li> <b>Sub-shapes Type</b> is the type of required sub-shapes. </li>
|
||||
</ul>
|
||||
|
||||
\n <b>Advanced options</b> \ref preview_anchor "Preview"
|
||||
|
||||
\n <b>TUI Command:</b> <em> geompy.GetSharedShapesMulti(Shapes,
|
||||
Type),</em> where \em Shapes is a list of shapes to fing shared sub-
|
||||
\n <b>Advanced options:</b> \ref preview_anchor "Preview"
|
||||
<p>
|
||||
<b>TUI Command:</b> <em> geompy.GetSharedShapesMulti( Shapes, Type ),</em>
|
||||
<br> where \em Shapes is a list or compound of shapes to fing shared sub-
|
||||
shapes of and \em Type is the type of required sub-shapes.
|
||||
|
||||
Our <b>TUI Scripts</b> provide you with useful examples of the use of
|
||||
|
@ -2001,8 +2001,8 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
|
||||
(std::list<Handle(GEOM_Object)> theShapes,
|
||||
const Standard_Integer theShapeType)
|
||||
(std::list<Handle(GEOM_Object)> & theShapes,
|
||||
const Standard_Integer theShapeType)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
@ -2012,18 +2012,33 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
|
||||
int ind = 1;
|
||||
std::list<Handle(GEOM_Object)>::iterator it = theShapes.begin();
|
||||
|
||||
Handle(GEOM_Object) aMainObj = (*it++);
|
||||
Handle(GEOM_Object) aMainObj = *it;
|
||||
Handle(GEOM_Function) aMainShape = aMainObj->GetLastFunction();
|
||||
if (aMainShape.IsNull()) {
|
||||
SetErrorCode("NULL shape for GetSharedShapes");
|
||||
return NULL;
|
||||
|
||||
TopTools_SequenceOfShape shapeSeq;
|
||||
for (; it != theShapes.end(); it++, ind++) {
|
||||
Handle(GEOM_Function) aRefShape = (*it)->GetLastFunction();
|
||||
if (aRefShape.IsNull()) {
|
||||
SetErrorCode("NULL shape for GetSharedShapes");
|
||||
return NULL;
|
||||
}
|
||||
TopoDS_Shape aShape2 = aRefShape->GetValue();
|
||||
if (aShape2.IsNull()) return NULL;
|
||||
shapeSeq.Append( aShape2 );
|
||||
}
|
||||
|
||||
TopoDS_Shape aShape1 = aMainShape->GetValue();
|
||||
if (aShape1.IsNull()) return NULL;
|
||||
TopoDS_Shape aShape1 = shapeSeq.First();
|
||||
|
||||
if ( shapeSeq.Length() == 1 )
|
||||
{
|
||||
shapeSeq.Clear();
|
||||
for ( TopoDS_Iterator it( aShape1); it.More(); it.Next() )
|
||||
shapeSeq.Append( it.Value() );
|
||||
aShape1 = shapeSeq.First();
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape anIndices;
|
||||
TopExp::MapShapes(aShape1, anIndices);
|
||||
TopExp::MapShapes(aMainShape->GetValue(), anIndices);
|
||||
|
||||
TopTools_IndexedMapOfShape mapSelected;
|
||||
TopExp::MapShapes(aShape1, TopAbs_ShapeEnum(theShapeType), mapSelected);
|
||||
@ -2032,23 +2047,17 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
|
||||
BRep_Builder B;
|
||||
TopoDS_Compound aCurrSelection;
|
||||
|
||||
for (; it != theShapes.end(); it++, ind++) {
|
||||
Handle(GEOM_Function) aRefShape = (*it)->GetLastFunction();
|
||||
if (aRefShape.IsNull()) {
|
||||
SetErrorCode("NULL shape for GetSharedShapes");
|
||||
return NULL;
|
||||
}
|
||||
for ( ind = 2; ind <= shapeSeq.Length(); ind++) {
|
||||
|
||||
TopoDS_Compound aCompound;
|
||||
B.MakeCompound(aCompound);
|
||||
|
||||
TopoDS_Shape aShape2 = aRefShape->GetValue();
|
||||
if (aShape2.IsNull()) return NULL;
|
||||
const TopoDS_Shape& aShape2 = shapeSeq.Value( ind );
|
||||
|
||||
TopTools_MapOfShape mapShape2;
|
||||
TopExp_Explorer exp (aShape2, TopAbs_ShapeEnum(theShapeType));
|
||||
for (; exp.More(); exp.Next()) {
|
||||
TopoDS_Shape aSS = exp.Current();
|
||||
const TopoDS_Shape& aSS = exp.Current();
|
||||
if (mapShape2.Add(aSS) && mapSelected.Contains(aSS)) {
|
||||
B.Add(aCompound, aSS);
|
||||
}
|
||||
@ -2060,7 +2069,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
|
||||
}
|
||||
|
||||
// Create GEOM_Object for each found shared shape (collected in aCurrSelection)
|
||||
Handle(GEOM_Object) anObj;
|
||||
Handle(GEOM_Object) anObj, aLastCreated;
|
||||
Handle(TColStd_HArray1OfInteger) anArray;
|
||||
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
|
||||
TCollection_AsciiString anAsciiList, anEntry;
|
||||
@ -2072,6 +2081,8 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
|
||||
anObj = GetEngine()->AddSubShape(aMainObj, anArray);
|
||||
aSeq->Append(anObj);
|
||||
|
||||
aLastCreated = GEOM::GetCreatedLast( aLastCreated, anObj );
|
||||
|
||||
// for python command
|
||||
TDF_Tool::Entry(anObj->GetEntry(), anEntry);
|
||||
anAsciiList += anEntry;
|
||||
@ -2087,16 +2098,8 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
|
||||
anAsciiList.Trunc(anAsciiList.Length() - 1);
|
||||
|
||||
// IPAL22904: TC6.5.0: order of python commands is wrong after dump study
|
||||
Handle(TColStd_HSequenceOfTransient) anObjects = new TColStd_HSequenceOfTransient;
|
||||
for( it = theShapes.begin(); it != theShapes.end(); it++ )
|
||||
{
|
||||
Handle(GEOM_Object) anObj = *it;
|
||||
if( !anObj.IsNull() )
|
||||
anObjects->Append( anObj );
|
||||
}
|
||||
|
||||
// Get the function of the latest published object
|
||||
Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast( anObjects )->GetLastFunction();
|
||||
Handle(GEOM_Function) aFunction = aLastCreated->GetLastFunction();
|
||||
if( aFunction.IsNull() ) // just in case
|
||||
aFunction = aMainShape;
|
||||
|
||||
|
@ -166,8 +166,8 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations
|
||||
const Standard_Integer theShapeType);
|
||||
|
||||
Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
|
||||
GetSharedShapes (std::list<Handle(GEOM_Object)> theShapes,
|
||||
const Standard_Integer theShapeType);
|
||||
GetSharedShapes (std::list<Handle(GEOM_Object)>& theShapes,
|
||||
const Standard_Integer theShapeType);
|
||||
|
||||
Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
|
||||
GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
|
||||
|
@ -1047,12 +1047,8 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
|
||||
|
||||
//Get the shapes
|
||||
std::list<Handle(GEOM_Object)> aShapes;
|
||||
int aLen = theShapes.length();
|
||||
for (int ind = 0; ind < aLen; ind++) {
|
||||
Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
|
||||
if (aSh.IsNull()) return aSeq._retn();
|
||||
aShapes.push_back(aSh);
|
||||
}
|
||||
if (! GetListOfObjectsImpl( theShapes, aShapes ))
|
||||
return aSeq._retn();
|
||||
|
||||
Handle(TColStd_HSequenceOfTransient) aHSeq =
|
||||
GetOperations()->GetSharedShapes(aShapes, theShapeType);
|
||||
|
@ -501,6 +501,14 @@ def TestSewGluing(geompy):
|
||||
assert glueEL3.GetShapeType() == GEOM.COMPOUND
|
||||
assert geompy.NumberOfEdges( glueEL3 ) == geompy.NumberOfEdges( comp ) - 4
|
||||
|
||||
# check GetSharedShapesMulti()
|
||||
sharedEE = geompy.GetSharedShapesMulti( glueEL3, geompy.ShapeType["EDGE"])
|
||||
assert len( sharedEE ) == 4
|
||||
assert sharedEE[0].GetShapeType() == GEOM.EDGE
|
||||
assert sharedEE[1].GetShapeType() == GEOM.EDGE
|
||||
assert sharedEE[2].GetShapeType() == GEOM.EDGE
|
||||
assert sharedEE[3].GetShapeType() == GEOM.EDGE
|
||||
|
||||
return
|
||||
|
||||
def TestHealingOperations (geompy, math):
|
||||
|
@ -4800,7 +4800,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
||||
return aList
|
||||
|
||||
## Get all sub-shapes, shared by all shapes in the list <VAR>theShapes</VAR>.
|
||||
# @param theShapes Shapes to find common sub-shapes of.
|
||||
# @param theShapes Either a list or compound of shapes to find common sub-shapes of.
|
||||
# @param theShapeType Type of sub-shapes to be retrieved (see ShapeType())
|
||||
# @param theName Object name; when specified, this parameter is used
|
||||
# for result publication in the study. Otherwise, if automatic
|
||||
@ -4815,7 +4815,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
||||
Get all sub-shapes, shared by all shapes in the list theShapes.
|
||||
|
||||
Parameters:
|
||||
theShapes Shapes to find common sub-shapes of.
|
||||
theShapes Either a list or compound of shapes to find common sub-shapes of.
|
||||
theShapeType Type of sub-shapes to be retrieved (see geompy.ShapeType)
|
||||
theName Object name; when specified, this parameter is used
|
||||
for result publication in the study. Otherwise, if automatic
|
||||
@ -4825,7 +4825,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
||||
List of GEOM.GEOM_Object, that are sub-shapes of all given shapes.
|
||||
"""
|
||||
# Example: see GEOM_TestOthers.py
|
||||
aList = self.ShapesOp.GetSharedShapesMulti(theShapes, theShapeType)
|
||||
aList = self.ShapesOp.GetSharedShapesMulti(ToList(theShapes), theShapeType)
|
||||
RaiseIfFailed("GetSharedShapesMulti", self.ShapesOp)
|
||||
self._autoPublish(aList, theName, "shared")
|
||||
return aList
|
||||
|
@ -308,11 +308,16 @@ GEOM::GEOM_IOperations_ptr OperationGUI_GetSharedShapesDlg::createOperation()
|
||||
//=================================================================================
|
||||
bool OperationGUI_GetSharedShapesDlg::isValid (QString& msg)
|
||||
{
|
||||
bool isOK = true;
|
||||
if (myListShapes.length() < 2) {
|
||||
msg = tr("MSG_SHARED_SHAPES_TOO_FEW_SHAPES");
|
||||
return false;
|
||||
isOK = false;
|
||||
if ( myListShapes.length() == 1 )
|
||||
isOK = ( myListShapes[0]->GetShapeType() == GEOM::COMPOUND );
|
||||
}
|
||||
return true;
|
||||
if ( !isOK )
|
||||
msg = tr("MSG_SHARED_SHAPES_TOO_FEW_SHAPES");
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user