0023197: [CEA] Extract and rebuild

This commit is contained in:
skv 2015-11-13 09:21:54 +03:00 committed by vsr
parent 45914b2b15
commit ef5ed77d70
35 changed files with 4086 additions and 0 deletions

View File

@ -66,6 +66,7 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/GEOM DESTINATION ${SALOME_INSTALL_
INSTALL(FILES images/head.png DESTINATION ${SALOME_INSTALL_DOC}/gui/GEOM) INSTALL(FILES images/head.png DESTINATION ${SALOME_INSTALL_DOC}/gui/GEOM)
INSTALL(FILES images/head.png DESTINATION ${SALOME_INSTALL_DOC}/gui/GEOM/geompy_doc) INSTALL(FILES images/head.png DESTINATION ${SALOME_INSTALL_DOC}/gui/GEOM/geompy_doc)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/static/SALOME_BOA_PA.pdf DESTINATION ${SALOME_INSTALL_DOC}/gui/GEOM) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/static/SALOME_BOA_PA.pdf DESTINATION ${SALOME_INSTALL_DOC}/gui/GEOM)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/static/ExtractAndRebuild.pdf DESTINATION ${SALOME_INSTALL_DOC}/gui/GEOM)
INSTALL(FILES input/geompy_migration.doc input/tui_auto_completion_documentation.doc input/tui_execution_distribution.doc DESTINATION ${SALOME_INSTALL_DOC}/gui/GEOM/input) INSTALL(FILES input/geompy_migration.doc input/tui_auto_completion_documentation.doc input/tui_execution_distribution.doc DESTINATION ${SALOME_INSTALL_DOC}/gui/GEOM/input)
FILE(GLOB tag_files ${CMAKE_CURRENT_BINARY_DIR}/*.tag) FILE(GLOB tag_files ${CMAKE_CURRENT_BINARY_DIR}/*.tag)

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,82 @@
/*!
\page extract_and_rebuild_page Extract and Rebuild
This operation allows extraction of sub-shapes from a given
shape.
To use this operation, select in the Main Menu <b>Operations -> Extract and Rebuild</b>.
The following dialog box appears:
\image html extract_rebuild.png "Extract and Rebuild Dialog"
In this dialog:
<ul>
<li> \b Name is a result object name.</li>
<li> <b>Main Object</b> is the main object selected for the operation. It is
possible to select the object in the Object Browser or in the viewer using
"selection" button.</li>
<li> <b>Sub-shape type</b> is the type filter for sub-shapes to be chosen
for the extraction.</li>
<li> <b>Filtered shapes</b> is the list of filtered sub-shape IDs available
for the extraction.</li>
<li> <b>Shapes to extract</b> is the list of sub-shape IDs to be extracted
grouped by shape types.</li>
<li> \b >> is the button to copy object IDs from <b>Filtered shapes</b> to
<b>Shapes to extract</b>.</li>
<li> \b << is the button to copy object IDs from <b>Shapes to extract</b> to
<b>Filtered shapes</b>.</li>
<li> <b>Show Only Selected</b> is the button to show objects selected in the
<b>Filtered shapes</b> list and hide all other objects.</li>
<li> <b>Hide Selected</b> is the button to hide objects selected in the
<b>Filtered shapes</b> list.</li>
<li> <b>Show all sub-shapes</b> is the button to show all objects from the
<b>Filtered shapes</b> list.</li>
<li> \b Rebuild is the button to perform extraction and show the operation
statistics.</li>
<li> The block of \b Statistics shows how many shapes of a certain type
are \b Removed, \b Modified and \b Added.</li>
<li> \b Apply is the button to create the result.</li>
<li> <b>Apply and Close</b> is the button to create the result and close
the dialog.</li>
<li> \b Close is the button to close this dialog.</li>
<li> \b Help is the button to show this help page.</li>
</ul>
<b>TUI Command:</b> <em>geompy.MakeExtraction(theShape, theListOfID),</em>
<br> where \em theShape is the main shape, \em theListOfID is a list of
sub-shape IDs to be extracted.
Our <b>TUI Scripts</b> provide you with useful example of the use of
\ref swig_MakeExtraction "Extract and Rebuild" functionality.
<b>More details</b>
If a sub-shape is extracted, all its ancestors should be modified. An ancestors
of extracted sub-shapes can be either:
- created anew without extracted sub-shapes, or
- extracted if it is not possible to create a valid shape without extracted
sub-shape.
E.g. it is necessary to extract the vertex from the box:
\image html extract_init.png "Extraction of the vertex from the box"
In this case 3 ancestor edges are removed as they can't be valid without
this vertex. 3 faces that contain these edges are also removed. It is because
the wires without edges are not closed and it is not possible to create
a valid face on not closed wire. These wires should contain two remaining
edges, but they are removed as they are the part of the remaining shell.
So these wires become empty that means that they should be removed as well.
The shell is replaced by another one that contains 3 not modified faces. As
It is not possible to construct a valid solid from not closed shell the solid
is removed. So the result of the extraction is a shell that contains 3 faces:
\image html extract_result.png "Result shape"
Please, refer to <a href="ExtractAndRebuild.pdf">this document</a> for a detailed
description of Extract and Rebuild operation.
*/

View File

@ -7,4 +7,6 @@ that can be useful for reading.
<a href="SALOME_BOA_PA.pdf">General Fuse Algorithm, Partition <a href="SALOME_BOA_PA.pdf">General Fuse Algorithm, Partition
Algorithm, Boolean Operations Algorithm. Backgrounds.</a> Algorithm, Boolean Operations Algorithm. Backgrounds.</a>
<a href="ExtractAndRebuild.pdf">Extract and Rebuild algorithm specification.</a>
*/ */

View File

@ -27,6 +27,8 @@ special case of \b Explode operation. </li>
special case of \b Explode operation. </li> special case of \b Explode operation. </li>
<li>\subpage transfer_data_page "Transfer Data" operation, which copies <li>\subpage transfer_data_page "Transfer Data" operation, which copies
non-topological data from one shape to another. </li> non-topological data from one shape to another. </li>
<li>\subpage extract_and_rebuild_page "Extract and Rebuild" operation, which
extracts sub-shapes from the main shape. </li>
<li>\subpage restore_presentation_parameters_page "Restore presentation parameters". <li>\subpage restore_presentation_parameters_page "Restore presentation parameters".

View File

@ -105,6 +105,9 @@
\until geompy.GetSubShapeEdgeSorted(Sketcher3d_2, p3, "OrderedEdges") \until geompy.GetSubShapeEdgeSorted(Sketcher3d_2, p3, "OrderedEdges")
\anchor swig_GetSubShapesWithTolerance \anchor swig_GetSubShapesWithTolerance
\until geompy.GetSubShapesWithTolerance(Box, GEOM.FACE, GEOM.CC_LE, 1.e-7, "le")
\anchor swig_MakeExtraction
\until print "DONE" \until print "DONE"
*/ */

Binary file not shown.

View File

@ -2782,6 +2782,43 @@ module GEOM
in comparison_condition theCondition, in comparison_condition theCondition,
in double theTolerance); in double theTolerance);
/**
* This enumeration represents an extraction statistics type. It is used in
* the interface GEOM_IShapesOperations::MakeExtraction.
*/
enum ExtractionStatType
{
EST_Removed, ///< Removed sub-shapes
EST_Modified, ///< Modified sub-shapes
EST_Added ///< Newly created sub-shapes
};
/*!
* This structure defines a format of extraction statistics. It is used in
* the interface GEOM_IShapesOperations::MakeExtraction.
*/
struct ExtractionStat
{
ExtractionStatType type; ///< Type of extraction statistics.
ListOfLong indices; ///< Shape indices touched by this type of modification.
};
typedef sequence<ExtractionStat> ExtractionStats;
/*!
* \brief Return the shape that is constructed from theShape without
* extracted sub-shapes from the input list.
*
* \param theShape the original shape.
* \param theSubShapeIDs the list of sub-shape IDs to be extracted from
* the original shape.
* \param theStats the operation statistics. Output parameter.
* \return the shape without extracted sub-shapes.
*/
GEOM_Object MakeExtraction(in GEOM_Object theShape,
in ListOfLong theSubShapeIDs,
out ExtractionStats theStats);
}; };
// # GEOM_IBlocksOperations: // # GEOM_IBlocksOperations:

