#include <ModelAPI_ResultBody.h>
#include <GeomAlgoAPI_Copy.h>
+#include <GeomAlgoAPI_Tools.h>
//=================================================================================================
BuildPlugin_Edge::BuildPlugin_Edge()
// Copy shape.
GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aShape));
- // Check that algo is done.
- if(!aCopyAlgo->isDone()) {
- setError("Error: " + getKind() + " algorithm failed.");
- return;
- }
-
- // Check if shape is not null.
- if(!aCopyAlgo->shape().get() || aCopyAlgo->shape()->isNull()) {
- setError("Error: Resulting shape is null.");
- return;
- }
-
- // Check that resulting shape is valid.
- if(!aCopyAlgo->isValid()) {
- setError("Error: Resulting shape is not valid.");
+ std::string anError;
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
#include <GeomAlgoAPI_Copy.h>
#include <GeomAlgoAPI_Filling.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_ShapeExplorer.h>
// build result
aFilling->build(aParameters.isApprox);
- if (isAlgorithmFailed(aFilling)) {
+ std::string anError;
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilling, getKind(), anError)) {
+ setError(anError);
removeResults(0);
return;
}
setResult(aResultBody, 0);
}
-bool BuildPlugin_Filling::isAlgorithmFailed(
- const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
-{
- if (!theAlgorithm->isDone()) {
- static const std::string aFeatureError = "Error: filling algorithm failed.";
- std::string anAlgoError = theAlgorithm->getError();
- if (anAlgoError.empty())
- anAlgoError = aFeatureError;
- else
- anAlgoError = aFeatureError + " " + anAlgoError;
- setError(anAlgoError);
- return true;
- }
- if (theAlgorithm->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape of filling is Null.";
- setError(aShapeError);
- return true;
- }
- if (!theAlgorithm->isValid()) {
- std::string aFeatureError = "Error: Resulting shape of filling is not valid.";
- setError(aFeatureError);
- return true;
- }
- return false;
-}
-
//=================================================================================================
void BuildPlugin_Filling::attributeChanged(const std::string& theID)
{
BUILDPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
private:
- /// Check the filling algorithm is failed
- bool isAlgorithmFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
-
/// Convert shape to edge according to construction method
std::shared_ptr<GeomAPI_Edge> toEdge(const std::shared_ptr<GeomAPI_Shape>& theShape,
const std::string& theMethod);
// Create wire from edges
GeomShapePtr aWire = GeomAlgoAPI_WireBuilder::wire(anEdges);
- if (!aWire.get()) {
- setError("Error: Result polyline is empty.");
- return;
- }
+ if (!aWire.get()) {
+ setError("Error: Result polyline is empty.");
+ return;
+ }
// Check the wire.
if (GeomAlgoAPI_WireBuilder::isSelfIntersected(aWire)) {
#include <ModelAPI_ResultConstruction.h>
#include <GeomAlgoAPI_Sewing.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_ShapeExplorer.h>
//=================================================================================================
// Sew faces.
GeomMakeShapePtr aSewingAlgo(new GeomAlgoAPI_Sewing(aShapes));
- // Check that algo is done.
- if(!aSewingAlgo->isDone()) {
- setError("Error: " + getKind() + " algorithm failed.");
- return;
- }
-
- // Check if shape is not null.
- if(!aSewingAlgo->shape().get() || aSewingAlgo->shape()->isNull()) {
- setError("Error: Resulting shape is null.");
- return;
- }
-
- // Check that resulting shape is valid.
- if(!aSewingAlgo->isValid()) {
- setError("Error: Resulting shape is not valid.");
+ std::string anError;
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSewingAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
#include <ModelAPI_ResultBody.h>
#include <GeomAlgoAPI_Copy.h>
+#include <GeomAlgoAPI_Tools.h>
//=================================================================================================
BuildPlugin_Vertex::BuildPlugin_Vertex()
}
// Copy shape.
- GeomAlgoAPI_Copy aCopyAlgo(aShape);
+ std::shared_ptr<GeomAlgoAPI_Copy> aCopyAlgo(new GeomAlgoAPI_Copy(aShape));
- // Check that algo is done.
- if(!aCopyAlgo.isDone()) {
- setError("Error: " + getKind() + " algorithm failed.");
- return;
- }
-
- // Check if shape is not null.
- if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) {
- setError("Error: Resulting shape is null.");
- return;
- }
-
- // Check that resulting shape is valid.
- if(!aCopyAlgo.isValid()) {
- setError("Error: Resulting shape is not valid.");
+ std::string anError;
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
// Store result.
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aShape, aCopyAlgo.shape());
+ aResultBody->storeModified(aShape, aCopyAlgo->shape());
setResult(aResultBody, aResultIndex);
++aResultIndex;
}
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
//==================================================================================================
}
int aResultIndex = 0;
+ std::string anError;
std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
ListOfShape aResultShapesList;
*anObjectsIt,
GeomAlgoAPI_Boolean::BOOL_COMMON));
- if (!aCommonAlgo->isDone()) {
- std::string aFeatureError = "Error: An algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aCommonAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aCommonAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
aResShape = aBoolAlgo->shape();
// Checking that the algorithm worked properly.
- if (!aBoolAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aResShape->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aBoolAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
GeomAlgoAPI_Boolean::BOOL_COMMON));
// Checking that the algorithm worked properly.
- if (!aCommonAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aCommonAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aCommonAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
GeomAlgoAPI_Boolean::BOOL_COMMON));
// Checking that the algorithm worked properly.
- if (!aCommonAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aCommonAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aCommonAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
+
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_ShapeIterator.h>
std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
ListOfShape aResultShapesList;
+ std::string anError;
// For solids cut each object with all tools.
for(ListOfShape::iterator anObjectsIt = anObjects.begin();
GeomShapePtr aResShape = aCutAlgo->shape();
// Checking that the algorithm worked properly.
- if (!aCutAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if(aResShape->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aCutAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
GeomAlgoAPI_Boolean::BOOL_CUT));
// Checking that the algorithm worked properly.
- if (!aCutAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aCutAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aCutAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
GeomAlgoAPI_Boolean::BOOL_CUT));
// Checking that the algorithm worked properly.
- if (!aCutAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aCutAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aCutAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
#include <GeomAlgoAPI_Partition.h>
#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
+
#include <GeomAPI_Face.h>
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_ShapeIterator.h>
//=================================================================================================
void FeaturesPlugin_BooleanFill::execute()
{
+ std::string anError;
ListOfShape anObjects, aTools, anEdgesAndFaces, aPlanes;
std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
}
// Checking that the algorithm worked properly.
- if(!aBoolAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if(aResShape->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if(!aBoolAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
aBoolAlgo.reset(new GeomAlgoAPI_Partition(aUsedInOperationSolids, aToolsWithPlanes));
// Checking that the algorithm worked properly.
- if(!aBoolAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if(aBoolAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if(!aBoolAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAlgoAPI_UnifySameDomain.h>
#include <GeomAPI_ShapeExplorer.h>
//==================================================================================================
void FeaturesPlugin_BooleanFuse::execute()
{
+ std::string anError;
ListOfShape anObjects, aTools, anEdgesAndFaces;
std::map<GeomShapePtr, ListOfShape> aCompSolidsObjects;
GeomAlgoAPI_Boolean::BOOL_FUSE));
// Checking that the algorithm worked properly.
- if (!aFuseAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aFuseAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aFuseAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFuseAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
}
std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
- if (!aFillerAlgo->isDone()) {
- std::string aFeatureError = "Error: PaveFiller algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aFillerAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aFillerAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
std::shared_ptr<GeomAlgoAPI_UnifySameDomain> aUnifyAlgo(
new GeomAlgoAPI_UnifySameDomain(aShape));
- if (!aUnifyAlgo->isDone()) {
- std::string aFeatureError = "Error: PaveFiller algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aUnifyAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aUnifyAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aUnifyAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
+
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_ShapeIterator.h>
//==================================================================================================
void FeaturesPlugin_BooleanSmash::execute()
{
+ std::string anError;
ListOfShape anObjects, aTools;
std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
GeomAlgoAPI_Boolean::BOOL_CUT));
// Checking that the algorithm worked properly.
- if (!aBoolAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Boolean algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aBoolAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aBoolAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
+
aMakeShapeList->appendAlgo(aBoolAlgo);
// Put all (cut result, tools and not used solids) to PaveFiller.
else {
std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
- if (!aFillerAlgo->isDone()) {
- std::string aFeatureError = "Error: PaveFiller algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (aFillerAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!aFillerAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
std::shared_ptr<ModelAPI_Feature> FeaturesPlugin_CompositeSketch::subFeature(const int theIndex,
bool forTree)
{
+ FeaturePtr aSubFeature;
if(theIndex == 0) {
- return std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_ID())->value());
+ aSubFeature =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_ID())->value());
}
-
- return std::shared_ptr<ModelAPI_Feature>();
+ return aSubFeature;
}
//=================================================================================================
//=================================================================================================
bool FeaturesPlugin_CompositeSketch::isSub(ObjectPtr theObject) const
{
+ bool isSubFeature = false;
// Check is this feature of result
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
- if(!aFeature.get()) {
- return false;
+ if (aFeature.get()) {
+ ObjectPtr aSub = data()->reference(SKETCH_ID())->value();
+ isSubFeature = aSub == theObject;
}
-
- ObjectPtr aSub = data()->reference(SKETCH_ID())->value();
- return aSub == theObject;
+ return isSubFeature;
}
//=================================================================================================
}
}
-//=================================================================================================
-bool FeaturesPlugin_CompositeSketch::isMakeShapeValid(
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
-{
- // Check that algo is done.
- if(!theMakeShape->isDone()) {
- setError("Error: " + getKind() + " algorithm failed.");
- return false;
- }
-
- // Check if shape is not null.
- if(!theMakeShape->shape().get() || theMakeShape->shape()->isNull()) {
- setError("Error: Resulting shape is null.");
- return false;
- }
-
- // Check that resulting shape is valid.
- if(!theMakeShape->isValid()) {
- setError("Error: Resulting shape is not valid.");
- return false;
- }
-
- return true;
-}
-
//=================================================================================================
void FeaturesPlugin_CompositeSketch::storeResult(const GeomShapePtr theBaseShape,
const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
/// \param[in] theIsMakeShells if true make shells from faces with shared edges.
void getBaseShapes(ListOfShape& theBaseShapesList, const bool theIsMakeShells = true);
- /// Checks make shape algo.
- bool isMakeShapeValid(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
-
/// Stores result of generation.
void storeResult(const GeomShapePtr theBaseShape,
const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
#include <ModelAPI_Validator.h>
#include <GeomAlgoAPI_Prism.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_Dir.h>
#include <GeomAPI_Edge.h>
}
// Generating result for each base shape.
+ std::string anError;
for(ListOfShape::const_iterator
anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) {
std::shared_ptr<GeomAPI_Shape> aBaseShape = *anIter;
std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo(new GeomAlgoAPI_Prism(aBaseShape, aDir,
aToShape, aToSize,
aFromShape, aFromSize));
- if(!isMakeShapeValid(aPrismAlgo)) {
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPrismAlgo, getKind(), anError)) {
+ setError(anError);
return false;
}
#include <GeomAlgoAPI_Fillet.h>
#include <GeomAlgoAPI_MakeShapeList.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_DataMapOfShapeMapOfShapes.h>
#include <GeomAPI_ShapeExplorer.h>
GeomAlgoAPI_MakeShapeList aMakeShapeList;
std::shared_ptr<GeomAlgoAPI_Fillet> aFilletBuilder;
int aResultIndex = 0;
+ std::string anError;
GeomAPI_DataMapOfShapeMapOfShapes::iterator anIt = aSolidsAndSubs.begin();
for (; anIt != aSolidsAndSubs.end(); ++anIt) {
aFilletBuilder.reset(new GeomAlgoAPI_Fillet(aSolid, aFilletEdges, aRadius1));
else
aFilletBuilder.reset(new GeomAlgoAPI_Fillet(aSolid, aFilletEdges, aRadius1, aRadius2));
- if (isFailed(aFilletBuilder))
+
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilletBuilder, getKind(), anError)) {
+ setError(anError);
return;
+ }
GeomShapePtr aResult = unwrapCompound(aFilletBuilder->shape());
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
removeResults(aResultIndex);
}
-bool FeaturesPlugin_Fillet::isFailed(
- const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
-{
- if (!theAlgorithm->isDone()) {
- static const std::string aFeatureError = "Error: fillet algorithm failed.";
- setError(aFeatureError);
- return true;
- }
- if (theAlgorithm->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape of fillet is Null.";
- setError(aShapeError);
- return true;
- }
- if (!theAlgorithm->isValid()) {
- std::string aFeatureError = "Error: Resulting shape of fillet is not valid.";
- setError(aFeatureError);
- return true;
- }
- return false;
-}
-
void FeaturesPlugin_Fillet::loadNamingDS(
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
const std::shared_ptr<GeomAPI_Shape> theBaseShape,
FeaturesPlugin_Fillet();
private:
- /// Check algorithm is finished correctly and store error otherwise
- bool isFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
-
/// Load Naming data structure of the feature to the document
void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
const std::shared_ptr<GeomAPI_Shape> theBaseShape,
#include <GeomAPI_ShapeIterator.h>
#include <GeomAPI_ShapeExplorer.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAlgoAPI_UnifySameDomain.h>
std::shared_ptr<GeomAlgoAPI_UnifySameDomain> anAlgo(new GeomAlgoAPI_UnifySameDomain(aBaseShape));
// Check algo status
- if (!anAlgo->isDone()) {
- setError("Error: Fusion algorithm failed.");
- return;
- }
- if (anAlgo->shape()->isNull()) {
- setError("Error: Resulting shape is Null.");
- return;
- }
- if (!anAlgo->isValid()) {
- setError("Error: Resulting shape is not valid.");
+ std::string anError;
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
#include <ModelAPI_AttributeSelectionList.h>
#include <GeomAlgoAPI_Intersection.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_ShapeExplorer.h>
#include <sstream>
GeomMakeShapePtr anIntersectionAlgo(new GeomAlgoAPI_Intersection(anObjects));
// Checking that the algorithm worked properly.
- if (!anIntersectionAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Intersection algorithm failed.";
- setError(aFeatureError);
- return;
- }
- if (anIntersectionAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- return;
- }
- if (!anIntersectionAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ std::string anError;
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anIntersectionAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAlgoAPI_Translation.h>
#include <GeomAPI_ShapeExplorer.h>
aResultIndex++;
}
} else {
+ std::string anError;
ListOfShape aListOfShape;
std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > aListOfRotationAlgo;
aRotationnAlgo->build();
// Checking that the algorithm worked properly.
- if (!aRotationnAlgo->isDone()) {
- static const std::string aFeatureError = "Error : Multitranslation algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if (aRotationnAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error : Resulting shape is null.";
- setError(aShapeError);
- break;
- }
- if (!aRotationnAlgo->isValid()) {
- static const std::string aFeatureError = "Error : Resulting shape in not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationnAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
aListOfShape.push_back(aRotationnAlgo->shape());
#include <FeaturesPlugin_MultiTranslation.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_Ax1.h>
#include <GeomAPI_Edge.h>
aResultIndex++;
}
} else {
+ std::string anError;
ListOfShape aListOfShape;
std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if (!aTranslationAlgo->isDone()) {
- static const std::string aFeatureError = "Error : Multitranslation algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if (aTranslationAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error : Resulting shape is null.";
- setError(aShapeError);
- break;
- }
- if (!aTranslationAlgo->isValid()) {
- static const std::string aFeatureError = "Error : Resulting shape in not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
aListOfShape.push_back(aTranslationAlgo->shape());
}
}
} else {
+ std::string anError;
ListOfShape aListOfShape;
std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if (!aTranslationAlgo->isDone()) {
- static const std::string aFeatureError = "Error : Multitranslation algorithm failed.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
- if (aTranslationAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error : Resulting shape is null.";
- setError(aShapeError);
- break;
- }
- if (!aTranslationAlgo->isValid()) {
- static const std::string aFeatureError = "Error : Resulting shape in not valid.";
- setError(aFeatureError);
- break;
- }
aListOfShape.push_back(aTranslationAlgo->shape());
aListOfTranslationAlgo.push_back(aTranslationAlgo);
}
#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_Partition.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_Face.h>
#include <GeomAPI_ShapeExplorer.h>
std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
std::string& theError);
-static bool isAlgoFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
- std::string& theError);
-
//=================================================================================================
FeaturesPlugin_Partition::FeaturesPlugin_Partition()
new GeomAlgoAPI_Partition(aTargetObjects, aPlanes));
// Checking that the algorithm worked properly.
- if (isAlgoFailed(aPartitionAlgo, aError)) {
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPartitionAlgo, getKind(), aError)) {
setError(aError);
return;
}
aPartitionAlgo.reset(new GeomAlgoAPI_Partition(aTargetObjects, ListOfShape()));
// Checking that the algorithm worked properly.
- if (isAlgoFailed(aPartitionAlgo, aError)) {
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPartitionAlgo, getKind(), aError)) {
setError(aError);
return;
}
// cut from current list of solids
aCutAlgo.reset(
new GeomAlgoAPI_Boolean(aUIt->second, theTools, GeomAlgoAPI_Boolean::BOOL_CUT));
- if (isAlgoFailed(aCutAlgo, theError))
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, "", theError))
return false;
theMakeShapeList->appendAlgo(aCutAlgo);
return cutSubs(aFirstArgument, theObjects, aToolsForUsed, theMakeShapeList, theError)
&& cutSubs(aFirstArgument, theNotUsed, aToolsForUnused, theMakeShapeList, theError);
}
-
-bool isAlgoFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo, std::string& theError)
-{
- if (!theAlgo->isDone()) {
- theError = "Error: Partition algorithm failed.";
- return true;
- }
- if (theAlgo->shape()->isNull()) {
- theError = "Error: Resulting shape is Null.";
- return true;
- }
- if (!theAlgo->isValid()) {
- theError = "Error: Resulting shape is not valid.";
- return true;
- }
-
- theError.clear();
- return false;
-}
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_Pipe.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
+
#include <GeomAPI_PlanarEdges.h>
#include <GeomAPI_ShapeExplorer.h>
// 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;
}
aLocations,
aPathShape));
- if(!aPipeAlgo->isDone()) {
- setError("Error: Pipe algorithm failed.");
- 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.");
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPipeAlgo, getKind(), anError)) {
+ setError(anError);
removeResults(0);
return;
}
#include <GeomAPI_ShapeIterator.h>
#include <GeomAlgoAPI_Placement.h>
#include <GeomAlgoAPI_Transform.h>
+#include <GeomAlgoAPI_Tools.h>
#include <FeaturesPlugin_Tools.h>
// Applying transformation to each object.
int aResultIndex = 0;
+ std::string anError;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
anObjectsIt++, aContext++) {
aTrsf));
// Checking that the algorithm worked properly.
- if(!aTransformAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Transform algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aTransformAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aTransformAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTransformAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Copy.h>
+#include <GeomAlgoAPI_Tools.h>
FeaturesPlugin_Recover::FeaturesPlugin_Recover()
{
void FeaturesPlugin_Recover::execute()
{
+ std::string anError;
int aResultIndex = 0;
AttributeRefListPtr aRecovered = reflist(RECOVERED_ENTITIES());
for(int anIndex = aRecovered->size() - 1; anIndex >= 0; anIndex--) {
// Copy shape.
std::shared_ptr<GeomAlgoAPI_Copy> aCopyAlgo(new GeomAlgoAPI_Copy(aShape));
// Check that algo is done.
- if(!aCopyAlgo->isDone()) {
- setError("Error: recover algorithm failed.");
- return;
- }
- // Check if shape is not null.
- if(!aCopyAlgo->shape().get() || aCopyAlgo->shape()->isNull()) {
- setError("Error: resulting shape is null.");
- return;
- }
- // Check that resulting shape is valid.
- if(!aCopyAlgo->isValid()) {
- setError("Error: resulting shape is not valid.");
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
#include <ModelAPI_Validator.h>
#include <GeomAlgoAPI_Revolution.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
}
// Generating result for each base shape.
+ std::string anError;
for(ListOfShape::const_iterator
anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) {
GeomShapePtr aBaseShape = *anIter;
aBaseShape, anAxis,
aToShape, aToAngle,
aFromShape, aFromAngle));
- if(!isMakeShapeValid(aRevolAlgo)) {
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRevolAlgo, getKind(), anError)) {
+ setError(anError);
return false;
}
#include <ModelAPI_ResultPart.h>
#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
double anAngle = real(FeaturesPlugin_Rotation::ANGLE_ID())->value();
// Rotating each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aRotationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aRotationAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Rotation algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aRotationAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aRotationAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
}
// Rotating each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aRotationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aRotationAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Rotation algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aRotationAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error : Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aRotationAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
#include <FeaturesPlugin_Scale.h>
#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeSelectionList.h>
double aScaleFactor = real(FeaturesPlugin_Scale::SCALE_FACTOR_ID())->value();
// Moving each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aScaleAlgo->build();
// Checking that the algorithm worked properly.
- if(!aScaleAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aScaleAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aScaleAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aScaleAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
double aScaleFactorZ = real(FeaturesPlugin_Scale::SCALE_FACTOR_Z_ID())->value();
// Moving each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aScaleAlgo->build();
// Checking that the algorithm worked properly.
- if(!aScaleAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aScaleAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aScaleAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aScaleAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomAlgoAPI_Copy.h>
#include <GeomAlgoAPI_MakeShapeList.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Face.h>
}
// Moving each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aSymmetryAlgo->build();
// Checking that the algorithm worked properly.
- if(!aSymmetryAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aSymmetryAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aSymmetryAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSymmetryAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
// Moving each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aSymmetryAlgo->build();
// Checking that the algorithm worked properly.
- if(!aSymmetryAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aSymmetryAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aSymmetryAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSymmetryAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
// Moving each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aSymmetryAlgo->build();
// Checking that the algorithm worked properly.
- if(!aSymmetryAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aSymmetryAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aSymmetryAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSymmetryAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
#include <GeomAPI_Trsf.h>
#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
#include <FeaturesPlugin_Tools.h>
double aDistance = real(FeaturesPlugin_Translation::DISTANCE_ID())->value();
// Moving each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aTranslationAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Translation algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aTranslationAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aTranslationAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
double aDZ = real(FeaturesPlugin_Translation::DZ_ID())->value();
// Moving each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aTranslationAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Translation algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aTranslationAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aTranslationAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
}
// Moving each object.
+ std::string anError;
int aResultIndex = 0;
std::list<ResultPtr>::iterator aContext = aContextes.begin();
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aTranslationAlgo->isDone()) {
- static const std::string aFeatureError = "Error: Translation algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aTranslationAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aTranslationAlgo->isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+ setError(anError);
break;
}
#include <GeomAlgoAPI_Boolean.h>
#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_PaveFiller.h>
+#include <GeomAlgoAPI_Tools.h>
#include <GeomAlgoAPI_UnifySameDomain.h>
#include <GeomAPI_ShapeExplorer.h>
}
// Fuse objects.
+ std::string anError;
std::shared_ptr<GeomAlgoAPI_MakeShape> anAlgo;
ListOfShape aTools;
if (anObjects.front()->shapeType() == GeomAPI_Shape::SOLID) {
// Checking that the algorithm worked properly.
std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
GeomAPI_DataMapOfShapeShape aMapOfShapes;
- if(!anAlgo->isDone()) {
- setError("Error: Boolean algorithm failed.");
- return;
- }
- if(anAlgo->shape()->isNull()) {
- setError("Error: Resulting shape is Null.");
- return;
- }
- if(!anAlgo->isValid()) {
- setError("Error: Resulting shape is not valid.");
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
aShapesToAdd.push_back(aShape);
std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
- if(!aFillerAlgo->isDone()) {
- setError("Error: PaveFiller algorithm failed.");
- return;
- }
- if(aFillerAlgo->shape()->isNull()) {
- setError("Error: Resulting shape is Null.");
- return;
- }
- if(!aFillerAlgo->isValid()) {
- setError("Error: Resulting shape is not valid.");
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) {
+ setError(anError);
return;
}
//
#include "GeomAlgoAPI_Tools.h"
+#include "GeomAlgoAPI_MakeShape.h"
#include <clocale>
OSD_Path aPath(aFileName);
return aPath.Name().ToCString();
}
+
+bool AlgoError::isAlgorithmFailed(const GeomMakeShapePtr& theAlgorithm,
+ const std::string& theFeature,
+ std::string& theError)
+{
+ theError.clear();
+ if (!theAlgorithm->isDone()) {
+ theError = "Error: " + (theFeature.empty() ? "The" : theFeature) + " algorithm failed.";
+ std::string anAlgoError = theAlgorithm->getError();
+ if (!anAlgoError.empty())
+ theError += " " + anAlgoError;
+ return true;
+ }
+ if (!theAlgorithm->shape() || theAlgorithm->shape()->isNull()) {
+ theError = "Error: Resulting shape";
+ if (!theFeature.empty())
+ theError += "of " + theFeature;
+ theError += " is Null.";
+ return true;
+ }
+ if (!theAlgorithm->isValid()) {
+ theError = "Error: Resulting shape";
+ if (!theFeature.empty())
+ theError += "of " + theFeature;
+ theError += " is not valid.";
+ return true;
+ }
+ return false;
+}
#include <GeomAlgoAPI.h>
+#include <memory>
#include <string>
+class GeomAlgoAPI_MakeShape;
+
namespace GeomAlgoAPI_Tools {
/** \class Localizer
GEOMALGOAPI_EXPORT static std::string name(const std::string& theFileName);
};
+/** \class AlgoError
+ * \ingroup DataAlgo
+ * \brief Verify error in MakeShape algorithm.
+ */
+class AlgoError {
+public:
+ /** \brief Verify MakeShape algorithm for failures
+ * \param[in] theAlgorithm object to verify the failure
+ * \param[in] theFeature kind of the feature, the algorithm belongs to
+ * \param[out] theError error string (empty if the feature succeed)
+ * \return \c true if succeed
+ */
+ GEOMALGOAPI_EXPORT static bool isAlgorithmFailed(
+ const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm,
+ const std::string& theFeature,
+ std::string& theError);
+};
+
} // GeomAlgoAPI_Tools
#endif /* GEOMALGOAPI_TOOLS_H_ */