+
+//==================================================================================================
+bool FeaturesPlugin_Placement::isShapeValid(GeomShapePtr theShape)
+{
+ if (theShape->isCompound()) {
+ GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
+ for (GeomAPI_ShapeIterator anIt(theShape); anIt.more(); anIt.next()) {
+ GeomShapePtr aCurrentShape = anIt.current();
+ if (aShapeType == GeomAPI_Shape::SHAPE) {
+ aShapeType = aCurrentShape->shapeType();
+ }
+ else if (aShapeType != aCurrentShape->shapeType()) {
+ static const std::string aLinearityError =
+ "Error: Selected compound contains shapes with different types.";
+ setError(aLinearityError);
+ return false;
+ }
+
+ if (!isShapeValid(aCurrentShape)) {
+ return false;
+ }
+ }
+ }
+ else if (theShape->isFace()) {
+ std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(theShape));
+ if (!aFace->isPlanar()) {
+ static const std::string aPlanarityError = "Error: One of selected faces is not planar.";
+ setError(aPlanarityError);
+ return false;
+ }
+ }
+ else if (theShape->isEdge()) {
+ std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(theShape));
+ if (!anEdge->isLine()) {
+ static const std::string aLinearityError = "Error: One of selected edges is not linear.";
+ setError(aLinearityError);
+ return false;
+ }
+ }
+
+ return true;
+}