0022761: [EDF] Improvement of Explode dialog box

This commit is contained in:
ova 2014-10-14 12:22:46 +04:00 committed by vsr
parent bff7674ef5
commit 285d412521
8 changed files with 309 additions and 309 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -2,49 +2,75 @@
\page create_explode_page Explode
\n To \b Explode an object into sub-shapes, in the <b>Main Menu</b>
select <b>New Entity > Explode</b>.
To \b Explode an object into sub-shapes, in the <b>Main Menu</b>
select <b>New Entity > Explode</b>. This operation opens the
<b>Sub Shapes Selection</b> dialog box.
\n To create a list of sub-shapes (vertices, edges, wires etc.) of the
\image html neo-obj1.png
To create a list of sub-shapes (vertices, edges, wires etc.) of the
given shape using the \b Explode operation, you need to define the <b>Main
Object</b>, which will be exploded and the <b>Type of Sub-shapes</b> you wish to
obtain from it.
\n The \b Result of the operation will be a List of \b GEOM_Objects
The \b Result of the operation will be a List of \b GEOM_Objects
(vertexes, edges, wires, faces, shells or solids).
\n Using <b>TUI Commands</b> you can perform this operation in a
Available choices in the <b>Sub Shapes Type</b> combo box depend on the type
of selected <b>Main Object</b>:
- \b Compound: to extract compounds;
- \b Compsolid: to extract compsolids;
- \b Solid: to extract solids;
- \b Shell: to extract shells;
- \b Face: to extract faces;
- \b Wire: to extract wires;
- \b Edge: to extract edges;
- \b Vertex: to extract vertices;
- \b Shape: to extract top-level contents of the compound shape;
- \b Flat: to extract "flat" contents of the compound shape.
Note: "flat" contents means top-level simple-type sub-shapes extracted from
the compound object recursively (i.e. there is no compounds in the result).
For example, if a compound C1 contains a solid S1 and another compound C2 that
contains solids S2 and S3 (see picture below):
- Explode operation with \b Shape type given as parameter will return S1 and C2;
- Explode operation with \b Flat type given as parameter will return S1, S2 and S3.
\image html flat_contents.png
Switching on <b>Select Sub-shapes</b> check box allows manual selection of sub-shapes
to be extracted from the main object. In this mode the user can select sub-shapes
directly in 3D viewer.
Using <b>TUI Commands</b> you can perform this operation in a
variety of ways:
<ul>
<li><em>geompy.ExtractShapes(Shape, Type, isSorted)</em> explodes a
Shape into sub-shapes of a given Type and returns a List of sub-shapes.
This method does not return the Shape itself if it matches the
Type.</li>
<li><em>geompy.SubShapeAll(Shape, Type)</em> explodes a Shape on
sub-shapes of a given Type and returns a List of sub-shapes.</li>
<li><em>geompy.SubShapeAllIDs(Shape, Type)</em> explodes a Shape on
sub-shapes of a given Type and returns a List of IDs of
sub-shapes.</li>
<li><em>geompy.SubShapeAllSortedCentres(Shape, Type)</em> explodes a
shape on sub-shapes of a given type and sorts them taking into account
their gravity centers, to provide stable order of sub-shapes.
It returns a list of sub-shapes.</li>
<li><em>geompy.SubShapeAllSortedCentresIDs(Shape, Type)</em> explodes
a shape on sub-shapes of a given type and sorts them taking into
account their gravity centers, to provide stable order of sub-shapes.
It returns a List of IDs of sub-shapes.</li>
<li><em>geompy.SubShape(Shape, Type, ListOfInd)</em> allows to obtain
a compound of sub-shapes of the Shape, selected by they indices in a
list of all sub-shapes of the given Type. Each index is in the range
[1, Nb_Sub-Shapes_Of_Given_Type].</li>
<li><em>geompy.SubShapeSortedCentres(Shape, Type, ListOfInd)</em>
allows to obtain a compound of sub-shapes of the Shape, selected by
they indices in sorted list of all sub-shapes of the given Type. Each
index is in the range [1, Nb_Sub-Shapes_Of_Given_Type]</li>
</ul>
- <em>geompy.ExtractShapes(Shape, Type, isSorted)</em> explodes a
Shape into sub-shapes of a given Type and returns a List of sub-shapes.
This method does not return the Shape itself if it matches the
Type.
- <em>geompy.SubShapeAll(Shape, Type)</em> explodes a Shape on
sub-shapes of a given Type and returns a List of sub-shapes.
- <em>geompy.SubShapeAllIDs(Shape, Type)</em> explodes a Shape on
sub-shapes of a given Type and returns a List of IDs of
sub-shapes.
- <em>geompy.SubShapeAllSortedCentres(Shape, Type)</em> explodes a
shape on sub-shapes of a given type and sorts them taking into account
their gravity centers, to provide stable order of sub-shapes.
It returns a list of sub-shapes.
- <em>geompy.SubShapeAllSortedCentresIDs(Shape, Type)</em> explodes
a shape on sub-shapes of a given type and sorts them taking into
account their gravity centers, to provide stable order of sub-shapes.
It returns a List of IDs of sub-shapes.
- <em>geompy.SubShape(Shape, Type, ListOfInd)</em> allows to obtain
a compound of sub-shapes of the Shape, selected by they indices in a
list of all sub-shapes of the given Type. Each index is in the range
[1, Nb_Sub-Shapes_Of_Given_Type].
- <em>geompy.SubShapeSortedCentres(Shape, Type, ListOfInd)</em>
allows to obtain a compound of sub-shapes of the Shape, selected by
they indices in sorted list of all sub-shapes of the given Type. Each
index is in the range [1, Nb_Sub-Shapes_Of_Given_Type]
\n <b>Arguments: </b>1 SHAPE + 1 type of SubShape.
\image html neo-obj1.png
<b>Arguments: </b>1 SHAPE + 1 type of SubShape.
<b>Example:</b>

