From: szy Date: Wed, 3 Dec 2014 15:29:35 +0000 (+0300) Subject: Adding Naming DS for Placement operation. X-Git-Tag: V_0.6.0^2~26 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5746238455553297ce5333502e6f27e6e5d9348b;p=modules%2Fshaper.git Adding Naming DS for Placement operation. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp index af86e8152..96d52d77b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp @@ -12,6 +12,10 @@ #include #include +#define _MODIFIEDF_TAG 1 +#define _MODIFIEDE_TAG 2 +#define _MODIFIEDV_TAG 3 +#define _FACE 4 FeaturesPlugin_Placement::FeaturesPlugin_Placement() { } @@ -53,20 +57,20 @@ void FeaturesPlugin_Placement::execute() aFaceRef = std::dynamic_pointer_cast( data()->attribute(FeaturesPlugin_Placement::ATTRACT_FACE_ID())); - std::shared_ptr anAttractiveFace = + std::shared_ptr aSlaveObjectFace = std::dynamic_pointer_cast(aFaceRef->value()); - if (!anAttractiveFace) + if (!aSlaveObjectFace) return; - std::shared_ptr anAttractiveFaceContext; + std::shared_ptr aSlaveObject; aContextRes = aFaceRef->context(); if (aContextRes) { if (aContextRes->groupName() == ModelAPI_ResultBody::group()) - anAttractiveFaceContext = std::dynamic_pointer_cast(aContextRes)->shape(); + aSlaveObject = std::dynamic_pointer_cast(aContextRes)->shape(); else if (aContextRes->groupName() == ModelAPI_ResultConstruction::group()) - anAttractiveFaceContext = std::dynamic_pointer_cast(aContextRes)->shape(); + aSlaveObject = std::dynamic_pointer_cast(aContextRes)->shape(); } - if (!anAttractiveFaceContext) { + if (!aSlaveObject) { static const std::string aContextError = "The selection context is bad"; setError(aContextError); return; @@ -74,18 +78,18 @@ void FeaturesPlugin_Placement::execute() // Verify faces planarity std::shared_ptr aBaseFace1(new GeomAPI_Face(aBaseFace)); - std::shared_ptr anAttractFace1(new GeomAPI_Face(anAttractiveFace)); - if (!aBaseFace1->isPlanar() || !anAttractFace1->isPlanar()) { + std::shared_ptr aSlaveFace1(new GeomAPI_Face(aSlaveObjectFace)); + if (!aBaseFace1->isPlanar() || !aSlaveFace1->isPlanar()) { static const std::string aPlanarityError = "One of selected face is not planar"; setError(aPlanarityError); return; } std::shared_ptr aBasePlane = aBaseFace1->getPlane(); - std::shared_ptr anAttractivePlane = anAttractFace1->getPlane(); + std::shared_ptr aSlavePlane = aSlaveFace1->getPlane(); std::shared_ptr aResultBody = document()->createBody(data()); - GeomAlgoAPI_Placement aFeature(anAttractiveFaceContext, anAttractivePlane, aBasePlane); + GeomAlgoAPI_Placement aFeature(aSlaveObject, aSlavePlane, aBasePlane); if(!aFeature.isDone()) { static const std::string aFeatureError = "Placement algorithm failed"; setError(aFeatureError); @@ -104,7 +108,7 @@ void FeaturesPlugin_Placement::execute() return; } //LoadNamingDS - LoadNamingDS(aFeature, aResultBody, anAttractiveFace, anAttractiveFaceContext); + LoadNamingDS(aFeature, aResultBody, aSlaveObject); setResult(aResultBody); } @@ -113,44 +117,15 @@ void FeaturesPlugin_Placement::execute() void FeaturesPlugin_Placement::LoadNamingDS( GeomAlgoAPI_Placement& theFeature, std::shared_ptr theResultBody, - std::shared_ptr theBasis, - std::shared_ptr theContext) + std::shared_ptr theSlaveObject) { - theResultBody->store(theFeature.shape()); - /// TODO: SZY -/* - //load result - if(theBasis->isEqual(theContext)) - theResultBody->store(theFeature.shape()); - else - theResultBody->storeGenerated(theContext, theFeature.shape()); + theResultBody->storeModified(theSlaveObject, theFeature.shape()); // the initial Slave, the resulting Slave GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape(); theFeature.mapOfShapes(*aSubShapes); - //Insert lateral face : Face from Edge - theResultBody->loadAndOrientGeneratedShapes(theFeature.makeShape(), theBasis, EDGE,_LATERAL_TAG, *aSubShapes); - - //Insert bottom face - std::shared_ptr aBottomFace = theFeature.firstShape(); - if (!aBottomFace->isNull()) { - if (aSubShapes->isBound(aBottomFace)) { - aBottomFace = aSubShapes->find(aBottomFace); - } - theResultBody->generated(aBottomFace, _FIRST_TAG); - } - - - - //Insert top face - std::shared_ptr aTopFace = theFeature.lastShape(); - if (!aTopFace->isNull()) { - if (aSubShapes->isBound(aTopFace)) { - aTopFace = aSubShapes->find(aTopFace); - } - theResultBody->generated(aTopFace, _LAST_TAG); - } + // put modifed faces in DF + theResultBody->loadAndOrientModifiedShapes(theFeature.makeShape(), theSlaveObject, _FACE, _MODIFIEDF_TAG, *aSubShapes); -*/ } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.h b/src/FeaturesPlugin/FeaturesPlugin_Placement.h index a98793e02..cc9e30f3d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.h @@ -53,8 +53,7 @@ private: /// Load Naming data structure of the feature to the document void LoadNamingDS(GeomAlgoAPI_Placement& theFeature, std::shared_ptr theResultBody, - std::shared_ptr theBasis, - std::shared_ptr theContext); + std::shared_ptr theSlaveObject); }; #endif diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp index c20e9fd89..23a6c6f4d 100644 --- a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp +++ b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp @@ -18,6 +18,12 @@ void GeomAPI_DataMapOfShapeShape::clear() implPtr()->Clear(); } +/// Size +int GeomAPI_DataMapOfShapeShape::size() +{ + return implPtr()->Extent(); +} + /// Adds the Key to the Map with the Item. Returns True if the Key was not already in the map bool GeomAPI_DataMapOfShapeShape::bind (std::shared_ptr theKey, std::shared_ptr theItem) { diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.h b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.h index 94a35b780..4609bf08f 100644 --- a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.h +++ b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.h @@ -25,6 +25,9 @@ class GEOMAPI_EXPORT GeomAPI_DataMapOfShapeShape : public GeomAPI_Interface /// Clear void clear(); + /// Size of the map + int GeomAPI_DataMapOfShapeShape::size(); + /// Adds the Key to the Map with the Item. Returns True if the Key was not already in the map bool bind (std::shared_ptr theKey, std::shared_ptr theItem); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp index b21ecc64d..7fb667490 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp @@ -15,8 +15,7 @@ #include #include #include - - +#define DEB_PLACEMENT 1 GeomAlgoAPI_Placement::GeomAlgoAPI_Placement( std::shared_ptr theAttractiveFace, std::shared_ptr theSourcePlane, @@ -64,6 +63,12 @@ void GeomAlgoAPI_Placement::build( aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current())); myMap.bind(aCurrentShape, aCurrentShape); } +#ifdef DEB_PLACEMENT + int aNum = myMap.size(); + cout << "MAP of Oriented shapes =" << aNum <setImpl(new TopoDS_Shape(aResult)); myMkShape = new GeomAlgoAPI_MakeShape (aBuilder); } diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 59c65ac9e..13db22108 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -92,7 +92,7 @@ void Model_ResultBody::storeModified(const std::shared_ptr& theOl TopoDS_Shape aShapeNew = theNewShape->impl(); if (aShapeNew.IsNull()) return; // null shape inside - aBuilder.Generated(aShapeOld, aShapeNew); + aBuilder.Modify(aShapeOld, aShapeNew); } }