X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultBody.cpp;h=d7e3f46c9fe0bf6336671aa5a4f3e1e83c62fbc4;hb=283433d9c2f39fbd332d6eba691b6a0cd875e29d;hp=f4a37d35316ac21749b73464e9d5e847ec469295;hpb=e77818ce255793f73f8188dedd30741f18942643;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index f4a37d353..d7e3f46c9 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -1,255 +1,43 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: Model_ResultBody.cpp // Created: 08 Jul 2014 // Author: Mikhail PONIKAROV #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include // DEB //#include //#include -Model_ResultBody::Model_ResultBody() -{ - setIsConcealed(false); -} - -void Model_ResultBody::store(const boost::shared_ptr& theShape) -{ - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); - if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); - // clean builders - clean(); - // store the new shape as primitive - TNaming_Builder aBuilder(aShapeLab); - if (!theShape) - return; // bad shape - TopoDS_Shape aShape = theShape->impl(); - if (aShape.IsNull()) - return; // null shape inside - - aBuilder.Generated(aShape); - } -} - -void Model_ResultBody::storeGenerated(const boost::shared_ptr& theFromShape, - const boost::shared_ptr& theToShape) -{ - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); - if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); - // clean builders - clean(); - // store the new shape as primitive - TNaming_Builder aBuilder(aShapeLab); - if (!theFromShape || !theToShape) - return; // bad shape - TopoDS_Shape aShapeBasis = theFromShape->impl(); - if (aShapeBasis.IsNull()) - return; // null shape inside - TopoDS_Shape aShapeNew = theToShape->impl(); - if (aShapeNew.IsNull()) - return; // null shape inside - aBuilder.Generated(aShapeBasis, aShapeNew); - } -} - -void Model_ResultBody::storeModified(const boost::shared_ptr& theOldShape, - const boost::shared_ptr& theNewShape) -{ - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); - if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); - // clean builders - clean(); - // store the new shape as primitive - TNaming_Builder aBuilder(aShapeLab); - if (!theOldShape || !theNewShape) - return; // bad shape - TopoDS_Shape aShapeOld = theOldShape->impl(); - if (aShapeOld.IsNull()) - return; // null shape inside - TopoDS_Shape aShapeNew = theNewShape->impl(); - if (aShapeNew.IsNull()) - return; // null shape inside - aBuilder.Generated(aShapeOld, aShapeNew); - } -} - -boost::shared_ptr Model_ResultBody::shape() -{ - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); - if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); - Handle(TNaming_NamedShape) aName; - if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { - TopoDS_Shape aShape = aName->Get(); - if (!aShape.IsNull()) { - boost::shared_ptr aRes(new GeomAPI_Shape); - aRes->setImpl(new TopoDS_Shape(aShape)); - return aRes; - } - } - } - return boost::shared_ptr(); -} - -void Model_ResultBody::clean() -{ - std::vector::iterator aBuilder = myBuilders.begin(); - for(; aBuilder != myBuilders.end(); aBuilder++) - delete *aBuilder; - myBuilders.clear(); -} - -Model_ResultBody::~Model_ResultBody() -{ - clean(); -} - -TNaming_Builder* Model_ResultBody::builder(const int theTag) -{ - if (myBuilders.size() <= (unsigned int)theTag) { - myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL); - } - if (!myBuilders[theTag]) { - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); - myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag)); - //TCollection_AsciiString entry;// - //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry); - //cout << "Label = " <& theNewShape, const int theTag) -{ - TopoDS_Shape aShape = theNewShape->impl(); - builder(theTag)->Generated(aShape); -} - -void Model_ResultBody::generated(const boost::shared_ptr& theOldShape, - const boost::shared_ptr& theNewShape, const int theTag) -{ - TopoDS_Shape anOldShape = theOldShape->impl(); - TopoDS_Shape aNewShape = theNewShape->impl(); - builder(theTag)->Generated(anOldShape, aNewShape); -} - - -void Model_ResultBody::modified(const boost::shared_ptr& theOldShape, - const boost::shared_ptr& theNewShape, const int theTag) -{ - TopoDS_Shape anOldShape = theOldShape->impl(); - TopoDS_Shape aNewShape = theNewShape->impl(); - builder(theTag)->Modify(anOldShape, aNewShape); -} +//#define DEB_IMPORT 1 -void Model_ResultBody::deleted(const boost::shared_ptr& theOldShape, - const int theTag) +Model_ResultBody::Model_ResultBody() { - TopoDS_Shape aShape = theOldShape->impl(); - builder(theTag)->Delete(aShape); + myBuilder = new Model_BodyBuilder(this); } -void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, - boost::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag) +void Model_ResultBody::initAttributes() { - TopoDS_Shape aShapeIn = theShapeIn->impl(); - TopTools_MapOfShape aView; - TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); - for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = ShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - boost::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); - if (theMS->isDeleted (aRShape)) { - builder(theTag)->Delete(aRoot); - } - } + // 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_ResultBody::loadAndOrientModifiedShapes ( - GeomAlgoAPI_MakeShape* theMS, - boost::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - GeomAPI_DataMapOfShapeShape& theSubShapes) +void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName, + std::string& theDefault) { - TopoDS_Shape aShapeIn = theShapeIn->impl(); - TopTools_MapOfShape aView; - TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); - for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = aShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - ListOfShape aList; - boost::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); - theMS->modified(aRShape, aList); - std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); - for (; anIt != aLast; anIt++) { - TopoDS_Shape aNewShape = (*anIt)->impl(); - if (theSubShapes.isBound(*anIt)) { - boost::shared_ptr aMapShape(theSubShapes.find(*anIt)); - aNewShape.Orientation(aMapShape->impl().Orientation()); - } - if (!aRoot.IsSame (aNewShape)) - builder(theTag)->Modify(aRoot,aNewShape); - } - } + theSection = "Visualization"; + theName = "result_body_color"; + theDefault = DEFAULT_COLOR(); } -void Model_ResultBody::loadAndOrientGeneratedShapes ( - GeomAlgoAPI_MakeShape* theMS, - boost::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - GeomAPI_DataMapOfShapeShape& theSubShapes) +bool Model_ResultBody::setDisabled(std::shared_ptr theThis, const bool theFlag) { - TopoDS_Shape aShapeIn = theShapeIn->impl(); - TopTools_MapOfShape aView; - TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); - for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = aShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - ListOfShape aList; - boost::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); - theMS->generated(aRShape, aList); - std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); - for (; anIt != aLast; anIt++) { - TopoDS_Shape aNewShape = (*anIt)->impl(); - if (theSubShapes.isBound(*anIt)) { - boost::shared_ptr aMapShape(theSubShapes.find(*anIt)); - aNewShape.Orientation(aMapShape->impl().Orientation()); - } - if (!aRoot.IsSame (aNewShape)) - builder(theTag)->Generated(aRoot,aNewShape); - } + bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag); + if (aChanged) { // state is changed, so modifications are needed + myBuilder->evolutionToSelection(theFlag); } + return aChanged; } - -void Model_ResultBody::loadFirstLevel(boost::shared_ptr theShapeIn,int& theTag) -{ - -} - -void Model_ResultBody::loadDisconnectedEdges(boost::shared_ptr theShapeIn,int& theTag) -{ - -} - -void Model_ResultBody::loadDisconnectedVertexes(boost::shared_ptr theShapeIn,int& theTag) -{ - -} \ No newline at end of file