View File

@ -39,7 +39,7 @@ module GEOM
*/
enum shape_type
{
/*! */
/*! A collection of arbitrary shapes */
COMPOUND,
/*! A collection of solids */
COMPSOLID,
@ -47,16 +47,19 @@ module GEOM
SOLID,
/*! A collection of faces connected by some edges of their wire boundaries */
SHELL,
/*! Part of a plane (in 2D geometry) or a surface (in 3D geometry) bounded by a close wire */
/*! Part of a plane (in 2D geometry) or a surface (in 3D geometry) bounded by a closed wire */
FACE,
/*! A sequence of edges connected by their vertices */
/*! A sequence of edges connected by their vertices */
WIRE,
/*! Edge, a shape corresponding to a curve, and bound by a vertex at each extremity */
EDGE,
/*! A zero-dimensional shape corresponding to a point in geometry */
VERTEX,
/*! */
SHAPE };
/*! Arbitrary shape in a Compound (used for processing of Compounds in some operations) */
SHAPE,
/*! Flat (top-level) contents of a Compound (used for processing of Compounds in some operations) */
FLAT
};
/*!
* \brief Marker type

View File

@ -55,6 +55,62 @@
#include <GEOMImpl_Types.hxx>
namespace
{
const char* const ShapeTypes [] = {
"Compound",
"Compsolid",
"Solid",
"Shell",
"Face",
"Wire",
"Edge",
"Vertex",
"Shape",
"Flat"
};
unsigned int NumberOfSubShapes(const TopoDS_Shape& S, const int shapeType, TopTools_MapOfShape& M)
{
unsigned int index = 0;
if (!S.IsNull()) {
if (S.ShapeType() == TopAbs_COMPOUND &&
(shapeType == TopAbs_SHAPE || shapeType == TopAbs_FLAT || shapeType == TopAbs_COMPOUND)) {
TopoDS_Iterator It(S, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
TopoDS_Shape SS = It.Value();
if (M.Add(SS)) {
if (shapeType == TopAbs_FLAT) {
if (SS.ShapeType() != TopAbs_COMPOUND)
index++;
else
index += NumberOfSubShapes(SS, shapeType, M);
}
else if (shapeType == TopAbs_SHAPE || shapeType == SS.ShapeType()) {
index++;
}
}
}
}
else {
TopExp_Explorer Exp (S, TopAbs_ShapeEnum(shapeType));
for (; Exp.More(); Exp.Next()) {
if (M.Add(Exp.Current())) {
index++;
}
}
}
}
return index;
}
unsigned int NumberOfSubShapes(const TopoDS_Shape& S, const int shapeType)
{
TopTools_MapOfShape M;
return NumberOfSubShapes(S, shapeType, M);
}
}
//=================================================================================
// class : EntityGUI_SubShapeDlg
// purpose : Constructs a EntityGUI_SubShapeDlg which is a child of 'parent', with the
@ -66,7 +122,6 @@ EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg(GeometryGUI* theGeometryGUI, QWidge
bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myDmMode( -1 ),
myWithShape(true),
myIsHiddenMain(false)
{
QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SUBSHAPE")));
@ -133,18 +188,9 @@ void EntityGUI_SubShapeDlg::Init()
myEditCurrentArgument = GroupPoints->LineEdit1;
myObject = GEOM::GEOM_Object::_nil();
myWithShape = true;
/* type for sub-shape selection */
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
for ( int i = 0; i <= (int)GEOM::FLAT; i++ )
GroupPoints->ComboBox1->addItem(ShapeTypes[i], i);
if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType()
!= OCCViewer_Viewer::Type())
@ -172,6 +218,7 @@ void EntityGUI_SubShapeDlg::Init()
updateButtonState();
resize(100,100);
SelectionIntoArgument();
SubShapeToggled();
}
//=================================================================================
@ -282,6 +329,8 @@ void EntityGUI_SubShapeDlg::SelectionIntoArgument()
if (!isAllSubShapes())
return;
int currentType = GroupPoints->ComboBox1->itemData( GroupPoints->ComboBox1->currentIndex() ).toInt();
ResetStateOfDialog();
QString aString = ""; /* name of selection */
@ -291,87 +340,47 @@ void EntityGUI_SubShapeDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList);
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
if (nbSel != 1)
return;
Handle(SALOME_InteractiveObject) IO = aSelList.First();
if (!IO->hasEntry()) {
SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
updateButtonState();
return;
}
if (myIsHiddenMain) {
GEOM_Displayer* aDisplayer = getDisplayer();
aDisplayer->Display(myObject);
myIsHiddenMain = false;
}
TopoDS_Shape S = GEOMBase::GetTopoFromSelection(aSelList);
if (S.IsNull() || S.ShapeType() == TopAbs_VERTEX) {
myObject = GEOM::GEOM_Object::_nil();
updateButtonState();
return;
}
myObject = GEOMBase::ConvertIOinGEOMObject(IO);
if (myObject->_is_nil()) {
updateButtonState();
return;
}
myShape = S;
GroupPoints->LineEdit1->setText(aString);
int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
int count = GroupPoints->ComboBox1->count();
if (myWithShape)
count = count - 1;
int i = 0;
// Solving PAL5590
if (myShape.ShapeType() == TopAbs_COMPOUND) {
unsigned int nb = NumberOfSubShapes(myShape, TopAbs_COMPOUND);
if (nb > 0)
i++;
}
while (i <= myShape.ShapeType()) {
GroupPoints->ComboBox1->removeItem(0);
i++;
}
if (myShape.ShapeType() == TopAbs_COMPOUND) {
if (myWithShape == false) {
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
myWithShape = true;
if (nbSel == 1) {
Handle(SALOME_InteractiveObject) IO = aSelList.First();
if (!IO->hasEntry()) {
SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
}
}
else {
if (myWithShape == true) {
GroupPoints->ComboBox1->removeItem(GroupPoints->ComboBox1->count() - 1);
myWithShape = false;
}
}
int count1 = GroupPoints->ComboBox1->count();
if (myWithShape)
count1 = count1 - 1;
if (SelectedShapeType > myShape.ShapeType()) {
if (SelectedShapeType == 8) {
if (myShape.ShapeType() != TopAbs_COMPOUND) {
GroupPoints->ComboBox1->setCurrentIndex(0);
ComboTextChanged();
else {
TopoDS_Shape S = GEOMBase::GetTopoFromSelection(aSelList);
if (S.IsNull() || S.ShapeType() == TopAbs_VERTEX) {
myObject = GEOM::GEOM_Object::_nil();
}
}
else
GroupPoints->ComboBox1->setCurrentIndex(count1 - count + SelectedShapeType);
}
else {
GroupPoints->ComboBox1->setCurrentIndex(0);
ComboTextChanged();
}
else {
myObject = GEOMBase::ConvertIOinGEOMObject(IO);
if (!CORBA::is_nil(myObject)) {
myShape = S;
GroupPoints->LineEdit1->setText(aString);
int i = 0;
// Solving PAL5590
if (myShape.ShapeType() == TopAbs_COMPOUND) {
unsigned int nb = NumberOfSubShapes(myShape, TopAbs_COMPOUND);
if (nb > 0)
i++;
}
while (i <= myShape.ShapeType()) {
GroupPoints->ComboBox1->removeItem(0);
i++;
}
// remove Shape and Flat types for non-compound shapes
if (myShape.ShapeType() != TopAbs_COMPOUND) {
int idx = GroupPoints->ComboBox1->findData( (int)GEOM::SHAPE );
if ( idx != -1 ) GroupPoints->ComboBox1->removeItem( idx );
idx = GroupPoints->ComboBox1->findData( (int)GEOM::FLAT );
if ( idx != -1 ) GroupPoints->ComboBox1->removeItem( idx );
} // if (myShape.ShapeType() != TopAbs_COMPOUND)
} // if (!CORBA::is_nil(myObject))
} // if (S.IsNull() || S.ShapeType() == TopAbs_VERTEX)
} // if (!IO->hasEntry()) ... else
} // if (nbSel == 1)
int idx = GroupPoints->ComboBox1->findData( currentType );
if ( idx != -1 )
GroupPoints->ComboBox1->setCurrentIndex( idx );
updateButtonState();
}
@ -420,29 +429,10 @@ void EntityGUI_SubShapeDlg::ResetStateOfDialog()
myShape.Nullify();
myEditCurrentArgument->setText("");
int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
int count = GroupPoints->ComboBox1->count();
if (myWithShape)
count = count - 1;
/* type for sub-shape selection */
GroupPoints->ComboBox1->clear();
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex");
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
myWithShape = true;
GroupPoints->ComboBox1->setCurrentIndex(8 - count + SelectedShapeType);
// to avoid recursion: SelectionIntoArgument->ResetStateOfDialog->ComboTextChanged->SubShapeToggled->activateSelection->(currentSelectionChanged)->SelectionIntoArgument
//ComboTextChanged();
for ( int i = 0; i <= (int)GEOM::FLAT; i++ )
GroupPoints->ComboBox1->addItem(ShapeTypes[i], i);
updateButtonState();
}
@ -472,59 +462,23 @@ void EntityGUI_SubShapeDlg::ComboTextChanged()
SubShapeToggled();
}
//=================================================================================
// function : NumberOfSubShapes()
// purpose :
//=================================================================================
unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes(const TopoDS_Shape& S,
const int shapeType) const
{
if (S.IsNull())
return 0;
unsigned int index = 0;
TopTools_MapOfShape M;
if (S.ShapeType() == TopAbs_COMPOUND &&
(TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE ||
TopAbs_ShapeEnum(shapeType) == TopAbs_COMPSOLID ||
TopAbs_ShapeEnum(shapeType) == TopAbs_COMPOUND)) {
TopoDS_Iterator It(S, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
if (M.Add(It.Value())) {
if (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE ||
TopAbs_ShapeEnum(shapeType) == It.Value().ShapeType()) {
index++;
}
}
}
}
else {
TopExp_Explorer Exp (S, TopAbs_ShapeEnum(shapeType));
for (; Exp.More(); Exp.Next()) {
if (M.Add(Exp.Current())) {
index++;
}
}
}
M.Clear();
return index;
}
//=================================================================================
// function : updateButtonState
// purpose :
//=================================================================================
void EntityGUI_SubShapeDlg::updateButtonState()
{
if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() != OCCViewer_Viewer::Type() ||
myObject->_is_nil() || shapeType() == TopAbs_SHAPE || shapeType() == TopAbs_COMPOUND) {
GroupPoints->CheckButton1->setChecked(false);
GroupPoints->CheckButton1->setEnabled(false);
bool viewOk = SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() == OCCViewer_Viewer::Type();
bool shapeTypeOk = shapeType() != TopAbs_SHAPE && shapeType() != TopAbs_FLAT && shapeType() != TopAbs_COMPOUND;
bool objectOK = !CORBA::is_nil( myObject );
if ( viewOk && objectOK && shapeTypeOk ) {
GroupPoints->CheckButton1->setEnabled( true );
}
else {
GroupPoints->CheckButton1->setChecked( false );
GroupPoints->CheckButton1->setEnabled( false );
}
else
GroupPoints->CheckButton1->setEnabled(true);
}
//=================================================================================
@ -533,7 +487,7 @@ void EntityGUI_SubShapeDlg::updateButtonState()
//=================================================================================
bool EntityGUI_SubShapeDlg::isAllSubShapes() const
{
return !GroupPoints->CheckButton1->isChecked() || !GroupPoints->CheckButton1->isEnabled();
return !GroupPoints->CheckButton1->isEnabled() || !GroupPoints->CheckButton1->isChecked();
}
//=================================================================================
@ -542,19 +496,7 @@ bool EntityGUI_SubShapeDlg::isAllSubShapes() const
//=================================================================================
int EntityGUI_SubShapeDlg::shapeType() const
{
int type = GroupPoints->ComboBox1->currentIndex();
if (myObject->_is_nil())
return type;
// Solving PAL5590
type += myShape.ShapeType() + 1;
if (myShape.ShapeType() == TopAbs_COMPOUND &&
NumberOfSubShapes(myShape, TopAbs_COMPOUND) > 0) {
type--;
}
return type;
return GroupPoints->ComboBox1->itemData(GroupPoints->ComboBox1->currentIndex()).toInt();
}
//=================================================================================

