1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_ResultConstruction.cpp
4 // Created: 07 Jul 2014
5 // Author: Mikhail PONIKAROV
7 #include <Model_ResultConstruction.h>
9 #include <Config_PropManager.h>
10 #include <GeomAPI_PlanarEdges.h>
11 #include <GeomAlgoAPI_SketchBuilder.h>
12 #include <Events_Loop.h>
13 #include <ModelAPI_Events.h>
15 void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName,
16 std::string& theDefault)
18 theSection = "Visualization";
19 theName = "result_construction_color";
20 theDefault = DEFAULT_COLOR();
23 void Model_ResultConstruction::setShape(std::shared_ptr<GeomAPI_Shape> theShape)
25 if (myShape != theShape && (!theShape.get() || !theShape->isEqual(myShape))) {
26 static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
27 ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
30 myFacesUpToDate = false;
36 std::shared_ptr<GeomAPI_Shape> Model_ResultConstruction::shape()
41 Model_ResultConstruction::Model_ResultConstruction()
45 myFacesUpToDate = false;
48 void Model_ResultConstruction::setIsInHistory(const bool isInHistory)
50 myIsInHistory = isInHistory;
53 int Model_ResultConstruction::facesNum()
55 if (!myFacesUpToDate) {
56 std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr =
57 std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(myShape);
59 std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
60 GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
61 aWirePtr->norm(), aWirePtr, aFaces);
62 std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aFIter = aFaces.begin();
63 for(; aFIter != aFaces.end(); aFIter++) {
64 std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(*aFIter));
65 if (aFace.get() && !aFace->isNull())
66 myFaces.push_back(aFace);
69 myFacesUpToDate = true;
71 return int(myFaces.size());
74 std::shared_ptr<GeomAPI_Face> Model_ResultConstruction::face(const int theIndex)
76 return myFaces[theIndex];
79 bool Model_ResultConstruction::isInfinite()
84 void Model_ResultConstruction::setInfinite(const bool theInfinite)
86 myIsInfinite = theInfinite;
89 void Model_ResultConstruction::setIsConcealed(const bool theValue)
91 // do nothing: the construction element is never consealed