-// 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 "FeaturesPlugin_Pipe.h"
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_Pipe.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
+
#include <GeomAPI_PlanarEdges.h>
#include <GeomAPI_ShapeExplorer.h>
// Searching faces with common edges.
if(aCreationMethod == CREATION_METHOD_SIMPLE()) {
- ListOfShape aShells;
- ListOfShape aFreeFaces;
std::shared_ptr<GeomAPI_Shape> aFacesCompound =
GeomAlgoAPI_CompoundBuilder::compound(aBaseFacesList);
- GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL,
- aShells, aFreeFaces);
- aBaseShapesList.insert(aBaseShapesList.end(), aFreeFaces.begin(), aFreeFaces.end());
- aBaseShapesList.insert(aBaseShapesList.end(), aShells.begin(), aShells.end());
+ GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, aBaseShapesList);
} else {
aBaseShapesList.insert(aBaseShapesList.end(), aBaseFacesList.begin(), aBaseFacesList.end());
}
}
std::shared_ptr<GeomAPI_Shape> aPathShape =
std::dynamic_pointer_cast<GeomAPI_Shape>(aPathSelection->value());
- if(!aPathShape.get()) {
- // Probaply it is a construction.
+ if(!aPathShape.get() && aPathSelection->context().get()) {
+ // Probably it is a construction.
aPathShape = aPathSelection->context()->shape();
}
if(!aPathShape.get() || aPathShape->isNull()) {
return;
}
aBiNormal = std::dynamic_pointer_cast<GeomAPI_Shape>(aBiNormalSelection->value());
- if(!aBiNormal.get()) {
+ if(!aBiNormal.get() && aBiNormalSelection->context().get()) {
// Probably it is a construction.
aBiNormal = aBiNormalSelection->context()->shape();
}
return;
}
std::shared_ptr<GeomAPI_Shape> aLocationShape = aLocationSelection->value();
- if(!aLocationShape.get()) {
+ if(!aLocationShape.get() && aLocationSelection->context().get()) {
// Probably it is a construction.
aLocationShape = aLocationSelection->context()->shape();
}
// Generating result for each object.
int aResultIndex = 0;
+ std::string anError;
if(aCreationMethod == CREATION_METHOD_SIMPLE() ||
aCreationMethod == CREATION_METHOD_BINORMAL()) {
for(ListOfShape::const_iterator
aPathShape,
aBiNormal));
- if(!aPipeAlgo->isDone()) {
- setError("Error: Pipe algorithm failed.");
- aResultIndex = 0;
- break;
- }
-
- // Check if shape is valid
- if(!aPipeAlgo->shape().get() || aPipeAlgo->shape()->isNull()) {
- setError("Error: Resulting shape is Null.");
- aResultIndex = 0;
- break;
- }
- if(!aPipeAlgo->isValid()) {
- setError("Error: Resulting shape is not valid.");
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPipeAlgo, getKind(), anError)) {
+ setError(anError);
aResultIndex = 0;
break;
}
- storeResult(aBaseShape, aPipeAlgo, aResultIndex++);
+ storeResult(aBaseShape, aPathShape, aPipeAlgo, aResultIndex++);
}
} else if(aCreationMethod == CREATION_METHOD_LOCATIONS()) {
std::shared_ptr<GeomAlgoAPI_Pipe> aPipeAlgo(new GeomAlgoAPI_Pipe(aBaseShapesList,
aLocations,
aPathShape));
- if(!aPipeAlgo->isDone()) {
- setError("Error: Pipe algorithm failed.");
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPipeAlgo, getKind(), anError)) {
+ setError(anError);
removeResults(0);
return;
}
- // Check if shape is valid
- if(!aPipeAlgo->shape().get() || aPipeAlgo->shape()->isNull()) {
- setError("Error: Resulting shape is Null.");
- removeResults(0);
- return;
- }
- if(!aPipeAlgo->isValid()) {
- setError("Error: Resulting shape is not valid.");
- removeResults(0);
- return;
- }
-
- storeResult(aBaseShapesList, aPipeAlgo, aResultIndex++);
+ storeResult(aBaseShapesList, aPathShape, aPipeAlgo, aResultIndex++);
} else {
setError("Error: Wrong creation method.");
return;
//==================================================================================================
void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+ const std::shared_ptr<GeomAPI_Shape> thePathShape,
const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex)
{
aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) {
aResultBody->loadGeneratedShapes(thePipeAlgo, theBaseShape, GeomAPI_Shape::EDGE);
}
+ if (thePathShape.get())
+ aResultBody->loadGeneratedShapes(thePipeAlgo, thePathShape, GeomAPI_Shape::EDGE);
// Store from shapes.
storeShapes(aResultBody, aBaseShapeType, thePipeAlgo->fromShapes(), "From_");
//==================================================================================================
void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes,
+ const std::shared_ptr<GeomAPI_Shape> thePathShape,
const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex)
{
aResultBody->loadGeneratedShapes(thePipeAlgo, aBaseShape, aShapeTypeToExplode);
}
+ if (thePathShape.get())
+ aResultBody->loadGeneratedShapes(thePipeAlgo, thePathShape, GeomAPI_Shape::EDGE);
+
// Store from shapes.
storeShapes(aResultBody, theBaseShapes.front()->shapeType(), thePipeAlgo->fromShapes(), "From_");