X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Tools.cpp;h=82675355b292f78aeec6255f5ac6ad880d81757a;hb=04f3d16c5347e2dd849add526fa1997d09d2f7e5;hp=9157938f1fbb2e37928d7173ae094eb1acd5c5dd;hpb=8babac25037f2666dcb422dd68a66dd2ed1383d8;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 9157938f1..82675355b 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -99,8 +99,9 @@ Handle(V3d_View) theView, std::shared_ptr aX = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr anY = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::DIRY_ID())); + std::shared_ptr aNorm = std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); + std::shared_ptr anY = aNorm->xyz()->cross(aX->xyz()); gp_Pnt anOriginPnt(anOrigin->x(), anOrigin->y(), anOrigin->z()); gp_Vec aVec(anOriginPnt, thePoint); @@ -138,13 +139,14 @@ std::shared_ptr PartSet_Tools::convertTo3D(const double theX, const aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); std::shared_ptr aX = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::DIRY_ID())); + std::shared_ptr aNorm = std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); + std::shared_ptr aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); std::shared_ptr aPnt2d = std::shared_ptr(new GeomAPI_Pnt2d(theX, theY)); - return aPnt2d->to3D(aC->pnt(), aX->dir(), aY->dir()); + return aPnt2d->to3D(aC->pnt(), aX->dir(), aY); } ObjectPtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView, @@ -361,6 +363,8 @@ void PartSet_Tools::setConstraints(CompositeFeaturePtr theSketch, FeaturePtr the new GeomAPI_Pnt2d(theClickedX, theClickedY)); for (; anIt != aLast; anIt++) { FeaturePtr aFeature = std::dynamic_pointer_cast(*anIt); + if (theFeature == aFeature) + continue; // find the given point in the feature attributes anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); std::list >::const_iterator anIt = anAttiributes.begin(), @@ -415,37 +419,42 @@ std::shared_ptr PartSet_Tools::point3D(std::shared_ptrdata(); std::shared_ptr aC = std::dynamic_pointer_cast( - theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); std::shared_ptr aX = std::dynamic_pointer_cast( - theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY = std::dynamic_pointer_cast( - theSketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID())); + aData->attribute(SketchPlugin_Sketch::DIRX_ID())); + std::shared_ptr aNorm = std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); + std::shared_ptr aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); - return thePoint2D->to3D(aC->pnt(), aX->dir(), aY->dir()); + return thePoint2D->to3D(aC->pnt(), aX->dir(), aY); } -bool PartSet_Tools::isConstraintFeature(const std::string& theKind) +ResultPtr PartSet_Tools::findFixedObjectByExternal(const TopoDS_Shape& theShape, + const ObjectPtr& theObject, + CompositeFeaturePtr theSketch) { - return theKind == SketchPlugin_ConstraintDistance::ID() - || theKind == SketchPlugin_ConstraintLength::ID() - || theKind == SketchPlugin_ConstraintRadius::ID() - || theKind == SketchPlugin_ConstraintRigid::ID(); + ResultPtr aResult; + if (theShape.ShapeType() == TopAbs_EDGE) { + // Check that we already have such external edge + std::shared_ptr aInEdge = std::shared_ptr(new GeomAPI_Edge()); + aInEdge->setImpl(new TopoDS_Shape(theShape)); + aResult = findExternalEdge(theSketch, aInEdge); + } + if (theShape.ShapeType() == TopAbs_VERTEX) { + std::shared_ptr aInVert = std::shared_ptr(new GeomAPI_Vertex()); + aInVert->setImpl(new TopoDS_Shape(theShape)); + aResult = findExternalVertex(theSketch, aInVert); + } + return aResult; } -ResultPtr PartSet_Tools::createFixedObjectByEdge(const TopoDS_Shape& theShape, +ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape, const ObjectPtr& theObject, CompositeFeaturePtr theSketch) { if (theShape.ShapeType() == TopAbs_EDGE) { - // Check that we already have such external edge - std::shared_ptr aInEdge = std::shared_ptr(new GeomAPI_Edge()); - aInEdge->setImpl(new TopoDS_Shape(theShape)); - ResultPtr aResult = findExternalEdge(theSketch, aInEdge); - if (aResult) - return aResult; - - // If not found then we have to create new Standard_Real aStart, aEnd; Handle(V3d_View) aNullView; FeaturePtr aMyFeature; @@ -468,7 +477,7 @@ ResultPtr PartSet_Tools::createFixedObjectByEdge(const TopoDS_Shape& theShape, DataPtr aData = aMyFeature->data(); AttributeSelectionPtr anAttr = std::dynamic_pointer_cast - (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID())); + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); ResultPtr aRes = std::dynamic_pointer_cast(theObject); if (anAttr && aRes) { @@ -489,19 +498,13 @@ ResultPtr PartSet_Tools::createFixedObjectByEdge(const TopoDS_Shape& theShape, } } if (theShape.ShapeType() == TopAbs_VERTEX) { - std::shared_ptr aInVert = std::shared_ptr(new GeomAPI_Vertex()); - aInVert->setImpl(new TopoDS_Shape(theShape)); - ResultPtr aResult = findExternalVertex(theSketch, aInVert); - if (aResult) - return aResult; - FeaturePtr aMyFeature = theSketch->addFeature(SketchPlugin_Point::ID()); if (aMyFeature) { DataPtr aData = aMyFeature->data(); AttributeSelectionPtr anAttr = std::dynamic_pointer_cast - (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID())); + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); ResultPtr aRes = std::dynamic_pointer_cast(theObject); if (anAttr && aRes) {