X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultConstruction.cpp;h=a882b99d6a9ad5dc41bd8b318e2432d301c4e1de;hb=45400ecc7d183dd2d2edb875bdb36f8fc031bc2c;hp=a0f3b9306ed2281a13ef5fe3c7c96d4596f6b44f;hpb=694482299ca580d780c221cc6a3e7574e59fd2c3;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index a0f3b9306..a882b99d6 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -8,12 +8,16 @@ #include #include +#include +#include +#include +#include void Model_ResultConstruction::initAttributes() { // append the color attribute. It is empty, the attribute will be filled by a request DataPtr aData = data(); - aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type()); + aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId()); } void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName, @@ -26,7 +30,15 @@ void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::str void Model_ResultConstruction::setShape(std::shared_ptr theShape) { - myShape = theShape; + if (myShape != theShape && (!theShape.get() || !theShape->isEqual(myShape))) { + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); + myShape = theShape; + if (theShape.get()) { + myFacesUpToDate = false; + myFaces.clear(); + } + } } std::shared_ptr Model_ResultConstruction::shape() @@ -37,10 +49,52 @@ std::shared_ptr Model_ResultConstruction::shape() Model_ResultConstruction::Model_ResultConstruction() { myIsInHistory = true; - setIsConcealed(false); + myIsInfinite = false; + myFacesUpToDate = false; } void Model_ResultConstruction::setIsInHistory(const bool isInHistory) { myIsInHistory = isInHistory; } + +int Model_ResultConstruction::facesNum() +{ + if (!myFacesUpToDate) { + std::shared_ptr aWirePtr = + std::dynamic_pointer_cast(myShape); + if (aWirePtr.get()) { + std::list > aFaces; + GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(), + aWirePtr->norm(), aWirePtr, aFaces); + std::list >::iterator aFIter = aFaces.begin(); + for(; aFIter != aFaces.end(); aFIter++) { + std::shared_ptr aFace(new GeomAPI_Face(*aFIter)); + if (aFace.get() && !aFace->isNull()) + myFaces.push_back(aFace); + } + } + myFacesUpToDate = true; + } + return int(myFaces.size()); +} + +std::shared_ptr Model_ResultConstruction::face(const int theIndex) +{ + return myFaces[theIndex]; +} + +bool Model_ResultConstruction::isInfinite() +{ + return myIsInfinite; +} + +void Model_ResultConstruction::setInfinite(const bool theInfinite) +{ + myIsInfinite = theInfinite; +} + +void Model_ResultConstruction::setIsConcealed(const bool theValue) +{ + // do nothing: the construction element is never consealed +}