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()
49 myFacesUpToDate = 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);
63 std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
64 GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
65 aWirePtr->norm(), aWirePtr, aFaces);
66 std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aFIter = aFaces.begin();
67 for(; aFIter != aFaces.end(); aFIter++) {
68 std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(*aFIter));
69 if (aFace.get() && !aFace->isNull())
70 myFaces.push_back(aFace);
73 myFacesUpToDate = true;
75 return myFaces.size();
78 std::shared_ptr<GeomAPI_Face> Model_ResultConstruction::face(const int theIndex)
80 return myFaces[theIndex];
83 bool Model_ResultConstruction::isInfinite()
88 void Model_ResultConstruction::setInfinite(const bool theInfinite)
90 myIsInfinite = theInfinite;
93 void Model_ResultConstruction::setIsConcealed(const bool theValue)
95 // do nothing: the construction element is never consealed