Salome HOME
projects
/
modules
/
shaper.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Initial implementation of geometrical naming in the selector.
[modules/shaper.git]
/
src
/
SketchPlugin
/
SketchPlugin_Projection.cpp
diff --git
a/src/SketchPlugin/SketchPlugin_Projection.cpp
b/src/SketchPlugin/SketchPlugin_Projection.cpp
index 254ccafc99899862470662f77a7daa3ce5eacff0..91b45643c5b46e6cf5848b9f9d4fc059d6b5a264 100644
(file)
--- a/
src/SketchPlugin/SketchPlugin_Projection.cpp
+++ b/
src/SketchPlugin/SketchPlugin_Projection.cpp
@@
-75,14
+75,17
@@
void SketchPlugin_Projection::execute()
return;
FeaturePtr aProjection = ModelAPI_Feature::feature(aRefAttr->object());
return;
FeaturePtr aProjection = ModelAPI_Feature::feature(aRefAttr->object());
- if (!lastResult().get() && aProjection->lastResult().get()) {
+ if (!lastResult().get()) {
+ bool hasProjResult = aProjection->lastResult().get() != NULL;
ResultConstructionPtr aConstr = document()->createConstruction(data());
ResultConstructionPtr aConstr = document()->createConstruction(data());
- aConstr->setShape(aProjection->lastResult()->shape());
+ if (hasProjResult)
+ aConstr->setShape(aProjection->lastResult()->shape());
aConstr->setIsInHistory(false);
aConstr->setDisplayed(false);
setResult(aConstr);
aConstr->setIsInHistory(false);
aConstr->setDisplayed(false);
setResult(aConstr);
- aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
+ if (hasProjResult)
+ aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
}
// is sketch plane is changed (issue 1791), attribute of projection is not changed, but
}
// is sketch plane is changed (issue 1791), attribute of projection is not changed, but
@@
-162,7
+165,8
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(lastResult());
if (aResult && aResult->shape() && theID == EXTERNAL_FEATURE_ID()) {
aResult->setShape(std::shared_ptr<GeomAPI_Edge>());
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(lastResult());
if (aResult && aResult->shape() && theID == EXTERNAL_FEATURE_ID()) {
aResult->setShape(std::shared_ptr<GeomAPI_Edge>());
- aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
+ if (aProjection)
+ aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
}
if (aVertex) {
}
if (aVertex) {
@@
-200,6
+204,10
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
double aRadius = aCircle->radius();
std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
double aRadius = aCircle->radius();
+ double aNormalsDot = aCircle->normal()->dot(aSketchPlane->direction());
+ if (fabs(fabs(aNormalsDot) - 1.0) > tolerance)
+ return; // circle is not in the plane, parallel to the sketch plane
+
std::shared_ptr<GeomAPI_Pnt> aCenter = aSketchPlane->project(aCircle->center());
std::shared_ptr<GeomAPI_Pnt2d> aCenterInSketch = sketch()->to2D(aCenter);
std::shared_ptr<GeomAPI_Pnt> aCenter = aSketchPlane->project(aCircle->center());
std::shared_ptr<GeomAPI_Pnt2d> aCenterInSketch = sketch()->to2D(aCenter);
@@
-223,7
+231,11
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
std::shared_ptr<GeomAPI_Pnt> aCenter = aSketchPlane->project(aCircle->center());
std::shared_ptr<GeomAPI_Pnt2d> aCenterInSketch = sketch()->to2D(aCenter);
std::shared_ptr<GeomAPI_Pnt> aCenter = aSketchPlane->project(aCircle->center());
std::shared_ptr<GeomAPI_Pnt2d> aCenterInSketch = sketch()->to2D(aCenter);
- bool isInversed = aCircle->normal()->dot(aSketchPlane->direction()) < 0.;
+ double aNormalsDot = aCircle->normal()->dot(aSketchPlane->direction());
+ if (fabs(fabs(aNormalsDot) - 1.0) > tolerance)
+ return; // arc is not in the plane, parallel to the sketch plane
+
+ bool isInversed = aNormalsDot < 0.;
if (!hasPrevProj)
aProjection = sketch()->addFeature(SketchPlugin_Arc::ID());
if (!hasPrevProj)
aProjection = sketch()->addFeature(SketchPlugin_Arc::ID());
@@
-245,8
+257,9
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
aCenterPnt->setValue(aCenterInSketch);
aProjection->boolean(SketchPlugin_Arc::REVERSED_ID())->setValue(isInversed);
aCenterPnt->setValue(aCenterInSketch);
aProjection->boolean(SketchPlugin_Arc::REVERSED_ID())->setValue(isInversed);
- aProjection->data()->blockSendAttributeUpdated(aWasBlocked, false);
- }
+ aProjection->data()->blockSendAttributeUpdated(aWasBlocked);
+ } else
+ return;
aProjection->boolean(COPY_ID())->setValue(true);
aProjection->execute();
aProjection->boolean(COPY_ID())->setValue(true);
aProjection->execute();
@@
-258,7
+271,8
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
if (aResult) {
aResult->setShape(aProjection->lastResult()->shape());
setResult(aResult);
if (aResult) {
aResult->setShape(aProjection->lastResult()->shape());
setResult(aResult);
- aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
+ GeomShapePtr anEmptyVal;
+ aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), anEmptyVal);
}
}
}
}
}
}