\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>
-
-\n <b>Arguments: </b>1 SHAPE + 1 type of SubShape.
+- <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]
-\image html neo-obj1.png
+<b>Arguments: </b>1 SHAPE + 1 type of SubShape.
<b>Example:</b>
*/
enum shape_type
{
- /*! */
+ /*! A collection of arbitrary shapes */
COMPOUND,
/*! A collection of solids */
COMPSOLID,
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
#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
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")));
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())
updateButtonState();
resize(100,100);
SelectionIntoArgument();
+ SubShapeToggled();
}
//=================================================================================
if (!isAllSubShapes())
return;
+ int currentType = GroupPoints->ComboBox1->itemData( GroupPoints->ComboBox1->currentIndex() ).toInt();
+
ResetStateOfDialog();
QString aString = ""; /* name of selection */
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;
- }
- }
- else {
- if (myWithShape == true) {
- GroupPoints->ComboBox1->removeItem(GroupPoints->ComboBox1->count() - 1);
- myWithShape = false;
+ if (nbSel == 1) {
+ Handle(SALOME_InteractiveObject) IO = aSelList.First();
+ if (!IO->hasEntry()) {
+ SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
}
- }
-
- 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();
}
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();
}
}
//=================================================================================
-// function : NumberOfSubShapes()
+// function : updateButtonState
// purpose :
//=================================================================================
-unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes(const TopoDS_Shape& S,
- const int shapeType) const
+void EntityGUI_SubShapeDlg::updateButtonState()
{
- if (S.IsNull())
- return 0;
+ 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 );
- 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++;
- }
- }
- }
+ if ( viewOk && objectOK && shapeTypeOk ) {
+ GroupPoints->CheckButton1->setEnabled( true );
}
else {
- TopExp_Explorer Exp (S, TopAbs_ShapeEnum(shapeType));
- for (; Exp.More(); Exp.Next()) {
- if (M.Add(Exp.Current())) {
- index++;
- }
- }
+ GroupPoints->CheckButton1->setChecked( false );
+ GroupPoints->CheckButton1->setEnabled( false );
}
-
- 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);
- }
- else
- GroupPoints->CheckButton1->setEnabled(true);
}
//=================================================================================
//=================================================================================
bool EntityGUI_SubShapeDlg::isAllSubShapes() const
{
- return !GroupPoints->CheckButton1->isChecked() || !GroupPoints->CheckButton1->isEnabled();
+ return !GroupPoints->CheckButton1->isEnabled() || !GroupPoints->CheckButton1->isChecked();
}
//=================================================================================
//=================================================================================
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();
}
//=================================================================================
void ResetStateOfDialog();
- unsigned int NumberOfSubShapes (const TopoDS_Shape&,
- const int) const;
-
void activateSelection();
int getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex);
void updateButtonState();
GEOM::GEOM_Object_var myObject;
int myDmMode;
- bool myWithShape;
-
bool myIsHiddenMain;
DlgRef_1Sel1List1Check3Btn* GroupPoints;
#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);
+ }
+ }
+ }
+}
//=============================================================================
/*!
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
}
}
}
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;
// 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);
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);
}
}
}
*/
try {
- 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_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 (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_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();
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:
// 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
#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
## 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.