View File

@ -94,6 +94,7 @@ SET( _res_files
edgeextension.png edgeextension.png
erase.png erase.png
eraseall.png eraseall.png
extract.png
extruded_boss.png extruded_boss.png
extruded_cut.png extruded_cut.png
facetosurface.png facetosurface.png

BIN
resources/extract.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -59,6 +59,7 @@ SET(GEOMAlgo_HEADERS
GEOMAlgo_DataMapOfPassKeyInteger.hxx GEOMAlgo_DataMapOfPassKeyInteger.hxx
GEOMAlgo_DataMapOfShapeMapOfShape.hxx GEOMAlgo_DataMapOfShapeMapOfShape.hxx
GEOMAlgo_DataMapOfShapePnt.hxx GEOMAlgo_DataMapOfShapePnt.hxx
GEOMAlgo_Extractor.hxx
GEOMAlgo_FinderShapeOn.hxx GEOMAlgo_FinderShapeOn.hxx
GEOMAlgo_FinderShapeOn1.hxx GEOMAlgo_FinderShapeOn1.hxx
GEOMAlgo_FinderShapeOn2.hxx GEOMAlgo_FinderShapeOn2.hxx
@ -123,6 +124,7 @@ SET(GEOMAlgo_SOURCES
GEOMAlgo_ClsfSurf.cxx GEOMAlgo_ClsfSurf.cxx
GEOMAlgo_CoupleOfShapes.cxx GEOMAlgo_CoupleOfShapes.cxx
GEOMAlgo_FinderShapeOn2.cxx GEOMAlgo_FinderShapeOn2.cxx
GEOMAlgo_Extractor.cxx
GEOMAlgo_GetInPlace.cxx GEOMAlgo_GetInPlace.cxx
GEOMAlgo_GetInPlace_1.cxx GEOMAlgo_GetInPlace_1.cxx
GEOMAlgo_GetInPlace_2.cxx GEOMAlgo_GetInPlace_2.cxx

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,363 @@
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File: GEOMAlgo_Extractor.hxx
// Author: Sergey KHROMOV
#ifndef _GEOMAlgo_Extractor_HeaderFile
#define _GEOMAlgo_Extractor_HeaderFile
#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;
/**
* \brief This class encapsulates an algorithm of extraction of sub-shapes
* from the main shape.
*/
class GEOMAlgo_Extractor : public GEOMAlgo_Algo
{
public:
/**
* \brief Empty constructor.
*/
Standard_EXPORT GEOMAlgo_Extractor();
/**
* \brief Virtual destructor.
*/
Standard_EXPORT virtual ~GEOMAlgo_Extractor();
/**
* \brief This method sets the main shape.
*
* \param theShape the main shape.
*/
Standard_EXPORT void SetShape(const TopoDS_Shape &theShape);
/**
* \brief This method returns the main shape.
*
* \return the main shape.
*/
const TopoDS_Shape &GetShape() const
{ return myShape; }
/**
* \brief This method sets the list of sub-shapes to be removed
* from the main shape.
*
* \param theSubShapes the sub-shapes to be removed.
*/
Standard_EXPORT void SetShapesToRemove
(const TopTools_ListOfShape &theSubShapes);
/**
* \brief This method returns the list of sub-shapes to be removed
* from the main shape.
*
* \return the list of sub-shapes to be removed.
*/
const TopTools_ListOfShape &GetShapesToRemove() const
{ return mySubShapes; }
/**
* This method performs computation of the extracted shape.
*/
Standard_EXPORT virtual void Perform();
/**
* This method returns the result of the algorithm.
*
* \return the result of the operation.
*/
Standard_EXPORT const TopoDS_Shape &GetResult() const;
/**
* \brief This method returns the sub-shapes removed from the main shape.
*
* \return the list of removed sub-shapes.
*/
const TopTools_ListOfShape &GetRemoved() const
{ return myRemoved; }
/**
* \brief This method returns the sub-shapes modified in the main shape.
*
* \return the list of modified sub-shapes.
*/
const TopTools_ListOfShape &GetModified() const
{ return myModified; }
/**
* \brief This method returns the newly created sub-shapes in the result
* shape.
*
* \return the list of new sub-shapes in result.
*/
const TopTools_ListOfShape &GetNew() const
{ return myNew; }
private:
/**
* \brief This method reinitializes the shape.
*/
void clear();
/**
* \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;
TopTools_DataMapOfShapeListOfShape myMapShapeAnc;
TopTools_MapOfShape myMapRemoved;
TopTools_DataMapOfShapeListOfShape myMapModified;
TopTools_DataMapOfShapeListOfShape myMapNewShapeAnc;
};
#endif

View File

@ -1387,6 +1387,10 @@
<source>ICO_TRANSFER_DATA</source> <source>ICO_TRANSFER_DATA</source>
<translation>transfer_data.png</translation> <translation>transfer_data.png</translation>
</message> </message>
<message>
<source>ICO_EXTRACTION</source>
<translation>extract.png</translation>
</message>
<message> <message>
<source>ICO_IMPORT_SHAPE</source> <source>ICO_IMPORT_SHAPE</source>
<translation>import.png</translation> <translation>import.png</translation>
@ -1407,6 +1411,10 @@
<source>ICON_DLG_TRANSFER_DATA</source> <source>ICON_DLG_TRANSFER_DATA</source>
<translation>transfer_data.png</translation> <translation>transfer_data.png</translation>
</message> </message>
<message>
<source>ICON_DLG_EXTRACTION</source>
<translation>extract.png</translation>
</message>
<message> <message>
<source>ICON_DLG_SCALE_ALONG_AXES</source> <source>ICON_DLG_SCALE_ALONG_AXES</source>
<translation>scale_along_axes.png</translation> <translation>scale_along_axes.png</translation>

View File

@ -471,6 +471,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_COMPOUNDSOLID</source> <source>GEOM_COMPOUNDSOLID</source>
<translation>CompSolid</translation> <translation>CompSolid</translation>
</message> </message>
<message>
<source>GEOM_COMPSOLIDS</source>
<translation>CompSolids</translation>
</message>
<message> <message>
<source>GEOM_COMPOUND_TITLE</source> <source>GEOM_COMPOUND_TITLE</source>
<translation>Create A Compound</translation> <translation>Create A Compound</translation>
@ -607,6 +611,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_EDGE</source> <source>GEOM_EDGE</source>
<translation>Edge</translation> <translation>Edge</translation>
</message> </message>
<message>
<source>GEOM_EDGES</source>
<translation>Edges</translation>
</message>
<message> <message>
<source>GEOM_EDGE_TITLE</source> <source>GEOM_EDGE_TITLE</source>
<translation>Create An Edge</translation> <translation>Create An Edge</translation>
@ -2024,6 +2032,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_SOLID</source> <source>GEOM_SOLID</source>
<translation>Solid</translation> <translation>Solid</translation>
</message> </message>
<message>
<source>GEOM_SOLIDS</source>
<translation>Solids</translation>
</message>
<message> <message>
<source>GEOM_SOLID_TITLE</source> <source>GEOM_SOLID_TITLE</source>
<translation>Solid Construction</translation> <translation>Solid Construction</translation>
@ -5236,6 +5248,18 @@ Please, select face, shell or solid and try again</translation>
<source>STB_TRANSFER_DATA</source> <source>STB_TRANSFER_DATA</source>
<translation>Transfer Data</translation> <translation>Transfer Data</translation>
</message> </message>
<message>
<source>TOP_EXTRACTION</source>
<translation>Extract and Rebuild</translation>
</message>
<message>
<source>MEN_EXTRACTION</source>
<translation>Extract and Rebuild</translation>
</message>
<message>
<source>STB_EXTRACTION</source>
<translation>Extract and Rebuild</translation>
</message>
<message> <message>
<source>TOP_EXTENSION</source> <source>TOP_EXTENSION</source>
<translation>Extend Edge or Face</translation> <translation>Extend Edge or Face</translation>
@ -7629,4 +7653,55 @@ Do you want to create new material?</translation>
<translation>Rotation angle</translation> <translation>Rotation angle</translation>
</message> </message>
</context> </context>
<context>
<name>OperationGUI_ExtractionDlg</name>
<message>
<source>GEOM_EXTRACT_TITLE</source>
<translation>Extract and Rebuild</translation>
</message>
<message>
<source>GEOM_EXTRACT_TYPE</source>
<translation>Extraction type</translation>
</message>
<message>
<source>GEOM_EXTRACT_INPUT_PARAMS</source>
<translation>Input parameters</translation>
</message>
<message>
<source>GEOM_EXTRACT_STATISTICS</source>
<translation>Statistics</translation>
</message>
<message>
<source>GEOM_EXTRACT_SUB_SHAPE_TYPE</source>
<translation>Sub-shape type</translation>
</message>
<message>
<source>GEOM_EXTRACT_FILTERED_SHAPES</source>
<translation>Filtered shapes</translation>
</message>
<message>
<source>GEOM_EXTRACT_SHAPES_TO_EXTRACT</source>
<translation>Shapes to extract</translation>
</message>
<message>
<source>GEOM_EXTRACT_REBUILD</source>
<translation>Rebuild</translation>
</message>
<message>
<source>GEOM_EXTRACT_REMOVED</source>
<translation>Removed</translation>
</message>
<message>
<source>GEOM_EXTRACT_MODIFIED</source>
<translation>Modified</translation>
</message>
<message>
<source>GEOM_EXTRACT_ADDED</source>
<translation>Added</translation>
</message>
<message>
<source>GEOM_EXTRACT_NAME</source>
<translation>Extraction</translation>
</message>
</context>
</TS> </TS>

View File

@ -471,6 +471,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>GEOM_COMPOUNDSOLID</source> <source>GEOM_COMPOUNDSOLID</source>
<translation>Assemblage solide</translation> <translation>Assemblage solide</translation>
</message> </message>
<message>
<source>GEOM_COMPSOLIDS</source>
<translation type="unfinished">CompSolids</translation>
</message>
<message> <message>
<source>GEOM_COMPOUND_TITLE</source> <source>GEOM_COMPOUND_TITLE</source>
<translation>Créer un assemblage</translation> <translation>Créer un assemblage</translation>
@ -607,6 +611,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>GEOM_EDGE</source> <source>GEOM_EDGE</source>
<translation>Arête</translation> <translation>Arête</translation>
</message> </message>
<message>
<source>GEOM_EDGES</source>
<translation type="unfinished">Edges</translation>
</message>
<message> <message>
<source>GEOM_EDGE_TITLE</source> <source>GEOM_EDGE_TITLE</source>
<translation>Créer une arête</translation> <translation>Créer une arête</translation>
@ -2016,6 +2024,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>GEOM_SOLID</source> <source>GEOM_SOLID</source>
<translation>Solide</translation> <translation>Solide</translation>
</message> </message>
<message>
<source>GEOM_SOLIDS</source>
<translation type="unfinished">Solids</translation>
</message>
<message> <message>
<source>GEOM_SOLID_TITLE</source> <source>GEOM_SOLID_TITLE</source>
<translation>Construction d&apos;un solide</translation> <translation>Construction d&apos;un solide</translation>
@ -5228,6 +5240,18 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>STB_TRANSFER_DATA</source> <source>STB_TRANSFER_DATA</source>
<translation>Transfert de données</translation> <translation>Transfert de données</translation>
</message> </message>
<message>
<source>TOP_EXTRACTION</source>
<translation type="unfinished">Extract and Rebuild</translation>
</message>
<message>
<source>MEN_EXTRACTION</source>
<translation type="unfinished">Extract and Rebuild</translation>
</message>
<message>
<source>STB_EXTRACTION</source>
<translation type="unfinished">Extract and Rebuild</translation>
</message>
<message> <message>
<source>TOP_EXTENSION</source> <source>TOP_EXTENSION</source>
<translation>Extend Edge or Face</translation> <translation>Extend Edge or Face</translation>
@ -7605,4 +7629,55 @@ Voulez-vous en créer un nouveau ?</translation>
<translation>Longueur de l&apos;angle</translation> <translation>Longueur de l&apos;angle</translation>
</message> </message>
</context> </context>
<context>
<name>OperationGUI_ExtractionDlg</name>
<message>
<source>GEOM_EXTRACT_TITLE</source>
<translation type="unfinished">Extract and Rebuild</translation>
</message>
<message>
<source>GEOM_EXTRACT_TYPE</source>
<translation type="unfinished">Extraction type</translation>
</message>
<message>
<source>GEOM_EXTRACT_INPUT_PARAMS</source>
<translation type="unfinished">Input parameters</translation>
</message>
<message>
<source>GEOM_EXTRACT_STATISTICS</source>
<translation type="unfinished">Statistics</translation>
</message>
<message>
<source>GEOM_EXTRACT_SUB_SHAPE_TYPE</source>
<translation type="unfinished">Sub-shape type</translation>
</message>
<message>
<source>GEOM_EXTRACT_FILTERED_SHAPES</source>
<translation type="unfinished">Filtered shapes</translation>
</message>
<message>
<source>GEOM_EXTRACT_SHAPES_TO_EXTRACT</source>
<translation type="unfinished">Shapes to extract</translation>
</message>
<message>
<source>GEOM_EXTRACT_REBUILD</source>
<translation type="unfinished">Rebuild</translation>
</message>
<message>
<source>GEOM_EXTRACT_REMOVED</source>
<translation type="unfinished">Removed</translation>
</message>
<message>
<source>GEOM_EXTRACT_MODIFIED</source>
<translation type="unfinished">Modified</translation>
</message>
<message>
<source>GEOM_EXTRACT_ADDED</source>
<translation type="unfinished">Added</translation>
</message>
<message>
<source>GEOM_EXTRACT_NAME</source>
<translation type="unfinished">Extraction</translation>
</message>
</context>
</TS> </TS>

View File

@ -467,6 +467,10 @@
<source>GEOM_COMPOUNDSOLID</source> <source>GEOM_COMPOUNDSOLID</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>GEOM_COMPSOLIDS</source>
<translation type="unfinished">CompSolids</translation>
</message>
<message> <message>
<source>GEOM_COMPOUND_TITLE</source> <source>GEOM_COMPOUND_TITLE</source>
<translation></translation> <translation></translation>
@ -603,6 +607,10 @@
<source>GEOM_EDGE</source> <source>GEOM_EDGE</source>
<translation>Edge</translation> <translation>Edge</translation>
</message> </message>
<message>
<source>GEOM_EDGES</source>
<translation type="unfinished">Edges</translation>
</message>
<message> <message>
<source>GEOM_EDGE_TITLE</source> <source>GEOM_EDGE_TITLE</source>
<translation></translation> <translation></translation>
@ -2019,6 +2027,10 @@
<source>GEOM_SOLID</source> <source>GEOM_SOLID</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>GEOM_SOLIDS</source>
<translation type="unfinished">Solids</translation>
</message>
<message> <message>
<source>GEOM_SOLID_TITLE</source> <source>GEOM_SOLID_TITLE</source>
<translation></translation> <translation></translation>
@ -5231,6 +5243,18 @@
<source>STB_TRANSFER_DATA</source> <source>STB_TRANSFER_DATA</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>TOP_EXTRACTION</source>
<translation type="unfinished">Extract and Rebuild</translation>
</message>
<message>
<source>MEN_EXTRACTION</source>
<translation type="unfinished">Extract and Rebuild</translation>
</message>
<message>
<source>STB_EXTRACTION</source>
<translation type="unfinished">Extract and Rebuild</translation>
</message>
<message> <message>
<source>TOP_EXTENSION</source> <source>TOP_EXTENSION</source>
<translation></translation> <translation></translation>
@ -7598,4 +7622,55 @@
<translation></translation> <translation></translation>
</message> </message>
</context> </context>
<context>
<name>OperationGUI_ExtractionDlg</name>
<message>
<source>GEOM_EXTRACT_TITLE</source>
<translation type="unfinished">Extract and Rebuild</translation>
</message>
<message>
<source>GEOM_EXTRACT_TYPE</source>
<translation type="unfinished">Extraction type</translation>
</message>
<message>
<source>GEOM_EXTRACT_INPUT_PARAMS</source>
<translation type="unfinished">Input parameters</translation>
</message>
<message>
<source>GEOM_EXTRACT_STATISTICS</source>
<translation type="unfinished">Statistics</translation>
</message>
<message>
<source>GEOM_EXTRACT_SUB_SHAPE_TYPE</source>
<translation type="unfinished">Sub-shape type</translation>
</message>
<message>
<source>GEOM_EXTRACT_FILTERED_SHAPES</source>
<translation type="unfinished">Filtered shapes</translation>
</message>
<message>
<source>GEOM_EXTRACT_SHAPES_TO_EXTRACT</source>
<translation type="unfinished">Shapes to extract</translation>
</message>
<message>
<source>GEOM_EXTRACT_REBUILD</source>
<translation type="unfinished">Rebuild</translation>
</message>
<message>
<source>GEOM_EXTRACT_REMOVED</source>
<translation type="unfinished">Removed</translation>
</message>
<message>
<source>GEOM_EXTRACT_MODIFIED</source>
<translation type="unfinished">Modified</translation>
</message>
<message>
<source>GEOM_EXTRACT_ADDED</source>
<translation type="unfinished">Added</translation>
</message>
<message>
<source>GEOM_EXTRACT_NAME</source>
<translation type="unfinished">Extraction</translation>
</message>
</context>
</TS> </TS>

View File

@ -623,6 +623,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
case GEOMOp::OpTransferData: // MENU OPERATION - TRANSFER DATA case GEOMOp::OpTransferData: // MENU OPERATION - TRANSFER DATA
case GEOMOp::OpExtraction: // MENU OPERATION - EXTRACT AND REBUILD
libName = "OperationGUI"; libName = "OperationGUI";
break; break;
case GEOMOp::OpSewing: // MENU REPAIR - SEWING case GEOMOp::OpSewing: // MENU REPAIR - SEWING
@ -1005,6 +1006,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" ); createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" ); createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
createGeomAction( GEOMOp::OpTransferData, "TRANSFER_DATA" ); createGeomAction( GEOMOp::OpTransferData, "TRANSFER_DATA" );
createGeomAction( GEOMOp::OpExtraction, "EXTRACTION" );
createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" ); createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" ); createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" ); createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
@ -1262,6 +1264,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createMenu( GEOMOp::OpShapesOnShape, operId, -1 ); createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
createMenu( GEOMOp::OpSharedShapes, operId, -1 ); createMenu( GEOMOp::OpSharedShapes, operId, -1 );
createMenu( GEOMOp::OpTransferData, operId, -1 ); createMenu( GEOMOp::OpTransferData, operId, -1 );
createMenu( GEOMOp::OpExtraction, operId, -1 );
createMenu( separator(), operId, -1 ); createMenu( separator(), operId, -1 );
@ -1438,6 +1441,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createTool( GEOMOp::OpShapesOnShape, operTbId ); createTool( GEOMOp::OpShapesOnShape, operTbId );
createTool( GEOMOp::OpSharedShapes, operTbId ); createTool( GEOMOp::OpSharedShapes, operTbId );
createTool( GEOMOp::OpTransferData, operTbId ); createTool( GEOMOp::OpTransferData, operTbId );
createTool( GEOMOp::OpExtraction, operTbId );
int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) ); int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) );
createTool( GEOMOp::OpFillet1d, featTbId ); createTool( GEOMOp::OpFillet1d, featTbId );

View File

@ -166,6 +166,7 @@ namespace GEOMOp {
OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS
OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT
OpTransferData = 3711, // MENU OPERATION - TRANSFER DATA OpTransferData = 3711, // MENU OPERATION - TRANSFER DATA
OpExtraction = 3712, // MENU OPERATION - EXTRACT AND REBUILD
// RepairGUI -------------------//-------------------------------- // RepairGUI -------------------//--------------------------------
OpSewing = 4000, // MENU REPAIR - SEWING OpSewing = 4000, // MENU REPAIR - SEWING
OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES

View File

@ -79,6 +79,7 @@ SET(GEOMImpl_HEADERS
GEOMImpl_ICircle.hxx GEOMImpl_ICircle.hxx
GEOMImpl_ISpline.hxx GEOMImpl_ISpline.hxx
GEOMImpl_IEllipse.hxx GEOMImpl_IEllipse.hxx
GEOMImpl_IExtract.hxx
GEOMImpl_IFillet.hxx GEOMImpl_IFillet.hxx
GEOMImpl_IFillet1d.hxx GEOMImpl_IFillet1d.hxx
GEOMImpl_IFillet2d.hxx GEOMImpl_IFillet2d.hxx

View File

@ -0,0 +1,73 @@
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//NOTE: This is an intreface to a function for the Offset creation.
//
#include "GEOM_Function.hxx"
#include <TColStd_HArray1OfInteger.hxx>
#define EXTRACT_SHAPE 1
#define EXTRACT_IDS 2
#define EXTRACT_REMOVED_IDS 3
#define EXTRACT_MODIFIED_IDS 4
#define EXTRACT_ADDED_IDS 5
class GEOMImpl_IExtract
{
public:
GEOMImpl_IExtract(Handle(GEOM_Function) theFunction): _func(theFunction) {}
void SetShape(Handle(GEOM_Function) theShape)
{ _func->SetReference(EXTRACT_SHAPE, theShape); }
Handle(GEOM_Function) GetShape()
{ return _func->GetReference(EXTRACT_SHAPE); }
void SetSubShapeIDs(const Handle(TColStd_HArray1OfInteger)& theSubShapeIDs)
{ _func->SetIntegerArray(EXTRACT_IDS, theSubShapeIDs); }
Handle(TColStd_HArray1OfInteger) GetSubShapeIDs()
{ return _func->GetIntegerArray(EXTRACT_IDS); }
void SetRemovedIDs(const Handle(TColStd_HArray1OfInteger)& theRemovedIDs)
{ _func->SetIntegerArray(EXTRACT_REMOVED_IDS, theRemovedIDs); }
Handle(TColStd_HArray1OfInteger) GetRemovedIDs()
{ return _func->GetIntegerArray(EXTRACT_REMOVED_IDS); }
void SetModifiedIDs(const Handle(TColStd_HArray1OfInteger)& theModifiedIDs)
{ _func->SetIntegerArray(EXTRACT_MODIFIED_IDS, theModifiedIDs); }
Handle(TColStd_HArray1OfInteger) GetModifiedIDs()
{ return _func->GetIntegerArray(EXTRACT_MODIFIED_IDS); }
void SetAddedIDs(const Handle(TColStd_HArray1OfInteger)& theAddedIDs)
{ _func->SetIntegerArray(EXTRACT_ADDED_IDS, theAddedIDs); }
Handle(TColStd_HArray1OfInteger) GetAddedIDs()
{ return _func->GetIntegerArray(EXTRACT_ADDED_IDS); }
private:
Handle(GEOM_Function) _func;
};

View File

@ -36,6 +36,7 @@
#include "GEOMImpl_GlueDriver.hxx" #include "GEOMImpl_GlueDriver.hxx"
#include "GEOMImpl_FillingDriver.hxx" #include "GEOMImpl_FillingDriver.hxx"
#include "GEOMImpl_IExtract.hxx"
#include "GEOMImpl_IVector.hxx" #include "GEOMImpl_IVector.hxx"
#include "GEOMImpl_IShapes.hxx" #include "GEOMImpl_IShapes.hxx"
#include "GEOMImpl_IShapeExtend.hxx" #include "GEOMImpl_IShapeExtend.hxx"
@ -3163,6 +3164,107 @@ Handle(TColStd_HSequenceOfTransient)
return aSeq; return aSeq;
} }
//=============================================================================
/*!
* MakeExtraction
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeExtraction
(const Handle(GEOM_Object) &theShape,
const Handle(TColStd_HArray1OfInteger) &theSubShapeIDs,
std::list<ExtractionStat> &theStats)
{
SetErrorCode(KO);
if (theShape.IsNull()) {
return NULL;
}
//Add a new Result object
Handle(GEOM_Object) aResult =
GetEngine()->AddObject(GetDocID(), GEOM_EXTRACTION);
//Add a new Extraction function
Handle(GEOM_Function) aFunction =
aResult->AddFunction(GEOMImpl_ShapeDriver::GetID(), EXTRACTION);
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) {
return NULL;
}
Handle(GEOM_Function) aShape = theShape->GetLastFunction();
if (aShape.IsNull()) {
return NULL;
}
GEOMImpl_IExtract aCI (aFunction);
aCI.SetShape(aShape);
aCI.SetSubShapeIDs(theSubShapeIDs);
//Compute the Edge value
try {
OCC_CATCH_SIGNALS;
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed");
return NULL;
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
// Fill in statistics.
theStats.clear();
Handle(TColStd_HArray1OfInteger) aStatIDsArray[3] =
{ aCI.GetRemovedIDs(), aCI.GetModifiedIDs(), aCI.GetAddedIDs() };
int i;
int j;
for (j = 0; j < 3; ++j) {
if (!aStatIDsArray[j].IsNull()) {
const int anUpperID = aStatIDsArray[j]->Upper();
ExtractionStat aStat;
for (i = aStatIDsArray[j]->Lower(); i <= anUpperID; ++i) {
aStat.indices.push_back(aStatIDsArray[j]->Value(i));
}
aStat.type = (ExtractionStatType) j;
theStats.push_back(aStat);
}
}
//Make a Python command
GEOM::TPythonDump pd(aFunction);
pd << aResult << " = geompy.MakeExtraction(" << theShape << ", [";
if (!theSubShapeIDs.IsNull()) {
const int aNbIDs = theSubShapeIDs->Upper();
for (i = theSubShapeIDs->Lower(); i < aNbIDs; ++i) {
pd << theSubShapeIDs->Value(i) << ", ";
}
// Dump the last value without a comma.
pd << theSubShapeIDs->Value(i);
}
pd << "])";
SetErrorCode(OK);
return aResult;
}
//======================================================================= //=======================================================================
//function : getShapesOnSurfaceIDs //function : getShapesOnSurfaceIDs
/*! /*!

View File

@ -59,6 +59,25 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations
All = Groups | Fields | SubShapes, All = Groups | Fields | SubShapes,
}; };
/**
* This enumeration represents an extraction statistics type.
*/
enum ExtractionStatType
{
EST_Removed, ///< Removed sub-shapes
EST_Modified, ///< Modified sub-shapes
EST_Added ///< Newly created sub-shapes
};
/*!
* This structure defines a format of extraction statistics.
*/
struct ExtractionStat
{
ExtractionStatType type; ///< Type of extraction statistics.
std::list<Standard_Integer> indices; ///< Shape indices touched by this type of modification.
};
Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID); Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
Standard_EXPORT ~GEOMImpl_IShapesOperations(); Standard_EXPORT ~GEOMImpl_IShapesOperations();
@ -470,6 +489,21 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations
const GEOMUtils::ComparisonCondition theCondition, const GEOMUtils::ComparisonCondition theCondition,
const Standard_Real theTolerance); const Standard_Real theTolerance);
/*!
* \brief Return the shape that is constructed from theShape without
* extracted sub-shapes from the input list.
*
* \param theShape the original shape.
* \param theSubShapeIDs the list of sub-shape IDs to be extracted from
* the original shape.
* \param theStats the operation statistics. Output parameter.
* \return the shape without extracted sub-shapes.
*/
Handle(GEOM_Object) MakeExtraction
(const Handle(GEOM_Object) &theShape,
const Handle(TColStd_HArray1OfInteger) &theSubShapeIDs,
std::list<ExtractionStat> &theStats);
private: private:
Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes, Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
const Standard_Integer theObjectType, const Standard_Integer theObjectType,

View File

@ -22,6 +22,7 @@
#include <GEOMImpl_ShapeDriver.hxx> #include <GEOMImpl_ShapeDriver.hxx>
#include <GEOMImpl_IExtract.hxx>
#include <GEOMImpl_IIsoline.hxx> #include <GEOMImpl_IIsoline.hxx>
#include <GEOMImpl_IShapes.hxx> #include <GEOMImpl_IShapes.hxx>
#include <GEOMImpl_IShapeExtend.hxx> #include <GEOMImpl_IShapeExtend.hxx>
@ -32,6 +33,7 @@
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
#include <GEOMUtils_Hatcher.hxx> #include <GEOMUtils_Hatcher.hxx>
#include <GEOMAlgo_State.hxx> #include <GEOMAlgo_State.hxx>
#include <GEOMAlgo_Extractor.hxx>
// OCCT Includes // OCCT Includes
#include <ShapeFix_Wire.hxx> #include <ShapeFix_Wire.hxx>
@ -109,6 +111,39 @@
#include <list> #include <list>
/**
* \brief This static function converts the list of shapes into an array
* of their IDs. If the input list is empty, null handle will be returned.
* this method doesn't check if a shape presents in theIndices map.
*
* \param theListOfShapes the list of shapes.
* \param theIndices the indexed map of shapes.
* \return the array of shape IDs.
*/
static Handle(TColStd_HArray1OfInteger) GetShapeIDs
(const TopTools_ListOfShape &theListOfShapes,
const TopTools_IndexedMapOfShape &theIndices)
{
Handle(TColStd_HArray1OfInteger) aResult;
if (!theListOfShapes.IsEmpty()) {
const Standard_Integer aNbShapes = theListOfShapes.Extent();
TopTools_ListIteratorOfListOfShape anIter(theListOfShapes);
Standard_Integer i;
aResult = new TColStd_HArray1OfInteger(1, aNbShapes);
for (i = 1; anIter.More(); anIter.Next(), ++i) {
const TopoDS_Shape &aShape = anIter.Value();
const Standard_Integer anIndex = theIndices.FindIndex(aShape);
aResult->SetValue(i, anIndex);
}
}
return aResult;
}
namespace namespace
{ {
// check that compound includes only shapes of expected type // check that compound includes only shapes of expected type
@ -918,6 +953,97 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
} }
} }
} }
} else if (aType == EXTRACTION) {
allowCompound = true;
GEOMImpl_IExtract aCI(aFunction);
Handle(GEOM_Function) aRefShape = aCI.GetShape();
TopoDS_Shape aShapeBase = aRefShape->GetValue();
if (aShapeBase.IsNull()) {
Standard_NullObject::Raise("Argument Shape is null");
return 0;
}
Handle(TColStd_HArray1OfInteger) anIDs = aCI.GetSubShapeIDs();
TopTools_ListOfShape aListSubShapes;
TopTools_IndexedMapOfShape anIndices;
int i;
TopExp::MapShapes(aShapeBase, anIndices);
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);
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);
}
}
// Compute extraction.
GEOMAlgo_Extractor anExtractor;
anExtractor.SetShape(aShapeBase);
anExtractor.SetShapesToRemove(aListSubShapes);
anExtractor.Perform();
// Interprete results
Standard_Integer iErr = anExtractor.ErrorStatus();
// The detailed description of error codes is in GEOMAlgo_Extractor.cxx
if (iErr) {
TCollection_AsciiString aMsg(" iErr : ");
aMsg += TCollection_AsciiString(iErr);
StdFail_NotDone::Raise(aMsg.ToCString());
return 0;
}
aShape = anExtractor.GetResult();
// Get statistics.
const TopTools_ListOfShape &aRemoved = anExtractor.GetRemoved();
const TopTools_ListOfShape &aModified = anExtractor.GetModified();
const TopTools_ListOfShape &aNew = anExtractor.GetNew();
Handle(TColStd_HArray1OfInteger) aRemovedIDs =
GetShapeIDs(aRemoved, anIndices);
Handle(TColStd_HArray1OfInteger) aModifiedIDs =
GetShapeIDs(aModified, anIndices);
Handle(TColStd_HArray1OfInteger) aNewIDs;
if (!aShape.IsNull()) {
// Get newly created sub-shapes
TopTools_IndexedMapOfShape aNewIndices;
TopExp::MapShapes(aShape, aNewIndices);
aNewIDs = GetShapeIDs(aNew, aNewIndices);
}
if (!aRemovedIDs.IsNull()) {
aCI.SetRemovedIDs(aRemovedIDs);
}
if (!aModifiedIDs.IsNull()) {
aCI.SetModifiedIDs(aModifiedIDs);
}
if (!aNewIDs.IsNull()) {
aCI.SetAddedIDs(aNewIDs);
}
} }
else { else {
} }
@ -1880,6 +2006,15 @@ GetCreationInformation(std::string& theOperationName,
AddParam(theParams, "Face", aSE.GetShape()); AddParam(theParams, "Face", aSE.GetShape());
break; break;
} }
case EXTRACTION:
{
GEOMImpl_IExtract aCI (function);
theOperationName = "EXTRACTION";
AddParam(theParams, "Main Shape", aCI.GetShape());
AddParam(theParams, "Sub-shape IDs", aCI.GetSubShapeIDs());
break;
}
default: default:
return false; return false;
} }

