-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <GeomAPI_Shape.h>
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Result.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
#include <GeomAPI_Circ.h>
return aFoundSubs;
}
- // Find circular/elliptical edge, which center/focus coincide with the given point
+ // Find circular/elliptic edge, which center/focus coincide with the given point
static GeomShapePtr findEdgeByCenter(const GeomShapePtr& theBaseShape,
const GeomPointPtr& theCenter,
const double theTolerance,
aSR.myResult = theResult;
aSR.mySubshape = theSubshape;
aSR.myCenterType = theCenterType;
+ // compound subshapes from other compounds should be processed as whole results
+ if (aSR.mySubshape && aSR.mySubshape->shapeType() == GeomAPI_Shape::COMPOUND &&
+ !theResult->shape()->isEqual(theSubshape)) {
+ ResultBodyPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
+ for (int i = 0; aResult && i < aResult->numberOfSubs(); ++i) {
+ ResultBodyPtr aSub = aResult->subResult(i);
+ if (aSub->shape()->isEqual(theSubshape)) {
+ aSR.myResult = aSub;
+ aSR.mySubshape = GeomShapePtr();
+ break;
+ }
+ }
+ }
theList.push_back(aSR);
}
const std::list<GeomShapePtr>& theSubshape)
{
for (std::list<GeomShapePtr>::const_iterator anIt = theSubshape.begin();
- anIt != theSubshape.end(); ++anIt) {
- SubshapeOfResult aSR;
- aSR.myResult = theResult;
- aSR.mySubshape = *anIt;
- aSR.myCenterType = (int)ModelAPI_AttributeSelection::NOT_CENTER;
- theList.push_back(aSR);
+ anIt != theSubshape.end(); ++anIt)
+ appendSubshapeOfResult(theList, theResult, *anIt);
+ }
+
+ static bool findSubshapeInCompsolid(const ResultBodyPtr& theCompsolid,
+ const std::shared_ptr<GeomAPI_Pnt>& thePoint,
+ const GeomAPI_Shape::ShapeType& theShapeType,
+ const double theTolerance,
+ std::list<SubshapeOfResult>& theSelected)
+ {
+ bool isSubshapeFound = false;
+ int aNbSolids = theCompsolid->numberOfSubs();
+ for (int i = 0; i < aNbSolids; ++i) {
+ ResultPtr aSubResult = theCompsolid->subResult(i);
+
+ // process subs of compsolid
+ ResultBodyPtr aSubCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aSubResult);
+ if (theShapeType != GeomAPI_Shape::COMPSOLID &&
+ aSubCompSolid && aSubCompSolid->numberOfSubs() > 0) {
+ isSubshapeFound = findSubshapeInCompsolid(aSubCompSolid,
+ thePoint, theShapeType, theTolerance, theSelected);
+ }
+ else {
+ GeomShapePtr aSubSolid = aSubResult->shape();
+ if (aSubSolid && isPointWithinBB(thePoint, aSubSolid, theTolerance)) {
+ std::list<GeomShapePtr> aSubshapes =
+ findSubShape(aSubSolid, theShapeType, thePoint, theTolerance);
+ if (!aSubshapes.empty()) {
+ appendSubshapeOfResult(theSelected, aSubResult, aSubshapes);
+ isSubshapeFound = true;
+ }
+ }
+ }
}
+ return isSubshapeFound;
}
bool findSubshapeByPoint(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const GeomAPI_Shape::ShapeType& theShapeType,
std::list<SubshapeOfResult>& theSelected)
{
- static const double TOLERANCE = 1.e-7;
+ static const double TOLERANCE = 1.e-6;
theSelected.clear();
std::shared_ptr<GeomAPI_PlanarEdges> aSketchEdges =
std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aCurShape);
if (theShapeType != GeomAPI_Shape::COMPOUND || !aSketchEdges) {
- ResultCompSolidPtr aCompSolid =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aResIt);
+ ResultBodyPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aResIt);
if (aCompSolid) {
- // process solids
- int aNbSolids = aCompSolid->numberOfSubs();
- for (int i = 0; i < aNbSolids; ++i) {
- ResultPtr aSubResult = aCompSolid->subResult(i);
- GeomShapePtr aSubSolid = aSubResult->shape();
- if (aSubSolid && isPointWithinBB(thePoint, aSubSolid, TOLERANCE)) {
- std::list<GeomShapePtr> aSubshapes =
- findSubShape(aSubSolid, theShapeType, thePoint, TOLERANCE);
- if (!aSubshapes.empty()) {
- appendSubshapeOfResult(theSelected, aSubResult, aSubshapes);
- isSubshapeFound = true;
- }
- }
- }
+ isSubshapeFound = findSubshapeInCompsolid(aCompSolid,
+ thePoint, theShapeType, TOLERANCE, theSelected);
}
if (!isSubshapeFound) {
// next special case: the full sketch is selected
// the selection type is a COMPOUND
- if (aSketchEdges &&
+ if (aSketchEdges && theShapeType == GeomAPI_Shape::COMPOUND &&
aSketchEdges->middlePoint()->distance(thePoint) < TOLERANCE) {
// select whole result
appendSubshapeOfResult(theSelected, *aResIt, GeomShapePtr());
std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aResults.front()->shape());
if (aSketchEdges && aCF) {
- bool isContinue = true;
int aNbSubs = aCF->numberOfSubs();
- for (int aSubInd = 0; aSubInd < aNbSubs && isContinue; ++aSubInd) {
+ for (int aSubInd = 0; aSubInd < aNbSubs; ++aSubInd) {
FeaturePtr aSub = aCF->subFeature(aSubInd);
const std::list<ResultPtr>& aSubResults = aSub->results();
for (std::list<ResultPtr>::const_iterator aSRIt = aSubResults.begin();
findSubShape(aCurShape, theShapeType, thePoint, TOLERANCE);
if (!aSubshapes.empty()) {
appendSubshapeOfResult(theSelected, aResults.front(), aSubshapes);
- isContinue = false;
break;
}
}