-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: SketchPlugin_Validators.cpp
-// Created: 01 Aug 2014
-// Author: Vitaly SMETANNIKOV
+// Copyright (C) 2014-2017 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
#include "SketchPlugin_Validators.h"
return false;
}
+static bool isPointPointCoincidence(const FeaturePtr& theCoincidence)
+{
+ AttributeRefAttrPtr aRefAttr[2] = {
+ theCoincidence->refattr(SketchPlugin_Constraint::ENTITY_A()),
+ theCoincidence->refattr(SketchPlugin_Constraint::ENTITY_B())
+ };
+
+ bool arePoints = true;
+ for (int i = 0; i < 2 && arePoints; ++i) {
+ if (aRefAttr[i]->isObject()) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr[i]->object());
+ arePoints = aFeature.get() && aFeature->getKind() == SketchPlugin_Point::ID();
+ } else
+ arePoints = aRefAttr[i]->attr().get() != NULL;
+ }
+ return arePoints;
+}
+
bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
std::shared_ptr<ModelAPI_Attribute> aAttr = (*anIt);
FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
+ if (!isPointPointCoincidence(aConstrFeature))
+ continue;
+
AttributeRefAttrPtr anAttrRefA = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
aConstrFeature->attribute(SketchPlugin_ConstraintCoincidence::ENTITY_A()));
AttributeRefAttrPtr anAttrRefB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
aConstrFeature->attribute(SketchPlugin_ConstraintCoincidence::ENTITY_B()));
- if(anAttrRefA.get() && !anAttrRefA->isObject()) {
- AttributePtr anAttrA = anAttrRefA->attr();
- if(aPointAttribute == anAttrA) {
- aConstraintCoincidence = aConstrFeature;
- break;
- }
+
+ AttributePtr anAttrA = anAttrRefA->attr();
+ if(aPointAttribute == anAttrA) {
+ aConstraintCoincidence = aConstrFeature;
+ break;
}
- if(anAttrRefB.get() && !anAttrRefB->isObject()) {
- AttributePtr anAttrB = anAttrRefB->attr();
- if(aPointAttribute == anAttrB) {
- aConstraintCoincidence = aConstrFeature;
- break;
- }
+
+ AttributePtr anAttrB = anAttrRefB->attr();
+ if(aPointAttribute == anAttrB) {
+ aConstraintCoincidence = aConstrFeature;
+ break;
}
}
}
std::set<FeaturePtr> aCoinsides;
SketchPlugin_Tools::findCoincidences(aConstraintCoincidence,
SketchPlugin_ConstraintCoincidence::ENTITY_A(),
- aCoinsides);
+ aCoinsides,
+ true);
SketchPlugin_Tools::findCoincidences(aConstraintCoincidence,
SketchPlugin_ConstraintCoincidence::ENTITY_B(),
- aCoinsides);
+ aCoinsides,
+ true);
- // Remove points from set of coincides.
+ // Remove points and external lines from set of coincides.
std::set<FeaturePtr> aNewSetOfCoincides;
for(std::set<FeaturePtr>::iterator anIt = aCoinsides.begin();
anIt != aCoinsides.end(); ++anIt) {
std::shared_ptr<SketchPlugin_SketchEntity> aSketchEntity =
std::dynamic_pointer_cast<SketchPlugin_SketchEntity>(*anIt);
- if(aSketchEntity.get() && aSketchEntity->isCopy()) {
+ if(aSketchEntity.get() && (aSketchEntity->isCopy() || aSketchEntity->isExternal())) {
continue;
}
if((*anIt)->getKind() != SketchPlugin_Line::ID() &&
return true;
if (aCenterRef->isObject()) {
- FeaturePtr aCenterFeature = ModelAPI_Feature::feature(aCenterRef->object());
- if (aCenterFeature == aPassedFeature) {
+ if (aCenterRef->object() == aPassedRef->object()) {
theError = aErrorMessage;
return false;
}
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if(aResult.get()) {
- GeomShapePtr aShape = toInfiniteEdge(aResult->shape());
+ GeomShapePtr aShape = aResult->shape();
+ if (!aShape->isEdge())
+ return true;
+ aShape = toInfiniteEdge(aShape);
if(aShape.get() && !aShape->isNull()) {
if(anArcShape->isIntersect(aShape)) {
return true;
anIt != aResults.cend();
++anIt)
{
- GeomShapePtr aShape = toInfiniteEdge((*anIt)->shape());
+ GeomShapePtr aShape = (*anIt)->shape();
+ if (!aShape->isEdge())
+ return true;
+ aShape = toInfiniteEdge(aShape);
if(aShape.get() && !aShape->isNull()) {
if(anArcShape->isIntersect(aShape)) {
return true;