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()
47 myIsDisabled = true; // by default it is not initialized and false to be after created
50 myFacesUpToDate = false;
51 setIsConcealed(false);
54 void Model_ResultConstruction::setIsInHistory(const bool isInHistory)
56 myIsInHistory = isInHistory;
59 int Model_ResultConstruction::facesNum()
61 if (!myFacesUpToDate) {
62 std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr =
63 std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(myShape);
65 std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
66 GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
67 aWirePtr->norm(), aWirePtr, aFaces);
68 std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aFIter = aFaces.begin();
69 for(; aFIter != aFaces.end(); aFIter++) {
70 std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(*aFIter));
72 myFaces.push_back(aFace);
75 myFacesUpToDate = true;
77 return myFaces.size();
80 std::shared_ptr<GeomAPI_Face> Model_ResultConstruction::face(const int theIndex)
82 return myFaces[theIndex];
85 bool Model_ResultConstruction::isInfinite()
90 void Model_ResultConstruction::setInfinite(const bool theInfinite)
92 myIsInfinite = theInfinite;