1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 // File: GDMLPlugin_ConeSegment.cpp
4 // Created: 23 Nov 2016
5 // Author: Clarisse Genrault (CEA)
7 #include <GDMLPlugin_ConeSegment.h>
9 #include <ModelAPI_Data.h>
10 #include <ModelAPI_ResultBody.h>
11 #include <ModelAPI_AttributeDouble.h>
12 #include <ModelAPI_AttributeString.h>
14 //=================================================================================================
15 GDMLPlugin_ConeSegment::GDMLPlugin_ConeSegment() // Nothing to do during instantiation
19 //=================================================================================================
20 void GDMLPlugin_ConeSegment::initAttributes()
22 data()->addAttribute(GDMLPlugin_ConeSegment::RMIN1_ID(), ModelAPI_AttributeDouble::typeId());
23 data()->addAttribute(GDMLPlugin_ConeSegment::RMAX1_ID(), ModelAPI_AttributeDouble::typeId());
24 data()->addAttribute(GDMLPlugin_ConeSegment::RMIN2_ID(), ModelAPI_AttributeDouble::typeId());
25 data()->addAttribute(GDMLPlugin_ConeSegment::RMAX2_ID(), ModelAPI_AttributeDouble::typeId());
26 data()->addAttribute(GDMLPlugin_ConeSegment::Z_ID(), ModelAPI_AttributeDouble::typeId());
27 data()->addAttribute(GDMLPlugin_ConeSegment::STARTPHI_ID(), ModelAPI_AttributeDouble::typeId());
28 data()->addAttribute(GDMLPlugin_ConeSegment::DELTAPHI_ID(), ModelAPI_AttributeDouble::typeId());
31 //=================================================================================================
32 void GDMLPlugin_ConeSegment::execute()
34 double aRMin1 = real(GDMLPlugin_ConeSegment::RMIN1_ID())->value();
35 double aRMax1 = real(GDMLPlugin_ConeSegment::RMAX1_ID())->value();
36 double aRMin2 = real(GDMLPlugin_ConeSegment::RMIN2_ID())->value();
37 double aRMax2 = real(GDMLPlugin_ConeSegment::RMAX2_ID())->value();
38 double aZ = real(GDMLPlugin_ConeSegment::Z_ID())->value();
39 double aStartPhi = real(GDMLPlugin_ConeSegment::STARTPHI_ID())->value();
40 double aDeltaPhi = real(GDMLPlugin_ConeSegment::DELTAPHI_ID())->value();
42 std::shared_ptr<GeomAlgoAPI_ConeSegment> aConeSegmentAlgo =
43 std::shared_ptr<GeomAlgoAPI_ConeSegment>(new GeomAlgoAPI_ConeSegment(aRMin1, aRMax1,
46 aStartPhi, aDeltaPhi));
48 // Check with that the arguments for aConeSegmentAlgo are correct
49 if (!aConeSegmentAlgo->check()){
50 setError(aConeSegmentAlgo->getError());
54 aConeSegmentAlgo->build();
56 // Check if the creation of the cone segment went well
57 if(!aConeSegmentAlgo->isDone()) {
58 setError(aConeSegmentAlgo->getError());
61 if (!aConeSegmentAlgo->checkValid("Cone Segment builder")) {
62 setError(aConeSegmentAlgo->getError());
67 ResultBodyPtr aResultConeSegment = document()->createBody(data(), aResultIndex);
68 loadNamingDS(aConeSegmentAlgo, aResultConeSegment);
69 setResult(aResultConeSegment, aResultIndex);
72 //=================================================================================================
73 void GDMLPlugin_ConeSegment::loadNamingDS(
74 std::shared_ptr<GeomAlgoAPI_ConeSegment> theConeSegmentAlgo,
75 std::shared_ptr<ModelAPI_ResultBody> theResultConeSegment)
78 theResultConeSegment->store(theConeSegmentAlgo->shape());
81 theConeSegmentAlgo->prepareNamingFaces();
85 std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
86 theConeSegmentAlgo->getCreatedFaces();
87 for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
88 it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
89 std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
90 theResultConeSegment->generated(aFace, (*it).first, num++);