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 <ModelAPI_AttributeIntArray.h>
10 #include <Config_PropManager.h>
11 #include <GeomAPI_PlanarEdges.h>
12 #include <GeomAlgoAPI_SketchBuilder.h>
14 void Model_ResultConstruction::initAttributes()
16 // append the color attribute. It is empty, the attribute will be filled by a request
17 DataPtr aData = data();
18 aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
21 void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName,
22 std::string& theDefault)
24 theSection = "Visualization";
25 theName = "result_construction_color";
26 theDefault = DEFAULT_COLOR();
29 void Model_ResultConstruction::setShape(std::shared_ptr<GeomAPI_Shape> theShape)
31 if (myShape != theShape && (!theShape.get() || !theShape->isEqual(myShape))) {
34 myFacesUpToDate = false;
40 std::shared_ptr<GeomAPI_Shape> Model_ResultConstruction::shape()
45 Model_ResultConstruction::Model_ResultConstruction()
48 myFacesUpToDate = false;
49 setIsConcealed(false);
52 void Model_ResultConstruction::setIsInHistory(const bool isInHistory)
54 myIsInHistory = isInHistory;
57 int Model_ResultConstruction::facesNum()
59 if (!myFacesUpToDate) {
60 std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr =
61 std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(myShape);
62 std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
63 GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
64 aWirePtr->norm(), aWirePtr, aFaces);
65 std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aFIter = aFaces.begin();
66 for(; aFIter != aFaces.end(); aFIter++) {
67 std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(*aFIter));
69 myFaces.push_back(aFace);
71 myFacesUpToDate = true;
73 return myFaces.size();
76 std::shared_ptr<GeomAPI_Face> Model_ResultConstruction::face(const int theIndex)
78 return myFaces[theIndex];