-// 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 "ConstructionPlugin_Plane.h"
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
+
static GeomShapePtr faceByThreeVertices(const std::shared_ptr<GeomAPI_Vertex> theV1,
const std::shared_ptr<GeomAPI_Vertex> theV2,
const std::shared_ptr<GeomAPI_Vertex> theV3);
aC = anAttrC->value(), aD = anAttrD->value();
std::shared_ptr<GeomAPI_Pln> aPlane =
std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
- double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size");
+ double aSize = Config_PropManager::real(SKETCH_TAB_NAME, "planes_size");
+ if (aSize <= 1.e-7)
+ aSize = 200; // Set default value
aSize *= 4.;
aPlaneFace = GeomAlgoAPI_FaceBuilder::squareFace(aPlane, aSize);
}
GeomAPI_ShapeIterator anIt(aLineShape);
anEdge = anIt.current()->edge();
}
+ if (!anEdge)
+ return GeomShapePtr();
// Get point.
AttributeSelectionPtr aPointSelection = selection(POINT());
bool anIsReverse = boolean(REVERSE())->value();
if(anIsReverse) aDist = -aDist;
GeomShapePtr aShape = aFaceAttr->value();
- if (!aShape.get()) {
+ if (!aShape.get() && aFaceAttr->context()) {
aShape = aFaceAttr->context()->shape();
}
GeomAPI_ShapeIterator anIt(aShape);
aFace = anIt.current()->face();
}
+ if (!aFace)
+ return GeomShapePtr();
std::shared_ptr<GeomAPI_Pln> aPln = aFace->getPlane();
std::shared_ptr<GeomAPI_Pnt> aOrig = aPln->location();
if(!aPointShape.get()) {
aPointShape = aPointSelection->context()->shape();
}
- std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aPointShape));
+ std::shared_ptr<GeomAPI_Vertex> aVertex = aPointShape->vertex();
+ if (!aVertex)
+ return GeomShapePtr();
std::shared_ptr<GeomAPI_Pnt> anOrig = aVertex->point();
std::shared_ptr<GeomAPI_Pln> aPln = aFace->getPlane();
GeomAPI_ShapeIterator anIt(aFaceShape);
aFace = anIt.current()->face();
}
+ if (!aFace)
+ return GeomShapePtr();
aFace = makeRectangularFace(aFace, aFace->getPlane());
// Get axis.
GeomAPI_ShapeIterator anIt(anAxisShape);
anEdge = anIt.current()->edge();
}
+ if (!anEdge)
+ return GeomShapePtr();
std::shared_ptr<GeomAPI_Ax1> anAxis =
std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
GeomAPI_ShapeIterator anIt(aFaceShape1);
aFace1 = anIt.current()->face();
}
+ if (!aFace1)
+ return GeomShapePtr();
std::shared_ptr<GeomAPI_Pln> aPln1 = aFace1->getPlane();
// Get plane 2.
GeomAPI_ShapeIterator anIt(aFaceShape2);
aFace2 = anIt.current()->face();
}
+ if (!aFace2)
+ return GeomShapePtr();
std::shared_ptr<GeomAPI_Pln> aPln2 = aFace2->getPlane();
std::shared_ptr<GeomAPI_Pnt> anOrig1 = aPln1->location();