View File

@ -73,9 +73,6 @@ private:
void ResetStateOfDialog();
unsigned int NumberOfSubShapes (const TopoDS_Shape&,
const int) const;
void activateSelection();
int getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex);
void updateButtonState();
@ -87,8 +84,6 @@ private:
GEOM::GEOM_Object_var myObject;
int myDmMode;
bool myWithShape;
bool myIsHiddenMain;
DlgRef_1Sel1List1Check3Btn* GroupPoints;

View File

@ -135,6 +135,63 @@
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
namespace {
//================================================================================
/*!
* \brief Return normal to face at extrema point
*/
//================================================================================
gp_Vec GetNormal (const TopoDS_Face& face, const BRepExtrema_DistShapeShape& extrema)
{
gp_Vec defaultNorm(1,0,0); // to have same normals on different faces
try {
// get UV at extrema point
Standard_Real u,v, f,l;
switch ( extrema.SupportTypeShape2(1) ) {
case BRepExtrema_IsInFace: {
extrema.ParOnFaceS2(1, u, v );
break;
}
case BRepExtrema_IsOnEdge: {
TopoDS_Edge edge = TopoDS::Edge( extrema.SupportOnShape2(1));
Handle(Geom2d_Curve) pcurve = BRep_Tool::CurveOnSurface( edge, face, f,l );
extrema.ParOnEdgeS2( 1, u );
gp_Pnt2d uv = pcurve->Value( u );
u = uv.Coord(1);
v = uv.Coord(2);
break;
}
case BRepExtrema_IsVertex: return defaultNorm;
}
// get derivatives
BRepAdaptor_Surface surface( face, false );
gp_Vec du, dv; gp_Pnt p;
surface.D1( u, v, p, du, dv );
return du ^ dv;
} catch (Standard_Failure ) {
}
return defaultNorm;
}
void AddFlatSubShapes(const TopoDS_Shape& S, TopTools_ListOfShape& L, TopTools_MapOfShape& M)
{
if (S.ShapeType() != TopAbs_COMPOUND) {
L.Append(S);
}
else {
TopoDS_Iterator It(S, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
TopoDS_Shape SS = It.Value();
if (M.Add(SS))
AddFlatSubShapes(SS, L, M);
}
}
}
}
//=============================================================================
/*!
@ -1298,17 +1355,20 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
TopTools_ListOfShape listShape;
if (aShape.ShapeType() == TopAbs_COMPOUND &&
(TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPSOLID ||
TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPOUND))
(theShapeType == TopAbs_SHAPE || theShapeType == TopAbs_FLAT || theShapeType == TopAbs_COMPOUND))
{
TopoDS_Iterator It (aShape, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
if (mapShape.Add(It.Value())) {
if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
TopAbs_ShapeEnum(theShapeType) == It.Value().ShapeType()) {
listShape.Append(It.Value());
TopoDS_Shape SS = It.Value();
if (mapShape.Add(SS)) {
if (theShapeType == TopAbs_FLAT) {
AddFlatSubShapes(SS, listShape, mapShape);
}
else if (theShapeType == TopAbs_SHAPE || theShapeType == SS.ShapeType()) {
listShape.Append(SS);
}
// VSR: for EXPLODE_NEW_INCLUDE_MAIN and EXPLODE_OLD_INCLUDE_MAIN:
// it seems it is necessary to add top-level shape if theShapeType == TopAbs_COMPOUND
}
}
}
@ -1320,7 +1380,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
listShape.Append(exp.Current());
}
if (listShape.IsEmpty()) {
if (listShape.IsEmpty()){
//SetErrorCode("The given shape has no sub-shapes of the requested type");
SetErrorCode(NOT_FOUND_ANY); // NPAL18017
return aSeq;
@ -1364,16 +1424,15 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
// Put this subshape in the list of sub-shapes of theMainShape
aMainShape->AddSubShapeReference(aFunction);
}
if (!anObj.IsNull()) {
aSeq->Append(anObj);
aSeq->Append(anObj);
// for python command
TDF_Tool::Entry(anObj->GetEntry(), anEntry);
anAsciiList += anEntry;
anAsciiList += ",";
}
}
// for python command
TDF_Tool::Entry(anObj->GetEntry(), anEntry);
anAsciiList += anEntry;
anAsciiList += ",";
}
}
//Make a Python command
anAsciiList.Trunc(anAsciiList.Length() - 1);
@ -1422,16 +1481,17 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs
TopTools_ListOfShape listShape;
if (aShape.ShapeType() == TopAbs_COMPOUND &&
(TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPSOLID ||
TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPOUND))
(theShapeType == TopAbs_SHAPE || theShapeType == TopAbs_FLAT || theShapeType == TopAbs_COMPOUND))
{
TopoDS_Iterator It (aShape, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
if (mapShape.Add(It.Value())) {
if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
TopAbs_ShapeEnum(theShapeType) == It.Value().ShapeType()) {
listShape.Append(It.Value());
TopoDS_Shape SS = It.Value();
if (mapShape.Add(SS)) {
if (theShapeType == TopAbs_FLAT) {
AddFlatSubShapes(SS, listShape, mapShape);
}
else if (theShapeType == TopAbs_SHAPE || theShapeType == SS.ShapeType()) {
listShape.Append(SS);
}
}
}
@ -1850,33 +1910,41 @@ Standard_Integer GEOMImpl_IShapesOperations::NumberOfSubShapes
*/
try {
OCC_CATCH_SIGNALS;
int iType, nbTypes [TopAbs_SHAPE];
for (iType = 0; iType < TopAbs_SHAPE; ++iType)
nbTypes[iType] = 0;
nbTypes[aShape.ShapeType()]++;
if (theShapeType == TopAbs_FLAT) {
TopTools_MapOfShape aMapOfShape;
TopTools_ListOfShape aListOfShape;
AddFlatSubShapes(aShape, aListOfShape, aMapOfShape);
nbShapes = aListOfShape.Extent();
}
else {
OCC_CATCH_SIGNALS;
int iType, nbTypes [TopAbs_SHAPE];
for (iType = 0; iType < TopAbs_SHAPE; ++iType)
nbTypes[iType] = 0;
nbTypes[aShape.ShapeType()]++;
TopTools_MapOfShape aMapOfShape;
aMapOfShape.Add(aShape);
TopTools_ListOfShape aListOfShape;
aListOfShape.Append(aShape);
TopTools_MapOfShape aMapOfShape;
aMapOfShape.Add(aShape);
TopTools_ListOfShape aListOfShape;
aListOfShape.Append(aShape);
TopTools_ListIteratorOfListOfShape itL (aListOfShape);
for (; itL.More(); itL.Next()) {
TopoDS_Iterator it (itL.Value());
for (; it.More(); it.Next()) {
TopoDS_Shape s = it.Value();
if (aMapOfShape.Add(s)) {
aListOfShape.Append(s);
nbTypes[s.ShapeType()]++;
TopTools_ListIteratorOfListOfShape itL (aListOfShape);
for (; itL.More(); itL.Next()) {
TopoDS_Iterator it (itL.Value());
for (; it.More(); it.Next()) {
TopoDS_Shape s = it.Value();
if (aMapOfShape.Add(s)) {
aListOfShape.Append(s);
nbTypes[s.ShapeType()]++;
}
}
}
}
if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE)
nbShapes = aMapOfShape.Extent();
else
nbShapes = nbTypes[theShapeType];
if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE)
nbShapes = aMapOfShape.Extent();
else
nbShapes = nbTypes[theShapeType];
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
@ -3850,49 +3918,6 @@ void GEOMImpl_IShapesOperations::GetShapeProperties( const TopoDS_Shape aShape,
return;
}
namespace {
//================================================================================
/*!
* \brief Return normal to face at extrema point
*/
//================================================================================
gp_Vec GetNormal (const TopoDS_Face& face, const BRepExtrema_DistShapeShape& extrema)
{
gp_Vec defaultNorm(1,0,0); // to have same normals on different faces
try {
// get UV at extrema point
Standard_Real u,v, f,l;
switch ( extrema.SupportTypeShape2(1) ) {
case BRepExtrema_IsInFace: {
extrema.ParOnFaceS2(1, u, v );
break;
}
case BRepExtrema_IsOnEdge: {
TopoDS_Edge edge = TopoDS::Edge( extrema.SupportOnShape2(1));
Handle(Geom2d_Curve) pcurve = BRep_Tool::CurveOnSurface( edge, face, f,l );
extrema.ParOnEdgeS2( 1, u );
gp_Pnt2d uv = pcurve->Value( u );
u = uv.Coord(1);
v = uv.Coord(2);
break;
}
case BRepExtrema_IsVertex: return defaultNorm;
}
// get derivatives
BRepAdaptor_Surface surface( face, false );
gp_Vec du, dv; gp_Pnt p;
surface.D1( u, v, p, du, dv );
return du ^ dv;
} catch (Standard_Failure ) {
}
return defaultNorm;
}
}
//=============================================================================
/*!
* case GetInPlace:

View File

@ -20,6 +20,10 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef GEOMImpl_Types_HXX
#define GEOMImpl_Types_HXX
#include <TopAbs_ShapeEnum.hxx>
// GEOM_Object types
@ -375,5 +379,10 @@
#define USER_TYPE_EX 1000 // Base type for GEOM plugins
//Plugins specified constants
// Plugins specified constants
#define PLUGIN_NAME "Plugin Name"
// Flat type for TopAbs
enum { TopAbs_FLAT = TopAbs_SHAPE+1 };
#endif // GEOMImpl_Types_HXX

View File

@ -559,7 +559,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
## Enumeration ShapeType as a dictionary. \n
## Topological types of shapes (like Open Cascade types). See GEOM::shape_type for details.
# @ingroup l1_geomBuilder_auxiliary
ShapeType = {"AUTO":-1, "COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
ShapeType = {"AUTO":-1, "COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8, "FLAT":9}
## Kinds of shape in terms of <VAR>GEOM.GEOM_IKindOfShape.shape_kind</VAR> enumeration
# and a list of parameters, describing the shape.