X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultConstruction.cpp;h=e614fd89ca4f73ece682dcf6ff20d9cdb039bf80;hb=2c5d9762904d572995855e2ce2239ea0c3463eb5;hp=97f2b4fcd3808b381aad63b2d71c63cb8b06531c;hpb=31e91a8d11e03ddce87e8c2aa04695961a266a97;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index 97f2b4fcd..e614fd89c 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -8,24 +8,33 @@ #include #include +#include +#include void Model_ResultConstruction::initAttributes() { - // append the color attribute + // 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()); - AttributeIntArrayPtr aColorAttr = aData->intArray(COLOR_ID()); - std::vector aRGB; - aRGB = Config_PropManager::color("Visualization", "result_construction_color", DEFAULT_COLOR()); - aColorAttr->setSize(3); - aColorAttr->setValue(0, aRGB[0]); - aColorAttr->setValue(1, aRGB[1]); - aColorAttr->setValue(2, aRGB[2]); + aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId()); +} + +void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName, + std::string& theDefault) +{ + theSection = "Visualization"; + theName = "result_construction_color"; + theDefault = DEFAULT_COLOR(); } void Model_ResultConstruction::setShape(std::shared_ptr theShape) { - myShape = theShape; + if (myShape != theShape && (!theShape.get() || !theShape->isEqual(myShape))) { + myShape = theShape; + if (theShape.get()) { + myFacesUpToDate = false; + myFaces.clear(); + } + } } std::shared_ptr Model_ResultConstruction::shape() @@ -36,6 +45,7 @@ std::shared_ptr Model_ResultConstruction::shape() Model_ResultConstruction::Model_ResultConstruction() { myIsInHistory = true; + myFacesUpToDate = false; setIsConcealed(false); } @@ -43,3 +53,27 @@ void Model_ResultConstruction::setIsInHistory(const bool isInHistory) { myIsInHistory = isInHistory; } + +int Model_ResultConstruction::facesNum() +{ + if (!myFacesUpToDate) { + std::shared_ptr aWirePtr = + std::dynamic_pointer_cast(myShape); + 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()) + myFaces.push_back(aFace); + } + myFacesUpToDate = true; + } + return myFaces.size(); +} + +std::shared_ptr Model_ResultConstruction::face(const int theIndex) +{ + return myFaces[theIndex]; +}