View File

@ -119,6 +119,8 @@
#define GEOM_TRANSFER_DATA 57 #define GEOM_TRANSFER_DATA 57
#define GEOM_EXTRACTION 58
//GEOM_Function types //GEOM_Function types
#define COPY_WITH_REF 1 #define COPY_WITH_REF 1
@ -316,6 +318,7 @@
#define FACE_UV 17 #define FACE_UV 17
#define SURFACE_FROM_FACE 18 #define SURFACE_FROM_FACE 18
#define SOLID_FACES 19 #define SOLID_FACES 19
#define EXTRACTION 20
#define ARCHIMEDE_TYPE 1 #define ARCHIMEDE_TYPE 1

View File

@ -2230,3 +2230,98 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapesWithTolerance
return aSeq._retn(); return aSeq._retn();
} }
//=============================================================================
/*!
* MakeExtraction
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeExtraction
(GEOM::GEOM_Object_ptr theShape,
const GEOM::ListOfLong &theSubShapeIDs,
GEOM::GEOM_IShapesOperations::ExtractionStats_out theStats)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
theStats = new GEOM::GEOM_IShapesOperations::ExtractionStats;
GetOperations()->SetNotDone();
//Get the reference object
Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
if (aShape.IsNull()) {
return aGEOMObject._retn();
}
const int aNbIDs = theSubShapeIDs.length();
if (aNbIDs == 0) {
return aGEOMObject._retn();
}
int i;
Handle(TColStd_HArray1OfInteger) anArray =
new TColStd_HArray1OfInteger (1, aNbIDs);
for (i = 0; i < aNbIDs; i++) {
anArray->SetValue(i + 1, theSubShapeIDs[i]);
}
//Get Shapes in place of aShapeWhat
std::list<GEOMImpl_IShapesOperations::ExtractionStat> aStats;
Handle(GEOM_Object) aResult =
GetOperations()->MakeExtraction(aShape, anArray, aStats);
if (!GetOperations()->IsDone() || aResult.IsNull()) {
return aGEOMObject._retn();
}
// Convert statistics.
const int aNbStats = aStats.size();
theStats->length(aNbStats);
// fill the local CORBA array with values from lists
std::list<GEOMImpl_IShapesOperations::ExtractionStat>::const_iterator
anIt = aStats.begin();
for (i = 0; anIt != aStats.end(); i++, anIt++) {
GEOM::GEOM_IShapesOperations::ExtractionStat_var aResStat =
new GEOM::GEOM_IShapesOperations::ExtractionStat;
// Copy type
switch (anIt->type) {
case GEOMImpl_IShapesOperations::EST_Removed:
aResStat->type = GEOM::GEOM_IShapesOperations::EST_Removed;
break;
case GEOMImpl_IShapesOperations::EST_Modified:
aResStat->type = GEOM::GEOM_IShapesOperations::EST_Modified;
break;
case GEOMImpl_IShapesOperations::EST_Added:
aResStat->type = GEOM::GEOM_IShapesOperations::EST_Added;
break;
default:
break;
}
// Copy the list of IDs
std::list<Standard_Integer> aIDList = anIt->indices;
GEOM::ListOfLong_var aResIDList = new GEOM::ListOfLong;
aResIDList->length(aIDList.size());
std::list<Standard_Integer>::iterator anIDIt = aIDList.begin();
int j = 0;
for (; anIDIt != aIDList.end(); j++, anIDIt++) {
aResIDList[j] = *anIDIt;
}
aResStat->indices = aResIDList;
theStats[i] = aResStat;
}
return GetObject(aResult);
}

View File

@ -306,6 +306,11 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i :
GEOM::comparison_condition theCondition, GEOM::comparison_condition theCondition,
CORBA::Double theTolerance); CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr MakeExtraction
(GEOM::GEOM_Object_ptr theShape,
const GEOM::ListOfLong &theSubShapeIDs,
GEOM::GEOM_IShapesOperations::ExtractionStats_out theStats);
::GEOMImpl_IShapesOperations* GetOperations() ::GEOMImpl_IShapesOperations* GetOperations()
{ return (::GEOMImpl_IShapesOperations*)GetImpl(); } { return (::GEOMImpl_IShapesOperations*)GetImpl(); }
}; };

View File

@ -590,5 +590,10 @@ def TestAll (geompy, math):
geompy.GetSubShapesWithTolerance(Box, GEOM.FACE, GEOM.CC_LT, 2.e-7, "lt") geompy.GetSubShapesWithTolerance(Box, GEOM.FACE, GEOM.CC_LT, 2.e-7, "lt")
geompy.GetSubShapesWithTolerance(Box, GEOM.FACE, GEOM.CC_LE, 1.e-7, "le") geompy.GetSubShapesWithTolerance(Box, GEOM.FACE, GEOM.CC_LE, 1.e-7, "le")
# MakeExtraction
geompy.MakeExtraction(Box, [13], "Ext_no_face")
geompy.MakeExtraction(Box, [18], "Ext_no_edge")
geompy.MakeExtraction(Box, [16], "Ext_no_vertex")
print "DONE" print "DONE"

View File

@ -6661,6 +6661,35 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
RaiseIfFailed("IsSubShapeBelongsTo", self.ShapesOp) RaiseIfFailed("IsSubShapeBelongsTo", self.ShapesOp)
return IsOk 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 swig_MakeExtraction "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 # end of l4_decompose
## @} ## @}

View File

@ -73,6 +73,7 @@ SET(OperationGUI_HEADERS
OperationGUI_ChamferDlg.h OperationGUI_ChamferDlg.h
OperationGUI_GetShapesOnShapeDlg.h OperationGUI_GetShapesOnShapeDlg.h
OperationGUI_GetSharedShapesDlg.h OperationGUI_GetSharedShapesDlg.h
OperationGUI_ExtractionDlg.h
OperationGUI_ExtrudedFeatureDlg.h OperationGUI_ExtrudedFeatureDlg.h
OperationGUI_ClippingDlg.h OperationGUI_ClippingDlg.h
OperationGUI_TransferDataDlg.h OperationGUI_TransferDataDlg.h
@ -87,6 +88,7 @@ SET(_moc_HEADERS
OperationGUI_ChamferDlg.h OperationGUI_ChamferDlg.h
OperationGUI_GetShapesOnShapeDlg.h OperationGUI_GetShapesOnShapeDlg.h
OperationGUI_GetSharedShapesDlg.h OperationGUI_GetSharedShapesDlg.h
OperationGUI_ExtractionDlg.h
OperationGUI_ExtrudedFeatureDlg.h OperationGUI_ExtrudedFeatureDlg.h
OperationGUI_ClippingDlg.h OperationGUI_ClippingDlg.h
OperationGUI_TransferDataDlg.h OperationGUI_TransferDataDlg.h
@ -109,6 +111,7 @@ SET(OperationGUI_SOURCES
OperationGUI_FilletDlg.cxx OperationGUI_FilletDlg.cxx
OperationGUI_Fillet1d2dDlg.cxx OperationGUI_Fillet1d2dDlg.cxx
OperationGUI_ChamferDlg.cxx OperationGUI_ChamferDlg.cxx
OperationGUI_ExtractionDlg.cxx
OperationGUI_ExtrudedFeatureDlg.cxx OperationGUI_ExtrudedFeatureDlg.cxx
OperationGUI_ClippingDlg.cxx OperationGUI_ClippingDlg.cxx
OperationGUI_TransferDataDlg.cxx OperationGUI_TransferDataDlg.cxx

View File

@ -40,6 +40,7 @@
#include "OperationGUI_GetSharedShapesDlg.h" #include "OperationGUI_GetSharedShapesDlg.h"
#include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT #include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT
#include "OperationGUI_TransferDataDlg.h" #include "OperationGUI_TransferDataDlg.h"
#include "OperationGUI_ExtractionDlg.h"
//======================================================================= //=======================================================================
// function : OperationGUI() // function : OperationGUI()
@ -83,6 +84,7 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break; case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break;
case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break; case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break;
case GEOMOp::OpTransferData: (new OperationGUI_TransferDataDlg (getGeometryGUI(), parent))->show(); break; case GEOMOp::OpTransferData: (new OperationGUI_TransferDataDlg (getGeometryGUI(), parent))->show(); break;
case GEOMOp::OpExtraction: (new OperationGUI_ExtractionDlg (getGeometryGUI(), parent))->show(); break;
default: default:
app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef OPERATIONGUI_EXTRACTIONDLG_H
#define OPERATIONGUI_EXTRACTIONDLG_H
#include <GEOMBase_Skeleton.h>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TColStd_MapOfInteger.hxx>
class QComboBox;
class QListWidget;
class QTreeWidget;
class QTreeWidgetItem;
//=================================================================================
// class : OperationGUI_ExtractionDlg
// purpose :
//=================================================================================
class OperationGUI_ExtractionDlg : public GEOMBase_Skeleton
{
Q_OBJECT
public:
OperationGUI_ExtractionDlg( GeometryGUI*, QWidget* );
~OperationGUI_ExtractionDlg();
protected:
// redefined from GEOMBase_Helper and MeasureGUI_Skeleton
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool execute(ObjectList &);
virtual void activateSelection();
virtual bool isValid( QString& );
private slots:
void SelectionIntoArgument();
void ClickOnOk();
bool ClickOnApply();
void onShapeTypeChanged();
void onAddExtracted();
void onRemoveExtracted();
void onListSelectionChanged();
void showOnlySelected();
void hideSelected();
void showAllSelected();
void onRebuild();
void ActivateThisDialog();
void SetEditCurrentArgument();
private:
void Init();
bool updateSubShTypeCompo();
void updateFilteredList();
void resetBuildData(const bool isEnableBuild);
bool isEmptyExtracted();
void selectMainShape();
void selectSubShapes();
void enterEvent(QEvent *);
bool getResult
(GEOM::GEOM_Object_ptr &theResult,
GEOM::GEOM_IShapesOperations::ExtractionStats &theStats);
QString getSubShapeEntry(const int theId);
Handle_SALOME_InteractiveObject createIO(const char *theEntry);
void displaySubShape(const int theId);
void eraseSubShape(const int theId);
void eraseAll();
void restoreViewer();
private:
GEOM::GEOM_Object_var myObj;
QPushButton *mySelBtn;
QLineEdit *myMainShapeEdit;
QComboBox *mySubShTypeCompo;
QListWidget *myFilteredList;
QTreeWidget *myExtractedTree;
QListWidget *myRemovedList;
QListWidget *myModifiedList;
QListWidget *myAddedList;
QTreeWidgetItem *myTopItems[8];
QPushButton *myRebuildBtn;
TColStd_MapOfInteger myMapExtractedIDs;
bool myIsHiddenMain;
TColStd_MapOfInteger myMapDisplayedIDs;
TopTools_IndexedMapOfShape myIndices;
};
#endif // OPERATIONGUI_EXTRACTIONDLG_H