mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-26 17:30:35 +05:00
0023197: [CEA] Extract and rebuild: algo + TUI + some fixes
This commit is contained in:
parent
553dce807d
commit
48b2400d5c
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,13 @@
|
||||
|
||||
#include <GEOMAlgo_Algo.hxx>
|
||||
|
||||
#include <NCollection_List.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_DataMapOfShapeListOfShape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
|
||||
class TopTools_IndexedMapOfShape;
|
||||
|
||||
|
||||
/**
|
||||
@ -124,23 +129,234 @@ public:
|
||||
private:
|
||||
|
||||
/**
|
||||
* This method reinitializes the shape.
|
||||
* \brief This method reinitializes the shape.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* This method checks the input data.
|
||||
* \brief This method checks the input data.
|
||||
*/
|
||||
void checkData();
|
||||
|
||||
/**
|
||||
* \brief This method fills the map of shapes and ancestors for the whole
|
||||
* sub-shapes of theShape. This method is recursively called up to the lowest
|
||||
* level of sub-shapes i.e. vertices.
|
||||
*
|
||||
* \param theShape the shape.
|
||||
*/
|
||||
void makeMapShapeAncestors(const TopoDS_Shape &theShape);
|
||||
|
||||
/**
|
||||
* \brief This method marks shapes to be removed and to be modified.
|
||||
*/
|
||||
void markShapes();
|
||||
|
||||
/**
|
||||
* \brief This method marks theShape to be removed. If it is required, it
|
||||
* recursively marks its sub-shapes to be removed.
|
||||
*
|
||||
* \param theShape the shape.
|
||||
*/
|
||||
void markRemoved(const TopoDS_Shape &theShape);
|
||||
|
||||
/**
|
||||
* \brief This method marks ancestors of theShape to be modified. It is
|
||||
* recursively called up to the level of main shape.
|
||||
*
|
||||
* \param theShape the shape.
|
||||
*/
|
||||
void markAncestorsModified(const TopoDS_Shape &theShape);
|
||||
|
||||
/**
|
||||
* \brief This method performs computation of modified shapes of
|
||||
* the provided type.
|
||||
*
|
||||
* \param theType the processed shape type.
|
||||
*/
|
||||
void processShapes(const TopAbs_ShapeEnum &theType);
|
||||
|
||||
/**
|
||||
* \brief This method performs computation of a modified edge.
|
||||
*
|
||||
* \param theEdge the modified edge (should be forward).
|
||||
*/
|
||||
void processEdge(const TopoDS_Shape &theEdge);
|
||||
|
||||
/**
|
||||
* \brief This method performs computation of a modified wire.
|
||||
*
|
||||
* \param theWire the modified wire (should be forward).
|
||||
*/
|
||||
void processWire(const TopoDS_Shape &theWire);
|
||||
|
||||
/**
|
||||
* \brief This method performs computation of a modified face or solid.
|
||||
*
|
||||
* \param theFOrSo the modified face or solid (should be forward).
|
||||
*/
|
||||
void processFOrSo(const TopoDS_Shape &theFOrSo);
|
||||
|
||||
/**
|
||||
* \brief This method performs computation of a modified shell or comp-solid.
|
||||
*
|
||||
* \param theShOrCS the modified shell or comp-solid (should be forward).
|
||||
*/
|
||||
void processShOrCS(const TopoDS_Shape &theShOrCS);
|
||||
|
||||
/**
|
||||
* \brief This method performs computation of a modified compound.
|
||||
*
|
||||
* \param theCompound the modified compound (should be forward).
|
||||
*/
|
||||
void processCompound(const TopoDS_Shape &theCompound);
|
||||
|
||||
/**
|
||||
* \brief This method removes hanging edges (faces) built for faces (solids)
|
||||
* if they lie on created faces (solids).
|
||||
*
|
||||
* \param theType the shape type. Should be either face or solid.
|
||||
*/
|
||||
void removeBoundsOnFOrSo(const TopAbs_ShapeEnum theType);
|
||||
|
||||
/**
|
||||
* \brief Returns theShape with an orientation composed with theContext's
|
||||
* orientation.
|
||||
*
|
||||
* \param theShape the shape to be re-oriented.
|
||||
* \param theContext the context shape.
|
||||
*/
|
||||
TopoDS_Shape oriented(const TopoDS_Shape &theShape,
|
||||
const TopoDS_Shape &theContext);
|
||||
|
||||
/**
|
||||
* \brief This method makes a shape as an empty copy of theShape adding
|
||||
* subshapes to it.
|
||||
*
|
||||
* \param theShape the shape to be copied (should be forward).
|
||||
* \param theSubShapes the sub-shapes (should be oriented correctly).
|
||||
* \return the modified shape.
|
||||
*/
|
||||
TopoDS_Shape makeShape(const TopoDS_Shape &theShape,
|
||||
const TopTools_ListOfShape &theSubShapes);
|
||||
|
||||
/**
|
||||
* \brief This method returns the shape from the list of sub-shapes
|
||||
* if there is any shape created already with these sub-shapes.
|
||||
* If there is no such shape, null shape is returned.
|
||||
*
|
||||
* \param theShape the shape to be copied (should be forward).
|
||||
* \param theSubShapes the sub-shapes (should be oriented correctly).
|
||||
* \return the modified shape (or null if it is not found).
|
||||
*/
|
||||
TopoDS_Shape getShapeFromSubShapes(const TopoDS_Shape &theShape,
|
||||
const TopTools_ListOfShape &theSubShapes);
|
||||
|
||||
/**
|
||||
* \brief This method makes the result for the given shape. If it is removed
|
||||
* the result is a compound of its modified sub-shapes (or a single
|
||||
* modified sub-shape if it in only one).
|
||||
*
|
||||
* \param theShape the shape.
|
||||
* \return the result.
|
||||
*/
|
||||
TopoDS_Shape makeResult(const TopoDS_Shape &theShape);
|
||||
|
||||
/**
|
||||
* \brief This method fills the lists of shapes myRemoved, myModified and
|
||||
* myNew with removed, modified and newly created shapes correspondingly.
|
||||
* This method is called recursively for sub-shapes of the shape.
|
||||
*
|
||||
* \param theShape the shape.
|
||||
* \param theMapFence the map of already treated shapes.
|
||||
*/
|
||||
void makeHistory(const TopoDS_Shape &theShape,
|
||||
TopTools_MapOfShape &theMapFence);
|
||||
|
||||
/**
|
||||
* \brief This method removes edges that are in theMapEdgesToRm from
|
||||
* theWire and re-creates one or more wires from the rest edges. theNewWires
|
||||
* contains the modified wire(s).
|
||||
*
|
||||
* \param theWire the input wire.
|
||||
* \param theMapEdgesToRm the map of edges to be extracted from theWire.
|
||||
* \param theNewWires is the list of new wires. Output parameter.
|
||||
* \return Standard_True if theWire is modified; Standard_False otherwise.
|
||||
*/
|
||||
Standard_Boolean removeCommonEdges
|
||||
(const TopoDS_Shape &theWire,
|
||||
const TopTools_IndexedMapOfShape &theMapEdgesToRm,
|
||||
TopTools_ListOfShape &theNewWires);
|
||||
|
||||
/**
|
||||
* \brief This method removes faces that are in theMapFacesToRm from
|
||||
* theShell and re-creates one or more shells from the rest faces.
|
||||
* theNewShells contains the modified shell(s).
|
||||
*
|
||||
* \param theShell the input shell.
|
||||
* \param theMapFacesToRm the map of faces to be extracted from theShell.
|
||||
* \param theNewShells is the list of new shells. Output parameter.
|
||||
* \return Standard_True if theShell is modified; Standard_False otherwise.
|
||||
*/
|
||||
Standard_Boolean removeCommonFaces
|
||||
(const TopoDS_Shape &theShell,
|
||||
const TopTools_IndexedMapOfShape &theMapFacesToRm,
|
||||
TopTools_ListOfShape &theNewShells);
|
||||
|
||||
/**
|
||||
* \brief This method creates wires from the list of list of edges.
|
||||
*
|
||||
* \param theWire the input wire.
|
||||
* \param theListListEdges the list of list of edges. Can be modified
|
||||
* on output.
|
||||
* \param theWires the list of created wires. Output parameter.
|
||||
*/
|
||||
void makeWires(const TopoDS_Shape &theWire,
|
||||
NCollection_List<TopTools_ListOfShape> &theListListEdges,
|
||||
TopTools_ListOfShape &theWires);
|
||||
|
||||
/**
|
||||
* \brief This method collects the shapes in theShapes via common bounds.
|
||||
* This method is used to group faces into shells via common edges or
|
||||
* solids into compsolids via common faces. Collected lists of shapes
|
||||
* are used to create new shapes from theShape that are returned in
|
||||
* theNewShapes. theNewShapes is not cleared at first.
|
||||
*
|
||||
* \param theShape the original shape.
|
||||
* \param theSubShapes the list of shapes to be connected.
|
||||
* \param theNewShapes the list of newly created shapes. Output parameter.
|
||||
*/
|
||||
void groupViaBounds(const TopoDS_Shape &theShape,
|
||||
const TopTools_ListOfShape &theSubShapes,
|
||||
TopTools_ListOfShape &theNewShapes);
|
||||
|
||||
/**
|
||||
* \brief This method returns the list of modified shapes obtained
|
||||
* from theShape. It performs recursive search in myMapModified.
|
||||
* theModifShapes is not cleared at first. If theShapeType filter is equal
|
||||
* to TopAbs_SHAPE (default value) all modified shapes will be returned,
|
||||
* otherwise shapes of particular type will only be returned.
|
||||
*
|
||||
* \param theShape the shape examined.
|
||||
* \param theModifShapes the list of modified shapes. Output parameter.
|
||||
* \param theShapeType the shape type filter.
|
||||
*/
|
||||
void getModified(const TopoDS_Shape &theShape,
|
||||
TopTools_ListOfShape &theModifShapes,
|
||||
const TopAbs_ShapeEnum theShapeType = TopAbs_SHAPE);
|
||||
|
||||
protected:
|
||||
|
||||
TopoDS_Shape myShape;
|
||||
TopoDS_Shape myResult;
|
||||
TopTools_ListOfShape mySubShapes;
|
||||
TopTools_ListOfShape myRemoved;
|
||||
TopTools_ListOfShape myModified;
|
||||
TopTools_ListOfShape myNew;
|
||||
TopoDS_Shape myShape;
|
||||
TopoDS_Shape myResult;
|
||||
TopTools_ListOfShape mySubShapes;
|
||||
TopTools_ListOfShape myRemoved;
|
||||
TopTools_ListOfShape myModified;
|
||||
TopTools_ListOfShape myNew;
|
||||
TopTools_DataMapOfShapeListOfShape myMapShapeAnc;
|
||||
TopTools_MapOfShape myMapRemoved;
|
||||
TopTools_DataMapOfShapeListOfShape myMapModified;
|
||||
TopTools_DataMapOfShapeListOfShape myMapNewShapeAnc;
|
||||
|
||||
};
|
||||
|
||||
|
@ -841,10 +841,21 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
|
||||
|
||||
if (!anIDs.IsNull()) {
|
||||
const int anUpperID = anIDs->Upper();
|
||||
const int aNbShapes = anIndices.Extent();
|
||||
|
||||
for (i = anIDs->Lower(); i <= anUpperID; ++i) {
|
||||
const Standard_Integer anIndex = anIDs->Value(i);
|
||||
const TopoDS_Shape &aSubShape = anIndices.FindKey(anIndex);
|
||||
const Standard_Integer anIndex = anIDs->Value(i);
|
||||
|
||||
if (anIndex < 1 || anIndex > aNbShapes) {
|
||||
TCollection_AsciiString aMsg(" Invalid index: ");
|
||||
|
||||
aMsg += TCollection_AsciiString(anIndex);
|
||||
StdFail_NotDone::Raise(aMsg.ToCString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
const TopoDS_Shape &aSubShape = anIndices.FindKey(anIndex);
|
||||
|
||||
aListSubShapes.Append(aSubShape);
|
||||
}
|
||||
}
|
||||
|
@ -2244,6 +2244,7 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeExtraction
|
||||
GEOM::GEOM_Object_var aGEOMObject;
|
||||
|
||||
//Set a not done flag
|
||||
theStats = new GEOM::GEOM_IShapesOperations::ExtractionStats;
|
||||
GetOperations()->SetNotDone();
|
||||
|
||||
//Get the reference object
|
||||
@ -2253,7 +2254,12 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeExtraction
|
||||
return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
const int aNbIDs = theSubShapeIDs.length();
|
||||
const int aNbIDs = theSubShapeIDs.length();
|
||||
|
||||
if (aNbIDs == 0) {
|
||||
return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
int i;
|
||||
Handle(TColStd_HArray1OfInteger) anArray =
|
||||
new TColStd_HArray1OfInteger (1, aNbIDs);
|
||||
@ -2272,11 +2278,9 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeExtraction
|
||||
}
|
||||
|
||||
// Convert statistics.
|
||||
GEOM::GEOM_IShapesOperations::ExtractionStats_var aResStats =
|
||||
new GEOM::GEOM_IShapesOperations::ExtractionStats;
|
||||
const int aNbStats = aStats.size();
|
||||
const int aNbStats = aStats.size();
|
||||
|
||||
aResStats->length(aNbStats);
|
||||
theStats->length(aNbStats);
|
||||
|
||||
// fill the local CORBA array with values from lists
|
||||
std::list<GEOMImpl_IShapesOperations::ExtractionStat>::const_iterator
|
||||
@ -2316,11 +2320,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeExtraction
|
||||
|
||||
aResStat->indices = aResIDList;
|
||||
|
||||
aResStats[i] = aResStat;
|
||||
theStats[i] = aResStat;
|
||||
}
|
||||
|
||||
// initialize out-parameter with local array
|
||||
theStats = aResStats._retn();
|
||||
|
||||
return GetObject(aResult);
|
||||
}
|
||||
|
@ -6657,6 +6657,35 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
||||
RaiseIfFailed("IsSubShapeBelongsTo", self.ShapesOp)
|
||||
return IsOk
|
||||
|
||||
## Perform extraction of sub-shapes from the main shape.
|
||||
#
|
||||
# @param theShape the main shape
|
||||
# @param theListOfID the list of sub-shape IDs to be extracted from
|
||||
# the main shape.
|
||||
# @return New GEOM.GEOM_Object, containing the shape without
|
||||
# extracted sub-shapes.
|
||||
#
|
||||
# @ref tui_multi_transformation "Example"
|
||||
@ManageTransactions("ShapesOp")
|
||||
def MakeExtraction(self, theShape, theListOfID, theName=None):
|
||||
"""
|
||||
Perform extraction of sub-shapes from the main shape.
|
||||
|
||||
Parameters:
|
||||
theShape the main shape
|
||||
theListOfID the list of sub-shape IDs to be extracted from
|
||||
the main shape.
|
||||
|
||||
Returns
|
||||
New GEOM.GEOM_Object, containing the shape without
|
||||
extracted sub-shapes.
|
||||
"""
|
||||
# Example: see GEOM_TestAll.py
|
||||
(anObj, aStat) = self.ShapesOp.MakeExtraction(theShape, theListOfID)
|
||||
RaiseIfFailed("MakeExtraction", self.ShapesOp)
|
||||
self._autoPublish(anObj, theName, "Extraction")
|
||||
return anObj
|
||||
|
||||
# end of l4_decompose
|
||||
## @}
|
||||
|
||||
|
@ -319,6 +319,8 @@ OperationGUI_ExtractionDlg::OperationGUI_ExtractionDlg
|
||||
/***************************************************************/
|
||||
myHelpFileName = "extract_and_rebuild_page.html";
|
||||
|
||||
resize(525, 600);
|
||||
|
||||
/* Initialisation */
|
||||
Init();
|
||||
}
|
||||
@ -1005,7 +1007,7 @@ void OperationGUI_ExtractionDlg::onRebuild()
|
||||
|
||||
QStringList aStrList;
|
||||
|
||||
for (j = 1; j < 8; ++j) {
|
||||
for (j = 0; j < 8; ++j) {
|
||||
if (aNbShapes[j] >= 1) {
|
||||
const char *aShapeType = aNbShapes[j] == 1 ?
|
||||
SINGLE_SHAPE_TYPE_TR_CODES[j] : PLURAL_SHAPE_TYPE_TR_CODES[j];
|
||||
|
Loading…
Reference in New Issue
Block a user