X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultConstruction.cpp;h=11cf883cd60908c0915e0fbf373948d640b0cf24;hb=b7298edf56ef8cbc903059859280cbce91c08c70;hp=a5e1ccc9bad7f3ec07530f19dc01e724bcf5a846;hpb=c0565e75ce0bd2f2994dc9874c4775cf7a4cb7ad;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index a5e1ccc9b..11cf883cd 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -1,26 +1,93 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: ModelAPI_ResultConstruction.cpp // Created: 07 Jul 2014 // Author: Mikhail PONIKAROV #include -void Model_ResultConstruction::setShape(boost::shared_ptr theShape) +#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::typeId()); +} + +void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName, + std::string& theDefault) { - myShape = theShape; + theSection = "Visualization"; + theName = "result_construction_color"; + theDefault = DEFAULT_COLOR(); } -boost::shared_ptr& Model_ResultConstruction::shape() +void Model_ResultConstruction::setShape(std::shared_ptr theShape) +{ + if (myShape != theShape && (!theShape.get() || !theShape->isEqual(myShape))) { + myShape = theShape; + if (theShape.get()) { + myFacesUpToDate = false; + myFaces.clear(); + } + } +} + +std::shared_ptr Model_ResultConstruction::shape() { return myShape; } -boost::shared_ptr Model_ResultConstruction::owner() +Model_ResultConstruction::Model_ResultConstruction() +{ + myIsDisabled = true; // by default it is not initialized and false to be after created + myIsInHistory = true; + myIsInfinite = false; + myFacesUpToDate = false; + setIsConcealed(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 myFaces.size(); +} + +std::shared_ptr Model_ResultConstruction::face(const int theIndex) +{ + return myFaces[theIndex]; +} + +bool Model_ResultConstruction::isInfinite() { - return myOwner; + return myIsInfinite; } -Model_ResultConstruction::Model_ResultConstruction( - const boost::shared_ptr& theFeature) - : myOwner(theFeature) +void Model_ResultConstruction::setInfinite(const bool theInfinite) { + myIsInfinite = theInfinite; }