From: dbv Date: Thu, 16 Jun 2016 13:21:29 +0000 (+0300) Subject: Added CPP High API for FeaturesPlugin_Pipe X-Git-Tag: V_2.4.0~91^2~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45400ecc7d183dd2d2edb875bdb36f8fc031bc2c;p=modules%2Fshaper.git Added CPP High API for FeaturesPlugin_Pipe --- diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index a04936172..e01482c49 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -8,6 +8,7 @@ SET(PROJECT_HEADERS FeaturesAPI_Extrusion.h FeaturesAPI_ExtrusionBoolean.h FeaturesAPI_Group.h + FeaturesAPI_Pipe.h FeaturesAPI_Placement.h FeaturesAPI_Revolution.h FeaturesAPI_RevolutionBoolean.h @@ -20,6 +21,7 @@ SET(PROJECT_SOURCES FeaturesAPI_Extrusion.cpp FeaturesAPI_ExtrusionBoolean.cpp FeaturesAPI_Group.cpp + FeaturesAPI_Pipe.cpp FeaturesAPI_Placement.cpp FeaturesAPI_Rotation.cpp FeaturesAPI_Revolution.cpp diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index b88e019a1..0bf48a170 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -25,6 +25,7 @@ %shared_ptr(FeaturesAPI_ExtrusionCut) %shared_ptr(FeaturesAPI_ExtrusionFuse) %shared_ptr(FeaturesAPI_Group) +%shared_ptr(FeaturesAPI_Pipe) %shared_ptr(FeaturesAPI_Placement) %shared_ptr(FeaturesAPI_Revolution) %shared_ptr(FeaturesAPI_RevolutionBoolean) @@ -38,6 +39,7 @@ %include "FeaturesAPI_Extrusion.h" %include "FeaturesAPI_ExtrusionBoolean.h" %include "FeaturesAPI_Group.h" +%include "FeaturesAPI_Pipe.h" %include "FeaturesAPI_Placement.h" %include "FeaturesAPI_Revolution.h" %include "FeaturesAPI_RevolutionBoolean.h" diff --git a/src/FeaturesAPI/FeaturesAPI_Pipe.cpp b/src/FeaturesAPI/FeaturesAPI_Pipe.cpp new file mode 100644 index 000000000..a7e49e031 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_Pipe.cpp @@ -0,0 +1,141 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_Pipe.cpp +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#include "FeaturesAPI_Pipe.h" + +#include + +//================================================================================================== +FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + setPath(thePath); + } +} + +//================================================================================================== +FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const ModelHighAPI_Selection& theBiNoramal) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setByBasePathBiNormal(theBaseObjects, thePath, theBiNoramal); + } +} + +//================================================================================================== +FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const std::list& theLocations) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setByBasePathLocations(theBaseObjects, thePath, theLocations); + } +} + +//================================================================================================== +FeaturesAPI_Pipe::~FeaturesAPI_Pipe() +{ + +} + +//================================================================================================== +void FeaturesAPI_Pipe::setBase(const std::list& theBaseObjects) +{ + fillAttribute(theBaseObjects, mybaseObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_Pipe::setPath(const ModelHighAPI_Selection& thePath) +{ + fillAttribute(thePath, mypath); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_Pipe::setByBasePath(const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath) +{ + fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE(), mycreationMethod); + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(thePath, mypath); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_Pipe::setByBasePathBiNormal(const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const ModelHighAPI_Selection& theBiNoramal) +{ + fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL(), mycreationMethod); + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(thePath, mypath); + fillAttribute(theBiNoramal, mybiNormal); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_Pipe::setByBasePathLocations(const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const std::list& theLocations) +{ + fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS(), mycreationMethod); + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(thePath, mypath); + fillAttribute(theLocations, mylocations); + + execute(); +} + +// TODO(spo): make add* as static functions of the class +//================================================================================================== +PipePtr addPipe(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID()); + return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath)); +} + +//================================================================================================== +PipePtr addPipe(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const ModelHighAPI_Selection& theBiNoramal) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID()); + return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theBiNoramal)); +} + +//================================================================================================== +PipePtr addPipe(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const std::list& theLocations) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID()); + return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theLocations)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_Pipe.h b/src/FeaturesAPI/FeaturesAPI_Pipe.h new file mode 100644 index 000000000..1a3ee09a0 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_Pipe.h @@ -0,0 +1,112 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_Pipe.h +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#ifndef FeaturesAPI_Pipe_H_ +#define FeaturesAPI_Pipe_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_Pipe +/// \ingroup CPPHighAPI +/// \brief Interface for Pipe feature. +class FeaturesAPI_Pipe: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_Pipe(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_Pipe(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_Pipe(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const ModelHighAPI_Selection& theBiNoramal); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_Pipe(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const std::list& theLocations); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_Pipe(); + + INTERFACE_5(FeaturesPlugin_Pipe::ID(), + baseObjects, FeaturesPlugin_Pipe::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */, + path, FeaturesPlugin_Pipe::PATH_OBJECT_ID(), ModelAPI_AttributeSelection, /** Path */, + creationMethod, FeaturesPlugin_Pipe::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, + biNormal, FeaturesPlugin_Pipe::BINORMAL_ID(), ModelAPI_AttributeSelection, /** Bi-Normal */, + locations, FeaturesPlugin_Pipe::LOCATIONS_ID(), ModelAPI_AttributeSelectionList, /** Locations */) + + /// Modify base attribute of the feature. + FEATURESAPI_EXPORT + void setBase(const std::list& theBaseObjects); + + /// Modify path attribute of the feature. + FEATURESAPI_EXPORT + void setPath(const ModelHighAPI_Selection& thePath); + + /// Modify creation method, base and path. + FEATURESAPI_EXPORT + void setByBasePath(const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath); + + /// Modify creation method, base, path and bi-normal. + FEATURESAPI_EXPORT + void setByBasePathBiNormal(const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const ModelHighAPI_Selection& theBiNoramal); + + /// Modify creation method, base, path and locations. + FEATURESAPI_EXPORT + void setByBasePathLocations(const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const std::list& theLocations); +}; + +/// Pointer on Pipe object. +typedef std::shared_ptr PipePtr; + +/// \ingroup CPPHighAPI +/// \brief Create Pipe feature. +FEATURESAPI_EXPORT +PipePtr addPipe(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath); + +/// \ingroup CPPHighAPI +/// \brief Create Pipe feature. +FEATURESAPI_EXPORT +PipePtr addPipe(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const ModelHighAPI_Selection& theBiNoramal); + +/// \ingroup CPPHighAPI +/// \brief Create Pipe feature. +FEATURESAPI_EXPORT +PipePtr addPipe(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& thePath, + const std::list& theLocations); + +#endif // FeaturesAPI_Pipe_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_swig.h b/src/FeaturesAPI/FeaturesAPI_swig.h index a81bc621f..6d4e02b46 100644 --- a/src/FeaturesAPI/FeaturesAPI_swig.h +++ b/src/FeaturesAPI/FeaturesAPI_swig.h @@ -14,6 +14,7 @@ #include "FeaturesAPI_Extrusion.h" #include "FeaturesAPI_ExtrusionBoolean.h" #include "FeaturesAPI_Group.h" + #include "FeaturesAPI_Pipe.h" #include "FeaturesAPI_Placement.h" #include "FeaturesAPI_Revolution.h" #include "FeaturesAPI_RevolutionBoolean.h" diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp index ca171dd01..787a37fcc 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp @@ -129,7 +129,7 @@ void FeaturesPlugin_Pipe::execute() } // Searching faces with common edges. - if(aCreationMethod == "simple") { + if(aCreationMethod == CREATION_METHOD_SIMPLE()) { ListOfShape aShells; ListOfShape aFreeFaces; std::shared_ptr aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aBaseFacesList); @@ -158,7 +158,7 @@ void FeaturesPlugin_Pipe::execute() // Getting Bi-Normal std::shared_ptr aBiNormal; - if(aCreationMethod == "binormal") { + if(aCreationMethod == CREATION_METHOD_BINORMAL()) { AttributeSelectionPtr aBiNormalSelection = selection(BINORMAL_ID()); if(!aBiNormalSelection.get()) { setError("Error: Bi-Normal selection is empty."); @@ -177,7 +177,7 @@ void FeaturesPlugin_Pipe::execute() // Getting locations. ListOfShape aLocations; - if(aCreationMethod == "locations") { + if(aCreationMethod == CREATION_METHOD_LOCATIONS()) { AttributeSelectionListPtr aLocationsSelectionList = selectionList(LOCATIONS_ID()); if(!aLocationsSelectionList.get()) { setError("Error: Could not get locations selection list."); @@ -204,12 +204,13 @@ void FeaturesPlugin_Pipe::execute() // Generating result for each object. int aResultIndex = 0; - if(aCreationMethod == "simple" || aCreationMethod == "binormal") { + if(aCreationMethod == CREATION_METHOD_SIMPLE() || aCreationMethod == CREATION_METHOD_BINORMAL()) { for(ListOfShape::const_iterator anIter = aBaseShapesList.cbegin(); anIter != aBaseShapesList.cend(); anIter++) { std::shared_ptr aBaseShape = *anIter; - GeomAlgoAPI_Pipe aPipeAlgo = aCreationMethod == "simple" ? GeomAlgoAPI_Pipe(aBaseShape, aPathShape) : - GeomAlgoAPI_Pipe(aBaseShape, aPathShape, aBiNormal); + GeomAlgoAPI_Pipe aPipeAlgo = aCreationMethod == + CREATION_METHOD_SIMPLE() ? GeomAlgoAPI_Pipe(aBaseShape, aPathShape) : + GeomAlgoAPI_Pipe(aBaseShape, aPathShape, aBiNormal); if(!aPipeAlgo.isDone()) { setError("Error: Pipe algorithm failed."); @@ -231,7 +232,7 @@ void FeaturesPlugin_Pipe::execute() storeResult(aBaseShape, aPipeAlgo, aResultIndex++); } - } else if(aCreationMethod == "locations") { + } else if(aCreationMethod == CREATION_METHOD_LOCATIONS()) { GeomAlgoAPI_Pipe aPipeAlgo = GeomAlgoAPI_Pipe(aBaseShapesList, aLocations, aPathShape); if(!aPipeAlgo.isDone()) { diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.h b/src/FeaturesPlugin/FeaturesPlugin_Pipe.h index 6682f230c..aba97b091 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.h @@ -39,6 +39,27 @@ public: return MY_CREATION_METHOD; } + /// Attribute name for creation method. + inline static const std::string& CREATION_METHOD_SIMPLE() + { + static const std::string MY_CREATION_METHOD("simple"); + return MY_CREATION_METHOD; + } + + /// Attribute name for creation method. + inline static const std::string& CREATION_METHOD_BINORMAL() + { + static const std::string MY_CREATION_METHOD("binormal"); + return MY_CREATION_METHOD; + } + + /// Attribute name for creation method. + inline static const std::string& CREATION_METHOD_LOCATIONS() + { + static const std::string MY_CREATION_METHOD("locations"); + return MY_CREATION_METHOD; + } + /// Attribute name of base objects. inline static const std::string& BASE_OBJECTS_ID() {