X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPrimitivesAPI%2FPrimitivesAPI_Cone.cpp;fp=src%2FPrimitivesAPI%2FPrimitivesAPI_Cone.cpp;h=da564cc8b0759244b4c6b7e51b5c4247b38049ed;hb=6cb54607705e4880cb22a8dd99cf211492d1d087;hp=0000000000000000000000000000000000000000;hpb=8c02cd3212ecefba1d69eb9d63f0cb94c98b0d3c;p=modules%2Fshaper.git diff --git a/src/PrimitivesAPI/PrimitivesAPI_Cone.cpp b/src/PrimitivesAPI/PrimitivesAPI_Cone.cpp new file mode 100644 index 000000000..da564cc8b --- /dev/null +++ b/src/PrimitivesAPI/PrimitivesAPI_Cone.cpp @@ -0,0 +1,105 @@ +// Copyright (C) 2014-201x CEA/DEN, EDF R&D --> + +// File: PrimitivesAPI_Cone.cpp +// Created: 20 Mar 2017 +// Author: Clarisse Genrault + +#include "PrimitivesAPI_Cone.h" + +#include +#include +#include + +//================================================================================================== +PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theBasePoint, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Double& theBaseRadius, + const ModelHighAPI_Double& theTopRadius, + const ModelHighAPI_Double& theHeight) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) { + fillAttribute(theBasePoint, basePoint()); + fillAttribute(theAxis, axis()); + fillAttribute(theBaseRadius, baseRadius()); + fillAttribute(theTopRadius, topRadius()); + setHeight(theHeight); + } +} + +//================================================================================================== +PrimitivesAPI_Cone::~PrimitivesAPI_Cone() +{ +} + +//================================================================================================== +void PrimitivesAPI_Cone::setRadius(const ModelHighAPI_Double& theBaseRadius, + const ModelHighAPI_Double& theTopRadius) +{ + fillAttribute(theBaseRadius, baseRadius()); + fillAttribute(theTopRadius, topRadius()); + execute(); +} + +//================================================================================================== +void PrimitivesAPI_Cone::setHeight(const ModelHighAPI_Double& theHeight) +{ + fillAttribute(theHeight, height()); + execute(); +} + +//================================================================================================== +void PrimitivesAPI_Cone::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + const std::string& aDocName = theDumper.name(aBase->document()); + + theDumper << aBase << " = model.addCone(" << aDocName; + + AttributeSelectionPtr anAttrBasePoint = + aBase->selection(PrimitivesPlugin_Cone::BASE_POINT_ID()); + AttributeSelectionPtr anAttrAxis = + aBase->selection(PrimitivesPlugin_Cone::AXIS_ID()); + theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis; + + AttributeDoublePtr anAttrBaseRadius = aBase->real(PrimitivesPlugin_Cone::BASE_RADIUS_ID()); + AttributeDoublePtr anAttrTopRadius = aBase->real(PrimitivesPlugin_Cone::TOP_RADIUS_ID()); + AttributeDoublePtr anAttrHeight = aBase->real(PrimitivesPlugin_Cone::HEIGHT_ID()); + theDumper << ", " << anAttrBaseRadius << ", " << anAttrTopRadius << ", " << anAttrHeight; + + theDumper << ")" << std::endl; +} + +//================================================================================================== +ConePtr addCone(const std::shared_ptr& thePart, + const ModelHighAPI_Selection& theBasePoint, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Double& theBaseRadius, + const ModelHighAPI_Double& theTopRadius, + const ModelHighAPI_Double& theHeight) +{ + std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID()); + return ConePtr(new PrimitivesAPI_Cone(aFeature, theBasePoint, theAxis, theBaseRadius, + theTopRadius, theHeight)); +} + +//================================================================================================== +ConePtr addCone(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theBaseRadius, + const ModelHighAPI_Double& theTopRadius, + const ModelHighAPI_Double& theHeight) +{ + ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin"); + ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ"); + std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID()); + return ConePtr(new PrimitivesAPI_Cone(aFeature, aBasePoint, anAxis, theBaseRadius, + theTopRadius, theHeight)); +} \ No newline at end of file