FeaturesAPI_Extrusion.h
FeaturesAPI_ExtrusionBoolean.h
FeaturesAPI_Intersection.h
+ FeaturesAPI_MultiRotation.h
FeaturesAPI_MultiTranslation.h
FeaturesAPI_Partition.h
FeaturesAPI_Pipe.h
FeaturesAPI_Extrusion.cpp
FeaturesAPI_ExtrusionBoolean.cpp
FeaturesAPI_Intersection.cpp
+ FeaturesAPI_MultiRotation.cpp
FeaturesAPI_MultiTranslation.cpp
FeaturesAPI_Partition.cpp
FeaturesAPI_Pipe.cpp
%shared_ptr(FeaturesAPI_ExtrusionCut)
%shared_ptr(FeaturesAPI_ExtrusionFuse)
%shared_ptr(FeaturesAPI_Intersection)
+%shared_ptr(FeaturesAPI_MultiRotation)
%shared_ptr(FeaturesAPI_MultiTranslation)
%shared_ptr(FeaturesAPI_Partition)
%shared_ptr(FeaturesAPI_Pipe)
%include "FeaturesAPI_Extrusion.h"
%include "FeaturesAPI_ExtrusionBoolean.h"
%include "FeaturesAPI_Intersection.h"
+%include "FeaturesAPI_MultiRotation.h"
%include "FeaturesAPI_MultiTranslation.h"
%include "FeaturesAPI_Partition.h"
%include "FeaturesAPI_Pipe.h"
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: FeaturesAPI_MultiRotation.cpp
+// Created: 04 Apr 2017
+// Author: Clarisse Genrault (CEA)
+
+#include <FeaturesAPI_MultiRotation.h>
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+
+//==================================================================================================
+FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Integer& theNumber)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ fillAttribute(theMainObjects, mainObjects());
+ fillAttribute(theAxis, axisAngular());
+ fillAttribute("",useStepAngular());
+ setNumberAngular(theNumber);
+ }
+}
+
+//==================================================================================================
+FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theStep,
+ const ModelHighAPI_Integer& theNumber)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ fillAttribute(theMainObjects, mainObjects());
+ fillAttribute(theAxis, axisAngular());
+ fillAttribute(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID(),useStepAngular());
+ fillAttribute(theStep, stepAngular());
+ setNumberAngular(theNumber);
+ }
+}
+
+//==================================================================================================
+FeaturesAPI_MultiRotation::~FeaturesAPI_MultiRotation()
+{
+}
+
+//==================================================================================================
+void FeaturesAPI_MultiRotation::setMainObjects(
+ const std::list<ModelHighAPI_Selection>& theMainObjects)
+{
+ fillAttribute(theMainObjects, mainObjects());
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_MultiRotation::setAxisAngular(const ModelHighAPI_Selection& theAxis)
+{
+ fillAttribute(theAxis, axisAngular());
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_MultiRotation::setStepAngular(const ModelHighAPI_Double& theStep)
+{
+ fillAttribute(theStep, stepAngular());
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_MultiRotation::setNumberAngular(const ModelHighAPI_Integer& theNumber)
+{
+ fillAttribute(theNumber, nbAngular());
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_MultiRotation::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ AttributeSelectionListPtr anAttrObjects =
+ aBase->selectionList(FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID());
+ theDumper << aBase << " = model.addMultiRotation(" << aDocName << ", " << anAttrObjects;
+
+ AttributeSelectionPtr anAttrAxis =
+ aBase->selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID());
+ theDumper << ", " << anAttrAxis;
+
+ if (aBase->string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->isInitialized()
+ && !aBase->string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->value().empty()) {
+ AttributeDoublePtr anAttrStepAngular =
+ aBase->real(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID());
+ theDumper << ", " << anAttrStepAngular;
+ }
+
+ AttributeIntegerPtr anAttrNumberAngular =
+ aBase->integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID());
+ theDumper << ", " << anAttrNumberAngular;
+
+ theDumper << ")" << std::endl;
+}
+
+//==================================================================================================
+MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Integer& theNumber)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ thePart->addFeature(FeaturesAPI_MultiRotation::ID());
+ return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
+ theAxis, theNumber));
+}
+
+//==================================================================================================
+MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theStep,
+ const ModelHighAPI_Integer& theNumber)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ thePart->addFeature(FeaturesAPI_MultiRotation::ID());
+ return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
+ theAxis, theStep, theNumber));
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: FeaturesAPI_MultiRotation.h
+// Created: 04 Apr 2017
+// Author: Clarisse Genrault (CEA)
+
+#ifndef FEATURESAPI_MULTIROTATION_H_
+#define FEATURESAPI_MULTIROTATION_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_MultiRotation.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Integer;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_MultiRotation
+/// \ingroup CPPHighAPI
+/// \brief Interface for Translation feature.
+class FeaturesAPI_MultiRotation: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ FEATURESAPI_EXPORT
+ explicit FeaturesAPI_MultiRotation(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ FEATURESAPI_EXPORT
+ FeaturesAPI_MultiRotation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Integer& theNumber);
+
+ /// Constructor with values.
+ FEATURESAPI_EXPORT
+ FeaturesAPI_MultiRotation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theStep,
+ const ModelHighAPI_Integer& theNumber);
+
+ /// Destructor.
+ FEATURESAPI_EXPORT
+ virtual ~FeaturesAPI_MultiRotation();
+
+ INTERFACE_5(FeaturesPlugin_MultiRotation::ID(),
+ mainObjects, FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID(),
+ ModelAPI_AttributeSelectionList, /** Main objects */,
+ axisAngular, FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID(),
+ ModelAPI_AttributeSelection, /** Angular direction */,
+ useStepAngular, FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID(),
+ ModelAPI_AttributeString, /** Use step angular */,
+ stepAngular, FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID(),
+ ModelAPI_AttributeDouble, /** Step angular */,
+ nbAngular, FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID(),
+ ModelAPI_AttributeInteger, /** Number of copies for angular */
+ )
+
+ /// Set main objects.
+ FEATURESAPI_EXPORT
+ void setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects);
+
+ /// Modify CreationMethod, axis_angular attribute of the feature.
+ FEATURESAPI_EXPORT
+ void setAxisAngular(const ModelHighAPI_Selection& theAxis);
+
+ /// Modify CreationMethod, step_angular attribute of the feature.
+ FEATURESAPI_EXPORT
+ void setStepAngular(const ModelHighAPI_Double& theStep);
+
+ /// Modify CreationMethod, nb_angular attribute of the feature.
+ FEATURESAPI_EXPORT
+ void setNumberAngular(const ModelHighAPI_Integer& theNumber);
+
+ /// Dump wrapped feature
+ FEATURESAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on Multirotation object.
+typedef std::shared_ptr<FeaturesAPI_MultiRotation> MultiRotationPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create MultiRotation feature.
+FEATURESAPI_EXPORT
+MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Integer& theNumber);
+
+/// \ingroup CPPHighAPI
+/// \brief Create MultiRotation feature.
+FEATURESAPI_EXPORT
+MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theStep,
+ const ModelHighAPI_Integer& theNumber);
+
+#endif // FEATURESAPI_MULTIROTATION_H_
virtual void dump(ModelHighAPI_Dumper& theDumper) const;
};
-/// Pointer on Translation object.
+/// Pointer on MultiTranslation object.
typedef std::shared_ptr<FeaturesAPI_MultiTranslation> MultiTranslationPtr;
/// \ingroup CPPHighAPI
#include "FeaturesAPI_Extrusion.h"
#include "FeaturesAPI_ExtrusionBoolean.h"
#include "FeaturesAPI_Intersection.h"
+ #include "FeaturesAPI_MultiRotation.h"
#include "FeaturesAPI_MultiTranslation.h"
#include "FeaturesAPI_Partition.h"
#include "FeaturesAPI_Pipe.h"
FeaturesPlugin_Symmetry.h
FeaturesPlugin_Scale.h
FeaturesPlugin_MultiTranslation.h
+ FeaturesPlugin_MultiRotation.h
)
SET(PROJECT_SOURCES
FeaturesPlugin_Symmetry.cpp
FeaturesPlugin_Scale.cpp
FeaturesPlugin_MultiTranslation.cpp
+ FeaturesPlugin_MultiRotation.cpp
)
SET(XML_RESOURCES
symmetry_widget.xml
scale_widget.xml
multitranslation_widget.xml
+ multirotation_widget.xml
)
SET(TEXT_RESOURCES
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File: FeaturesPlugin_MultiRotation.cpp
+// Created: 30 Jan 2017
+// Author: Clarisse Genrault (CEA)
+
+#include <FeaturesPlugin_MultiRotation.h>
+
+#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Translation.h>
+
+#include <GeomAPI_ShapeExplorer.h>
+
+#include <GeomAPI_Ax1.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultPart.h>
+
+#include <math.h>
+#include <iostream>
+
+//=================================================================================================
+FeaturesPlugin_MultiRotation::FeaturesPlugin_MultiRotation()
+{
+}
+
+//=================================================================================================
+void FeaturesPlugin_MultiRotation::initAttributes()
+{
+ AttributeSelectionListPtr aSelection =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
+ FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID(),
+ ModelAPI_AttributeSelectionList::typeId()));
+
+ data()->addAttribute(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID(),
+ ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID(),
+ ModelAPI_AttributeString::typeId());
+ data()->addAttribute(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID(),
+ ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID(),
+ ModelAPI_AttributeInteger::typeId());
+
+ /*data()->addAttribute(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID(),
+ ModelAPI_AttributeString::typeId());
+ data()->addAttribute(FeaturesPlugin_MultiRotation::STEP_RADIAL_ID(),
+ ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(FeaturesPlugin_MultiRotation::NB_COPIES_RADIAL_ID(),
+ ModelAPI_AttributeInteger::typeId());*/
+}
+
+//=================================================================================================
+void FeaturesPlugin_MultiRotation::execute()
+{
+ /*std::string useRadialDir = string(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID())->value();
+ if (useRadialDir.empty()) {
+ performRotation1D();
+ } else {
+ performRotation2D();
+ }*/
+ performRotation1D();
+}
+
+//=================================================================================================
+void FeaturesPlugin_MultiRotation::performRotation1D()
+{
+ // Getting objects.
+ ListOfShape anObjects;
+ std::list<ResultPtr> aContextes;
+ AttributeSelectionListPtr anObjectsSelList =
+ selectionList(FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID());
+ if (anObjectsSelList->size() == 0) {
+ return;
+ }
+ for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr =
+ anObjectsSelList->value(anObjectsIndex);
+ std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
+ if(!anObject.get()) { // may be for not-activated parts
+ eraseResults();
+ return;
+ }
+ anObjects.push_back(anObject);
+ aContextes.push_back(anObjectAttr->context());
+ }
+
+ //Getting axis.
+ std::shared_ptr<GeomAPI_Ax1> anAxis;
+ std::shared_ptr<GeomAPI_Edge> anEdge;
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
+ selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID());
+ if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
+ } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
+ anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
+ }
+ if(anEdge) {
+ anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
+ anEdge->line()->direction()));
+ }
+
+ // Getting number of copies.
+ int nbCopies =
+ integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID())->value();
+
+ if (nbCopies <=0) {
+ std::string aFeatureError = "Multirotation builder ";
+ aFeatureError+=":: the number of copies for the angular direction is null or negative.";
+ setError(aFeatureError);
+ return;
+ }
+
+ // Getting angle
+ double anAngle;
+ std::string useAngularStep =
+ string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->value();
+ if (!useAngularStep.empty()) {
+ anAngle = real(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID())->value();
+ } else {
+ anAngle = 360./nbCopies;
+ }
+
+ // Moving each object.
+ int aResultIndex = 0;
+ std::list<ResultPtr>::iterator aContext = aContextes.begin();
+ for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
+ anObjectsIt++, aContext++) {
+ std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
+ bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+
+ // Setting result.
+ if (isPart) {
+ ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
+ std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
+ for (int i=0; i<nbCopies; i++) {
+ aTrsf->setRotation(anAxis, i*anAngle);
+ ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
+ aResultPart->setTrsf(*aContext, aTrsf);
+ setResult(aResultPart, aResultIndex);
+ aResultIndex++;
+ }
+ } else {
+ ListOfShape aListOfShape;
+ std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > aListOfRotationAlgo;
+
+ for (int i=0; i<nbCopies; i++) {
+ std::shared_ptr<GeomAlgoAPI_Rotation> aRotationnAlgo(
+ new GeomAlgoAPI_Rotation(aBaseShape, anAxis, i*anAngle));
+
+ if (!aRotationnAlgo->check()) {
+ setError(aRotationnAlgo->getError());
+ break;
+ }
+
+ aRotationnAlgo->build();
+
+ // Checking that the algorithm worked properly.
+ if (!aRotationnAlgo->isDone()) {
+ static const std::string aFeatureError = "Error : Multitranslation algorithm failed.";
+ setError(aFeatureError);
+ break;
+ }
+ if (aRotationnAlgo->shape()->isNull()) {
+ static const std::string aShapeError = "Error : Resulting shape is null.";
+ setError(aShapeError);
+ break;
+ }
+ if (!aRotationnAlgo->isValid()) {
+ static const std::string aFeatureError = "Error : Resulting shape in not valid.";
+ setError(aFeatureError);
+ break;
+ }
+ aListOfShape.push_back(aRotationnAlgo->shape());
+ aListOfRotationAlgo.push_back(aRotationnAlgo);
+ }
+ std::shared_ptr<GeomAPI_Shape> aCompound =
+ GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+ ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+ aResultBody->storeModified(aBaseShape, aCompound);
+ loadNamingDS(aListOfRotationAlgo, aResultBody, aBaseShape);
+
+ setResult(aResultBody, aResultIndex);
+ }
+ aResultIndex++;
+ }
+
+ // Remove the rest results if there were produced in the previous pass.
+ removeResults(aResultIndex);
+}
+
+//=================================================================================================
+void FeaturesPlugin_MultiRotation::performRotation2D()
+{
+ // Getting objects.
+ ListOfShape anObjects;
+ std::list<ResultPtr> aContextes;
+ AttributeSelectionListPtr anObjectsSelList =
+ selectionList(FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID());
+ if (anObjectsSelList->size() == 0) {
+ return;
+ }
+ for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr =
+ anObjectsSelList->value(anObjectsIndex);
+ std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
+ if(!anObject.get()) { // may be for not-activated parts
+ eraseResults();
+ return;
+ }
+ anObjects.push_back(anObject);
+ aContextes.push_back(anObjectAttr->context());
+ }
+
+ //Getting axis.
+ std::shared_ptr<GeomAPI_Ax1> anAxis;
+ std::shared_ptr<GeomAPI_Edge> anEdge;
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
+ selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID());
+ if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
+ } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
+ anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
+ }
+ if(anEdge) {
+ anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
+ anEdge->line()->direction()));
+ }
+
+ // Getting number of copies int he angular direction.
+ int nbAngular =
+ integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID())->value();
+
+ if (nbAngular <=0) {
+ std::string aFeatureError = "Multirotation builder ";
+ aFeatureError+=":: the number of copies for the angular direction is null or negative.";
+ setError(aFeatureError);
+ return;
+ }
+
+ // Getting number of copies int he radial direction.
+ int nbRadial =
+ integer(FeaturesPlugin_MultiRotation::NB_COPIES_RADIAL_ID())->value();
+
+ if (nbRadial <=0) {
+ std::string aFeatureError = "Multirotation builder ";
+ aFeatureError+=":: the number of copies for the radial direction is null or negative.";
+ setError(aFeatureError);
+ return;
+ }
+
+ // Getting angle
+ double anAngle;
+ std::string useAngularStep =
+ string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->value();
+ if (!useAngularStep.empty()) {
+ anAngle = real(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID())->value();
+ } else {
+ anAngle = 360./nbAngular;
+ }
+
+ // Getting step
+ double aStep = real(FeaturesPlugin_MultiRotation::STEP_RADIAL_ID())->value();
+
+ // Moving each object.
+ int aResultIndex = 0;
+ std::list<ResultPtr>::iterator aContext = aContextes.begin();
+ for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
+ anObjectsIt++, aContext++) {
+ std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
+ bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+
+ std::shared_ptr<GeomAPI_Dir> aDir =
+ GeomAlgoAPI_ShapeTools::buildDirFromAxisAndShape(aBaseShape, anAxis);
+ double x = aDir->x();
+ double y = aDir->y();
+ double z = aDir->z();
+ double norm = sqrt(x*x+y*y+z*z);
+
+ // Setting result.
+ if (isPart) {
+ /*ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
+ std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
+ for (int j=0; j<aSecondNbCopies; j++) {
+ for (int i=0; i<aFirstNbCopies; i++) {
+ double dx = i*aFirstStep*x1/norm1+j*aSecondStep*x2/norm2;
+ double dy = i*aFirstStep*y1/norm1+j*aSecondStep*y2/norm2;
+ double dz = i*aFirstStep*z1/norm1+j*aSecondStep*z2/norm2;
+ aTrsf->setTranslation(dx, dy, dz);
+ ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
+ aResultPart->setTrsf(*aContext, aTrsf);
+ setResult(aResultPart, aResultIndex);
+ aResultIndex++;
+ }
+ }*/
+ } else {
+ ListOfShape aListOfShape;
+ std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
+ std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > aListOfRotationAlgo;
+ for (int j=0; j<nbRadial; j++) {
+ // Translation
+ double dx = j*aStep*x/norm;
+ double dy = j*aStep*y/norm;
+ double dz = j*aStep*z/norm;
+ std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+ new GeomAlgoAPI_Translation(aBaseShape, dx, dy, dz));
+
+ if (!aTranslationAlgo->check()) {
+ setError(aTranslationAlgo->getError());
+ break;
+ }
+
+ aTranslationAlgo->build();
+
+ // Checking that the algorithm worked properly.
+ if (!aTranslationAlgo->isDone()) {
+ static const std::string aFeatureError = "Error : Multirotation algorithm failed.";
+ setError(aFeatureError);
+ break;
+ }
+ if (aTranslationAlgo->shape()->isNull()) {
+ static const std::string aShapeError = "Error : Resulting shape is null.";
+ setError(aShapeError);
+ break;
+ }
+ if (!aTranslationAlgo->isValid()) {
+ static const std::string aFeatureError = "Error : Resulting shape in not valid.";
+ setError(aFeatureError);
+ break;
+ }
+ aListOfShape.push_back(aTranslationAlgo->shape());
+ aListOfTranslationAlgo.push_back(aTranslationAlgo);
+ for (int i=1; i<nbAngular; i++) {
+ std::shared_ptr<GeomAlgoAPI_Rotation> aRotationnAlgo(
+ new GeomAlgoAPI_Rotation(aTranslationAlgo->shape(), anAxis, i*anAngle));
+ if (!aRotationnAlgo->check()) {
+ setError(aTranslationAlgo->getError());
+ break;
+ }
+ aRotationnAlgo->build();// Checking that the algorithm worked properly.
+ if (!aRotationnAlgo->isDone()) {
+ static const std::string aFeatureError = "Error : Multirotation algorithm failed.";
+ setError(aFeatureError);
+ break;
+ }
+ if (aRotationnAlgo->shape()->isNull()) {
+ static const std::string aShapeError = "Error : Resulting shape is null.";
+ setError(aShapeError);
+ break;
+ }
+ if (!aRotationnAlgo->isValid()) {
+ static const std::string aFeatureError = "Error : Resulting shape in not valid.";
+ setError(aFeatureError);
+ break;
+ }
+ aListOfShape.push_back(aRotationnAlgo->shape());
+ aListOfRotationAlgo.push_back(aRotationnAlgo);
+ }
+ }
+ std::shared_ptr<GeomAPI_Shape> aCompound =
+ GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+ ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+ aResultBody->storeModified(aBaseShape, aCompound);
+
+ loadNamingDS2(aListOfTranslationAlgo, aResultBody, aBaseShape);
+ loadNamingDS3(aListOfRotationAlgo, aResultBody, aBaseShape, nbRadial);
+ setResult(aResultBody, aResultIndex);
+ }
+ aResultIndex++;
+ }
+
+ // Remove the rest results if there were produced in the previous pass.
+ removeResults(aResultIndex);
+}
+
+//=================================================================================================
+void FeaturesPlugin_MultiRotation::loadNamingDS2(
+ std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ std::shared_ptr<GeomAPI_Shape> theBaseShape)
+{
+ int aTag = 1;
+ int anIndex = 1;
+ std::string aRotatedName;
+
+ for (std::list<std::shared_ptr<GeomAlgoAPI_Translation> >::const_iterator anIt =
+ theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) {
+ std::cout << "LOAD" << std::endl;
+ std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = (*anIt)->mapOfSubShapes();
+
+ // naming of faces
+ aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex);
+ theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE,
+ aTag++, aRotatedName, *aSubShapes.get(),
+ false, true);
+
+ // naming of edges
+ aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex);
+ theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE,
+ aTag++, aRotatedName, *aSubShapes.get(),
+ false, true);
+
+ // naming of vertex
+ aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex);
+ theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX,
+ aTag++, aRotatedName, *aSubShapes.get(),
+ false, true);
+
+ ++anIndex;
+ }
+}
+
+//=================================================================================================
+void FeaturesPlugin_MultiRotation::loadNamingDS3(
+ std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > theListOfRotationAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ std::shared_ptr<GeomAPI_Shape> theBaseShape, int nb)
+{
+ int aTag = 6*nb+1;
+ int anIndex = nb+1;
+ std::string aRotatedName;
+
+ for (std::list<std::shared_ptr<GeomAlgoAPI_Rotation> >::const_iterator anIt =
+ theListOfRotationAlgo.begin(); anIt != theListOfRotationAlgo.cend(); ++anIt) {
+
+ // naming of faces
+ int numFace = 1;
+ GeomAPI_ShapeExplorer anExp((*anIt)->shape(), GeomAPI_Shape::FACE);
+ for(; anExp.more(); anExp.next()) {
+ aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex);
+ aRotatedName = aRotatedName + "_" + std::to_string((long long) numFace);
+ theResultBody->generated(anExp.current(), aRotatedName, aTag++);
+ ++numFace;
+ }
+ ++anIndex;
+ }
+}
+
+//=================================================================================================
+void FeaturesPlugin_MultiRotation::loadNamingDS(
+ std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > theListOfRotationAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ std::shared_ptr<GeomAPI_Shape> theBaseShape)
+{
+ int aTag = 1;
+ int anIndex = 1;
+ std::string aRotatedName;
+
+ for (std::list<std::shared_ptr<GeomAlgoAPI_Rotation> >::const_iterator anIt =
+ theListOfRotationAlgo.begin(); anIt != theListOfRotationAlgo.cend(); ++anIt) {
+ std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = (*anIt)->mapOfSubShapes();
+
+ // naming of faces
+ aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex);
+ theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE,
+ aTag++, aRotatedName, *aSubShapes.get(),
+ false, true);
+
+ // naming of edges
+ aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex);
+ theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE,
+ aTag++, aRotatedName, *aSubShapes.get(),
+ false, true);
+
+ // naming of vertex
+ aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex);
+ theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX,
+ aTag++, aRotatedName, *aSubShapes.get(),
+ false, true);
+ ++anIndex;
+ }
+}
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File: FeaturesPlugin_MultiRotation.h
+// Created: 30 Jan 2017
+// Author: Clarisse Genrault (CEA)
+
+#ifndef FEATURESPLUGIN_MULTIROTATION_H_
+#define FEATURESPLUGIN_MULTIROTATION_H_
+
+#include <FeaturesPlugin.h>
+
+#include <GeomAlgoAPI_Rotation.h>
+#include <GeomAlgoAPI_Translation.h>
+
+#include <ModelAPI_Feature.h>
+
+/** \class FeaturesPlugin_MultiRotation
+ * \ingroup Plugins
+ * \brief Feature that rotaes object around an axis an number of times.
+ * The 2D version also makes translated copies of the object and performs the rotation
+ * on these as well.
+ */
+class FeaturesPlugin_MultiRotation : public ModelAPI_Feature
+{
+ public:
+ /// Multi-rotation kind.
+ inline static const std::string& ID()
+ {
+ static const std::string MY_MULTIROTATION_ID("MultiRotation");
+ return MY_MULTIROTATION_ID;
+ }
+
+ /// Attribute name of referenced objects.
+ inline static const std::string& OBJECTS_LIST_ID()
+ {
+ static const std::string MY_OBJECTS_LIST_ID("main_objects");
+ return MY_OBJECTS_LIST_ID;
+ }
+
+ /// Attribute name of the angular direction.
+ inline static const std::string& AXIS_ANGULAR_ID()
+ {
+ static const std::string MY_AXIS_ANGULAR_ID("axis_angular");
+ return MY_AXIS_ANGULAR_ID;
+ }
+
+ /// Attribute name for use angular step.
+ inline static const std::string& USE_ANGULAR_STEP_ID()
+ {
+ static const std::string MY_USE_ANGULAR_STEP_ID("use_step_angular");
+ return MY_USE_ANGULAR_STEP_ID;
+ }
+
+ /// Attribute name of step for the angular.
+ inline static const std::string& STEP_ANGULAR_ID()
+ {
+ static const std::string MY_STEP_ANGULAR_ID("step_angular");
+ return MY_STEP_ANGULAR_ID;
+ }
+
+ /// Attribute name of number of copies for angular.
+ inline static const std::string& NB_COPIES_ANGULAR_ID()
+ {
+ static const std::string MY_NB_COPIES_ANGULAR_ID("nb_angular");
+ return MY_NB_COPIES_ANGULAR_ID;
+ }
+
+ /// Attribute name for use radial dir.
+ inline static const std::string& USE_RADIAL_DIR_ID()
+ {
+ static const std::string MY_USE_RADIAL_DIR_ID("use_radial_dir");
+ return MY_USE_RADIAL_DIR_ID;
+ }
+
+ /// Attribute name of radial step.
+ inline static const std::string& STEP_RADIAL_ID()
+ {
+ static const std::string MY_STEP_RADIAL_ID("step_radial");
+ return MY_STEP_RADIAL_ID;
+ }
+
+ /// Attribute name of number of copies for radial.
+ inline static const std::string& NB_COPIES_RADIAL_ID()
+ {
+ static const std::string MY_NB_COPIES_RADIAL_ID("nb_radial");
+ return MY_NB_COPIES_RADIAL_ID;
+ }
+
+ /// \return the kind of a feature.
+ FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = FeaturesPlugin_MultiRotation::ID();
+ return MY_KIND;
+ }
+
+ /// Creates a new part document if needed.
+ FEATURESPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes.
+ FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Use plugin manager for features creation.
+ FeaturesPlugin_MultiRotation();
+
+private:
+ /// Perform the multi rotation in one direction.
+ void performRotation1D();
+
+ /// Perform the multi totation in two directions.
+ void performRotation2D();
+
+ void loadNamingDS2(std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ std::shared_ptr<GeomAPI_Shape> theBaseShape);
+
+ void loadNamingDS3(std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > theListOfRotationAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ std::shared_ptr<GeomAPI_Shape> theBaseShape, int nb);
+
+ void loadNamingDS(std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > theListOfRotationAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ std::shared_ptr<GeomAPI_Shape> theBaseShape);
+};
+
+#endif // FEATURESPLUGIN_MULTIROTATION_H_
\ No newline at end of file
class FeaturesPlugin_MultiTranslation : public ModelAPI_Feature
{
public:
- /// Translation kind.
+ /// Multi-translation kind.
inline static const std::string& ID()
{
static const std::string MY_MULTITRANSLATION_ID("MultiTranslation");
#include <FeaturesPlugin_ExtrusionCut.h>
#include <FeaturesPlugin_ExtrusionFuse.h>
#include <FeaturesPlugin_Intersection.h>
+#include <FeaturesPlugin_MultiRotation.h>
#include <FeaturesPlugin_MultiTranslation.h>
#include <FeaturesPlugin_Partition.h>
#include <FeaturesPlugin_Pipe.h>
return FeaturePtr(new FeaturesPlugin_Scale);
} else if (theFeatureID == FeaturesPlugin_MultiTranslation::ID()) {
return FeaturePtr(new FeaturesPlugin_MultiTranslation);
+ } else if (theFeatureID == FeaturesPlugin_MultiRotation::ID()) {
+ return FeaturePtr(new FeaturesPlugin_MultiRotation);
}
// feature of such kind is not found
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ id="svg11250"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ viewBox="0 0 16 16"
+ sodipodi:docname="multi_rotation.svg"
+ inkscape:export-filename="/export/home/ldigallo/DOC_ALYOTECH/icones/Transformations/multi_rotation.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs11252">
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4903"
+ is_visible="true" />
+ <marker
+ inkscape:stockid="TriangleOutS"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker8735"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path8737"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.2,0.2)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="TriangleOutS"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="TriangleOutS"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path5715"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.2,0.2)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect13212"
+ is_visible="true" />
+ <marker
+ inkscape:stockid="EmptyTriangleOutS"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyTriangleOutS"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path5733"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.2,0,0,0.2,-0.6,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="TriangleOutM"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="TriangleOutM"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path5712"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.4,0.4)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Send"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Send"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path5582"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.2,0,0,-0.2,-1.2,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect12156"
+ is_visible="true" />
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 16 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="32 : 16 : 1"
+ inkscape:persp3d-origin="16 : 10.666667 : 1"
+ id="perspective12136" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect12134"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="skeletal"
+ id="path-effect12130"
+ is_visible="true"
+ pattern="M 0,5 C 0,2.24 2.24,0 5,0 7.76,0 10,2.24 10,5 10,7.76 7.76,10 5,10 2.24,10 0,7.76 0,5 Z"
+ copytype="single_stretched"
+ prop_scale="1"
+ scale_y_rel="false"
+ spacing="0"
+ normal_offset="0"
+ tang_offset="0"
+ prop_units="false"
+ vertical_pattern="false"
+ fuse_tolerance="0" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect12128"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="skeletal"
+ id="path-effect12124"
+ is_visible="true"
+ pattern="M 0,5 C 0,2.24 2.24,0 5,0 7.76,0 10,2.24 10,5 10,7.76 7.76,10 5,10 2.24,10 0,7.76 0,5 Z"
+ copytype="single_stretched"
+ prop_scale="1"
+ scale_y_rel="false"
+ spacing="0"
+ normal_offset="0"
+ tang_offset="0"
+ prop_units="false"
+ vertical_pattern="false"
+ fuse_tolerance="0" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect12122"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="skeletal"
+ id="path-effect12118"
+ is_visible="true"
+ pattern="m -0.04465162,5 c 0,-2.76 2.24000002,-5 5.00000002,-5 2.76,0 5,2.24 5,5 0,2.76 -2.24,5 -5,5 -2.76,0 -5.00000002,-2.24 -5.00000002,-5 z"
+ copytype="single_stretched"
+ prop_scale="1"
+ scale_y_rel="false"
+ spacing="0"
+ normal_offset="0"
+ tang_offset="0"
+ prop_units="false"
+ vertical_pattern="false"
+ fuse_tolerance="0" />
+ <marker
+ inkscape:stockid="TriangleOutS"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker18553-4"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path18555-7"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.2,0.2)" />
+ </marker>
+ <marker
+ inkscape:stockid="TriangleOutS"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker18553-3"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path18555-3"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.2,0.2)" />
+ </marker>
+ <marker
+ inkscape:stockid="TriangleOutS"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker18553-5"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path18555-73"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.2,0.2)" />
+ </marker>
+ <marker
+ inkscape:stockid="TriangleOutS"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker8735-6"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path8737-0"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.2,0.2)" />
+ </marker>
+ <marker
+ inkscape:stockid="TriangleOutS"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker8735-3"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path8737-1"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.2,0.2)" />
+ </marker>
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4481"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4481-6"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4481-6-3"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4481-1"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4481-1-4"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4359"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4734"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4359-3"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4734-3"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4359-85"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4734-0"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4359-8"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4734-4"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4812"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4481-5"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4481-9-0"
+ is_visible="true" />
+ <inkscape:path-effect
+ effect="spiro"
+ id="path-effect4481-9"
+ is_visible="true" />
+ <filter
+ inkscape:label="Pixellize"
+ inkscape:menu="Pixel tools"
+ inkscape:menu-tooltip="Reduce or remove antialiasing around shapes"
+ style="color-interpolation-filters:sRGB"
+ id="filter5039-5">
+ <feColorMatrix
+ values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1000 -500 "
+ id="feColorMatrix5041-7" />
+ </filter>
+ <filter
+ inkscape:label="Pixellize"
+ inkscape:menu="Pixel tools"
+ inkscape:menu-tooltip="Reduce or remove antialiasing around shapes"
+ style="color-interpolation-filters:sRGB"
+ id="filter5039-5-6">
+ <feColorMatrix
+ values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1000 -500 "
+ id="feColorMatrix5041-7-2" />
+ </filter>
+ <filter
+ inkscape:label="Pixellize"
+ inkscape:menu="Pixel tools"
+ inkscape:menu-tooltip="Reduce or remove antialiasing around shapes"
+ style="color-interpolation-filters:sRGB"
+ id="filter5039-5-6-1">
+ <feColorMatrix
+ values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1000 -500 "
+ id="feColorMatrix5041-7-2-9" />
+ </filter>
+ <filter
+ inkscape:label="Pixellize"
+ inkscape:menu="Pixel tools"
+ inkscape:menu-tooltip="Reduce or remove antialiasing around shapes"
+ style="color-interpolation-filters:sRGB"
+ id="filter5039-5-6-1-4">
+ <feColorMatrix
+ values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1000 -500 "
+ id="feColorMatrix5041-7-2-9-3" />
+ </filter>
+ <filter
+ inkscape:label="Pixellize"
+ inkscape:menu="Pixel tools"
+ inkscape:menu-tooltip="Reduce or remove antialiasing around shapes"
+ style="color-interpolation-filters:sRGB"
+ id="filter5039-5-6-1-4-6">
+ <feColorMatrix
+ values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1000 -500 "
+ id="feColorMatrix5041-7-2-9-3-7" />
+ </filter>
+ <filter
+ inkscape:label="Pixellize"
+ inkscape:menu="Pixel tools"
+ inkscape:menu-tooltip="Reduce or remove antialiasing around shapes"
+ style="color-interpolation-filters:sRGB"
+ id="filter5039-5-6-1-4-6-2">
+ <feColorMatrix
+ values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1000 -500 "
+ id="feColorMatrix5041-7-2-9-3-7-6" />
+ </filter>
+ <filter
+ inkscape:label="Pixellize"
+ inkscape:menu="Pixel tools"
+ inkscape:menu-tooltip="Reduce or remove antialiasing around shapes"
+ style="color-interpolation-filters:sRGB"
+ id="filter5039-5-6-1-4-6-2-3">
+ <feColorMatrix
+ values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1000 -500 "
+ id="feColorMatrix5041-7-2-9-3-7-6-9" />
+ </filter>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="31.672165"
+ inkscape:cx="2.7791679"
+ inkscape:cy="6.2438977"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:window-width="1920"
+ inkscape:window-height="1006"
+ inkscape:window-x="0"
+ inkscape:window-y="25"
+ inkscape:window-maximized="1"
+ inkscape:snap-center="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-others="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-grids="false"
+ inkscape:object-paths="false"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-page="false"
+ showguides="false"
+ inkscape:snap-global="true"
+ inkscape:showpageshadow="false"
+ inkscape:object-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid11798" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata11255">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ transform="translate(0,-16)">
+ <g
+ transform="matrix(0.61508511,0,0,0.77777773,0.02030893,10.560744)"
+ id="g4929"
+ style="stroke:none;stroke-opacity:1">
+ <path
+ sodipodi:nodetypes="ccccccc"
+ style="fill:#b7d9ea;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m -0.04504951,16.04505 0,-8.0000005 4.00000001,0 0,4.0000005 4,0 0,4 z"
+ id="path4836"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="ccccccccccc"
+ style="fill:#1b4955;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 0.95495049,7.0450495 -1,1 4.00000001,0 0,4.0000005 4,0 0,4 1,-1 0,-4 -4,0 0,-4.0000005 z"
+ id="path4838"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ transform="matrix(0.50384823,0.35279833,-0.44611498,0.63711822,12.416596,13.249382)"
+ id="g4929-3"
+ style="stroke:none;stroke-opacity:1">
+ <path
+ sodipodi:nodetypes="ccccccc"
+ style="fill:#b7d9ea;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m -0.04504951,16.04505 0,-8.0000005 4.00000001,0 0,4.0000005 4,0 0,4 z"
+ id="path4836-4"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="ccccccccccc"
+ style="fill:#1b4955;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 0.95495049,7.0450495 -1,1 4.00000001,0 0,4.0000005 4,0 0,4 1,-1 0,-4 -4,0 0,-4.0000005 z"
+ id="path4838-7"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ transform="matrix(0.2103715,0.57799095,-0.730872,0.26601565,20.064311,22.847031)"
+ id="g4929-3-7"
+ style="stroke:none;stroke-opacity:1">
+ <path
+ sodipodi:nodetypes="ccccccc"
+ style="fill:#b7d9ea;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m -0.04504951,16.04505 0,-8.0000005 4.00000001,0 0,4.0000005 4,0 0,4 z"
+ id="path4836-4-4"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="ccccccccccc"
+ style="fill:#1b4955;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 0.95495049,7.0450495 -1,1 4.00000001,0 0,4.0000005 4,0 0,4 1,-1 0,-4 -4,0 0,-4.0000005 z"
+ id="path4838-7-8"
+ inkscape:connector-curvature="0" />
+ </g>
+ <path
+ style="fill:#fecc02;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.69999999;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 0.51277295,27.461033 1.700539,26.273267 3.0808095,27.653538 4.4610798,26.273267 5.6488459,27.461033 4.2685755,28.841304 5.6488459,30.221574 4.4610798,31.40934 3.0808095,30.02907 1.700539,31.40934 0.51277295,30.221574 1.8930434,28.841304 0.51277295,27.461033"
+ id="path4453"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
--- /dev/null
+<!-- Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+<source>
+ <multi_selector id="main_objects"
+ label="Main objects"
+ icon=""
+ tooltip="Select objects"
+ type_choice="objects"
+ concealment="true">
+ <validator id="FeaturesPlugin_ValidatorTransform"/>
+ </multi_selector>
+ <groupbox title="Angular direction">
+ <shape_selector id="axis_angular"
+ icon="icons/Features/axis.png"
+ label="Axis"
+ tooltip="Select an edge for the angular direction"
+ shape_types="edge"
+ default="">
+ <validator id="GeomValidators_ShapeType" parameters="line"/>
+ </shape_selector>
+ <optionalbox id="use_step_angular" title="Angular step">
+ <doublevalue id="step_angular"
+ label="Angular step"
+ step="1.0"
+ default="0"
+ tooltip="Step for the angular direction">
+ </doublevalue>
+ </optionalbox>
+ <integervalue id="nb_angular"
+ label="Nb copies"
+ step="1"
+ default="2"
+ icon=""
+ tooltip="Number of copies for the first direction">
+ </integervalue>
+ </groupbox>
+ <!--<optionalbox id="use_radial_dir" title="Radial direction">
+ <doublevalue id="step_radial"
+ label="Step"
+ step="1.0"
+ default="0"
+ icon="icons/Features/dimension_v.png"
+ tooltip="Step for the radial direction">
+ </doublevalue>
+ <integervalue id="nb_radial"
+ label="Nb copies"
+ step="1"
+ default="2"
+ icon=""
+ tooltip="Number of copies for the radial direction">
+ </integervalue>
+ </optionalbox>-->
+</source>
\ No newline at end of file
<feature id="MultiTranslation" title="MultiTranslation" tooltip="Perform multi-translation objects" icon="icons/Features/multitranslation.png">
<source path="multitranslation_widget.xml"/>
</feature>
+ <feature id="MultiRotation" title="MultiRotation" tooltip="Perform multi-rotation objects" icon="icons/Features/multirotation.png">
+ <source path="multirotation_widget.xml"/>
+ </feature>
</group>
</workbench>
</plugin>
GeomAlgoAPI_ShapeAPI.h
GeomAlgoAPI_Exception.h
GeomAlgoAPI_Box.h
+ GeomAlgoAPI_Cone.h
GeomAlgoAPI_Cylinder.h
+ GeomAlgoAPI_Sphere.h
+ GeomAlgoAPI_Torus.h
GeomAlgoAPI_XAOExport.h
GeomAlgoAPI_XAOImport.h
GeomAlgoAPI_Copy.h
GeomAlgoAPI_ShapeAPI.cpp
GeomAlgoAPI_Exception.cpp
GeomAlgoAPI_Box.cpp
+ GeomAlgoAPI_Cone.cpp
GeomAlgoAPI_Cylinder.cpp
+ GeomAlgoAPI_Sphere.cpp
+ GeomAlgoAPI_Torus.cpp
GeomAlgoAPI_XAOExport.cpp
GeomAlgoAPI_XAOImport.cpp
GeomAlgoAPI_Copy.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_Cone.cpp
+// Created: 20 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#include <GeomAlgoAPI_Cone.h>
+
+#include <gp_Ax2.hxx>
+
+#include <BRepPrimAPI_MakeCone.hxx>
+
+//=================================================================================================
+GeomAlgoAPI_Cone::GeomAlgoAPI_Cone()
+{
+}
+
+//=================================================================================================
+GeomAlgoAPI_Cone::GeomAlgoAPI_Cone(std::shared_ptr<GeomAPI_Ax2> theAxis,
+ const double theBaseRadius,
+ const double theTopRadius,
+ const double theHeight)
+{
+ myAxis = theAxis;
+ myBaseRadius = theBaseRadius;
+ myTopRadius = theTopRadius;
+ myHeight = theHeight;
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_Cone::check()
+{
+ if (!myAxis) {
+ myError = "Cone builder :: axis is not valid.";
+ return false;
+ } else if (myBaseRadius < Precision::Confusion() && myTopRadius < Precision::Confusion()) {
+ myError = "Cone builder :: base radius and top radius are negative or null.";
+ return false;
+ } else if (myBaseRadius < 0.) {
+ myError = "Cone builder :: base radius is negative.";
+ return false;
+ } else if (myTopRadius < 0.) {
+ myError = "Cone builder :: top radius is negative.";
+ return false;
+ } else if (fabs(myBaseRadius-myTopRadius) < Precision::Confusion()) {
+ myError = "Cone builder :: base radius and top radius are too close.";
+ return false;
+ } else if (myHeight < Precision::Confusion()) {
+ myError = "Cone builder :: height is negative or null.";
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_Cone::build()
+{
+ myCreatedFaces.clear();
+
+ const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
+
+ // Construct the torus
+ BRepPrimAPI_MakeCone *aConeMaker =
+ new BRepPrimAPI_MakeCone(anAxis, myBaseRadius, myTopRadius, myHeight);
+
+ aConeMaker->Build();
+
+ if (!aConeMaker->IsDone()) {
+ return;
+ }
+
+ TopoDS_Shape aResult = aConeMaker->Shape();
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aResult));
+ setShape(aShape);
+
+ // Test on the shapes
+ if (!aShape.get() || aShape->isNull()) {
+ myError = "Torus builder :: resulting shape is null.";
+ return;
+ }
+
+ setImpl(aConeMaker);
+
+ setDone(true);
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_Cone.h
+// Created: 20 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#ifndef GEOMALGOAPI_CONE_H_
+#define GEOMALGOAPI_CONE_H_
+
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Ax2.h>
+
+/**\class GeomAlgoAPI_Cone
+ * \ingroup DataAlgo
+ * \brief Allows to create Cone Primitives
+ */
+class GeomAlgoAPI_Cone : public GeomAlgoAPI_MakeShape
+{
+ public:
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Cone();
+
+ /// Creates a cone.
+ /// \param theAxis The axis of the cone
+ /// \param theBaseRadius The base radius of the cone
+ /// \param theTopRadius The top radius of the cone
+ /// \param theHeight The height of the cone
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Cone(std::shared_ptr<GeomAPI_Ax2> theAxis,
+ const double theBaseRadius,
+ const double theTopRadius,
+ const double theHeight);
+
+ /// Checks if data for the cone construction is OK.
+ GEOMALGOAPI_EXPORT bool check();
+
+ /// Builds the cone.
+ GEOMALGOAPI_EXPORT void build();
+
+ private:
+ std::shared_ptr<GeomAPI_Ax2> myAxis; /// Axis of the cone.
+ double myBaseRadius; /// Base radius of the cone.
+ double myTopRadius; /// Top radius of the cone.
+ double myHeight; /// Height of the cone.
+};
+
+#endif // GEOMALGOAPI_CONE_H_
#include <BRepPrimAPI_MakeCylinder.hxx>
-#include <iostream>
-
//=================================================================================================
GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder()
{
const double theHeight,
const double theAngle);
- /// Checks if data for the cyminder construction is OK.
+ /// Checks if data for the cylinder construction is OK.
GEOMALGOAPI_EXPORT bool check();
/// Builds the cylinder.
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_MultiRotation.cpp
+// Created: 30 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#include "GeomAlgoAPI_MultiRotation.h"
+
+//=================================================================================================
+GeomAlgoAPI_MultiRotation::GeomAlgoAPI_MultiRotation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> theAxis,
+ double theAngle)
+{
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_MultiRotation::check()
+{
+ return true;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MultiRotation::build()
+{
+ setDone(true);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_MultiRotation.h
+// Created: 30 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#ifndef GEOMALGOAPI_MULTIROTATION_H_
+#define GEOMALGOAPI_MULTIROTATION_H_
+
+#include <GeomAlgoAPI.h>
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Ax1.h>
+#include <GeomAPI_Shape.h>
+
+/// \class GeomAlgoAPI_MultiRotation
+/// \ingroup DataAlgo
+/// \brief Creates a copy of the object by rotating it around the axis.
+class GeomAlgoAPI_MultiRotation : public GeomAlgoAPI_MakeShape
+{
+public:
+
+ /// \brief Creates an object which is obtained from current object by rotating it around the axis
+ /// with the angle.
+ /// \param[in] theSourceShape a shape to be rotated.
+ /// \param[in] theAxis rotation axis.
+ /// \param[in] theAngle rotation angle(in degree).
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_MultiRotation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> theAxis,
+ double theAngle);
+
+ /// Checks if data for the translation execution is OK.
+ GEOMALGOAPI_EXPORT bool check();
+
+ /// Execute the translation.
+ GEOMALGOAPI_EXPORT void build();
+
+private:
+ std::shared_ptr<GeomAPI_Shape> mySourceShape; /// Shape to be rotated.
+ std::shared_ptr<GeomAPI_Ax1> myAxis; /// Rotation axis.
+ double myAngle; /// Rotation angle.
+ std::shared_ptr<GeomAPI_Pnt> myCenterPoint; /// Rotation center point.
+ std::shared_ptr<GeomAPI_Pnt> myStartPoint; /// Rotation start point.
+ std::shared_ptr<GeomAPI_Pnt> myEndPoint; /// Rotation end point.
+};
+
+#endif // GEOMALGOAPI_MULTIROTATION_H_
myError = "Rotation builder :: source shape is not valid.";
return false;
}
- if (myAngle < -360.) {
- myError = "Rotation builder :: angle smaller than -360 degrees.";
- return false;
- }
- if (myAngle > 360.) {
- myError = "Rotation builder :: angle greater than 360 degrees.";
- return false;
- }
return true;
}
case BY_POINTS: {
#include "GeomAlgoAPI_ShapeAPI.h"
#include <GeomAlgoAPI_Box.h>
-#include <GeomAlgoAPI_Cylinder.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_Cone.h>
#include <GeomAlgoAPI_ConeSegment.h>
+#include <GeomAlgoAPI_Cylinder.h>
#include <GeomAlgoAPI_EdgeBuilder.h>
#include <GeomAlgoAPI_Rotation.h>
#include <GeomAlgoAPI_Scale.h>
+#include <GeomAlgoAPI_Sphere.h>
#include <GeomAlgoAPI_Symmetry.h>
+#include <GeomAlgoAPI_Torus.h>
#include <GeomAlgoAPI_Translation.h>
#include <GeomAPI_Lin.h>
return aCylinderAlgo.shape();
}
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(
+ std::shared_ptr<GeomAPI_Pnt> theCenterPoint, double theRadius) throw (GeomAlgoAPI_Exception)
+ {
+ GeomAlgoAPI_Sphere aSphereAlgo(theCenterPoint, theRadius);
+
+ if (!aSphereAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+
+ aSphereAlgo.build();
+
+ if(!aSphereAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+
+ if (!aSphereAlgo.checkValid("Sphere builder")) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+ return aSphereAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(double theRadius)
+ throw (GeomAlgoAPI_Exception)
+ {
+ std::shared_ptr<GeomAPI_Pnt> aCenterPoint =
+ std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
+
+ GeomAlgoAPI_Sphere aSphereAlgo(aCenterPoint, theRadius);
+
+ if (!aSphereAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+
+ aSphereAlgo.build();
+
+ if(!aSphereAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+
+ if (!aSphereAlgo.checkValid("Sphere builder")) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+ return aSphereAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(
+ std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+ std::shared_ptr<GeomAPI_Edge> theEdge,double theRadius, double theRingRadius)
+ throw (GeomAlgoAPI_Exception)
+ {
+ // Check if the base point is OK
+ if (!theBasePoint) {
+ throw GeomAlgoAPI_Exception("Torus builder :: the base point is not valid.");
+ }
+ // Check if the edge is OK
+ if (!theEdge) {
+ throw GeomAlgoAPI_Exception("Torus builder :: the axis is not valid.");
+ }
+
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
+ theEdge->line()->direction()));
+
+ GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
+
+ if (!aTorusAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+
+ aTorusAlgo.build();
+
+ if(!aTorusAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+
+ if (!aTorusAlgo.checkValid("Torus builder")) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+ return aTorusAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(double theRadius,
+ double theRingRadius) throw (GeomAlgoAPI_Exception)
+ {
+ std::shared_ptr<GeomAPI_Pnt> aBasePoint =
+ std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
+ std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
+ aEdge->line()->direction()));
+
+ GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
+
+ if (!aTorusAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+
+ aTorusAlgo.build();
+
+ if(!aTorusAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+
+ if (!aTorusAlgo.checkValid("Torus builder")) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+ return aTorusAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
+ std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+ std::shared_ptr<GeomAPI_Edge> theEdge,
+ double theBaseRadius, double theTopRadius,
+ double theHeight) throw (GeomAlgoAPI_Exception)
+ {
+ // Check if the base point is OK
+ if (!theBasePoint) {
+ throw GeomAlgoAPI_Exception("Cone builder :: the base point is not valid.");
+ }
+ // Check if the edge is OK
+ if (!theEdge) {
+ throw GeomAlgoAPI_Exception("Cone builder :: the axis is not valid.");
+ }
+
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
+ theEdge->line()->direction()));
+
+ GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
+
+ if (!aConeAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+
+ aConeAlgo.build();
+
+ if(!aConeAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+
+ if (!aConeAlgo.checkValid("Cone builder")) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+ return aConeAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
+ double theBaseRadius, double theTopRadius,
+ double theHeight) throw (GeomAlgoAPI_Exception)
+ {
+ std::shared_ptr<GeomAPI_Pnt> aBasePoint =
+ std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
+ std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
+ aEdge->line()->direction()));
+
+ GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
+
+ if (!aConeAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+
+ aConeAlgo.build();
+
+ if(!aConeAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+
+ if (!aConeAlgo.checkValid("Cone builder")) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+ return aConeAlgo.shape();
+ }
+
//===============================================================================================
std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
std::shared_ptr<GeomAPI_Shape> theSourceShape,
static std::shared_ptr<GeomAPI_Shape> makeCylinder(double theRadius, double theHeight,
double theAngle) throw (GeomAlgoAPI_Exception);
+ /// Creates a sphere using a center and a radius.
+ /// \param theCenterPoint The center of the sphere
+ /// \param theRadius The radius of the sphere
+ static std::shared_ptr<GeomAPI_Shape> makeSphere(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
+ double theRadius) throw (GeomAlgoAPI_Exception);
+
+ /// Creates a sphere using the origin and a radius.
+ /// \param theRadius The radius of the sphere
+ static std::shared_ptr<GeomAPI_Shape> makeSphere(double theRadius)
+ throw (GeomAlgoAPI_Exception);
+
+ /// Creates a torus using a base point, an axis, a radius and a ring radius.
+ /// \param theBasePoint The center of the torus
+ /// \param theEdge The axis of the torus
+ /// \param theRadius The radius of the torus
+ /// \param theRingRadius The ring radius of the torus
+ static std::shared_ptr<GeomAPI_Shape> makeTorus(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+ std::shared_ptr<GeomAPI_Edge> theEdge, double theRadius, double theRingRadius)
+ throw (GeomAlgoAPI_Exception);
+
+ /// Creates a torus using a radius and a ring radius.
+ /// \param theRadius The radius of the torus
+ /// \param theRingRadius The ring radius of the torus
+ static std::shared_ptr<GeomAPI_Shape> makeTorus(double theRadius, double theRingRadius)
+ throw (GeomAlgoAPI_Exception);
+
+ /// Creates a cone using a base point, an axis, a base radius, a top radius and a height.
+ /// \param theBasePoint The center of the lower base of the cone
+ /// \param theEdge The axis of the cone
+ /// \param theBaseRadius The base radius of the cone
+ /// \param theTopRadius The top radius of the cone
+ /// \param theHeight The height of the cone
+ static std::shared_ptr<GeomAPI_Shape> makeCone(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+ std::shared_ptr<GeomAPI_Edge> theEdge, double theBaseRadius,
+ double theTopRadius, double theHeight) throw (GeomAlgoAPI_Exception);
+
+ /// Creates a cone using a base radius, a top radius and a height.
+ /// \param theBaseRadius The base radius of the cone
+ /// \param theTopRadius The top radius of the cone
+ /// \param theHeight The height of the cone
+ static std::shared_ptr<GeomAPI_Shape> makeCone(double theBaseRadius, double theTopRadius,
+ double theHeight) throw (GeomAlgoAPI_Exception);
+
/// Performs a translation from an axis and a distance.
/// \param theSourceShape Shape to be moved
/// \param theAxis Movement axis
#include "GeomAlgoAPI_SketchBuilder.h"
+#include <GeomAPI_Ax1.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Dir.h>
#include <GeomAPI_Face.h>
#include <Geom2d_Curve.hxx>
#include <BRepLib_CheckCurveOnSurface.hxx>
#include <BRep_Tool.hxx>
+#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomLib_IsPlanarSurface.hxx>
#include <GeomLib_Tool.hxx>
#include <gp_Pln.hxx>
return aResultShape;
}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Dir> GeomAlgoAPI_ShapeTools::buildDirFromAxisAndShape(
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+ const std::shared_ptr<GeomAPI_Ax1> theAxis)
+{
+ gp_Pnt aCentreOfMassPoint =
+ GeomAlgoAPI_ShapeTools::centreOfMass(theBaseShape)->impl<gp_Pnt>();
+ Handle(Geom_Line) aLine = new Geom_Line(theAxis->impl<gp_Ax1>());
+ GeomAPI_ProjectPointOnCurve aPrjTool(aCentreOfMassPoint, aLine);
+ gp_Pnt aPoint = aPrjTool.NearestPoint();
+
+ std::shared_ptr<GeomAPI_Dir> aDir(new GeomAPI_Dir(aCentreOfMassPoint.X()-aPoint.X(),
+ aCentreOfMassPoint.Y()-aPoint.Y(),
+ aCentreOfMassPoint.Z()-aPoint.Z()));
+ return aDir;
+}
\ No newline at end of file
#include <map>
#include <set>
+class GeomAPI_Ax1;
class GeomAPI_Edge;
class GeomAPI_Dir;
class GeomAPI_Face;
const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints,
const std::set<std::shared_ptr<GeomAPI_Shape> >& theShapes);
+ /// \brief Returns a dir from a shape and an axis.
+ /// \param[in] theBaseShape shape whose center of mass serves as the starting point of the dir.
+ /// \param[in] theAxis axis that serves as a direction for the dir
+ /// \return dir that builds from center of mass of the base shape and the axis
+ GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Dir> buildDirFromAxisAndShape(
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+ const std::shared_ptr<GeomAPI_Ax1> theAxis);
};
#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_Sphere.h
+// Created: 16 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#include <GeomAlgoAPI_Sphere.h>
+
+#include <BRepPrimAPI_MakeSphere.hxx>
+
+//=================================================================================================
+GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere()
+{
+}
+
+//=================================================================================================
+GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
+ const double theRadius)
+{
+ myCenterPoint = theCenterPoint;
+ myRadius = theRadius;
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_Sphere::check()
+{
+ if (!myCenterPoint) {
+ myError = "Sphere builder :: center is not valid.";
+ return false;
+ }
+ if (myRadius < Precision::Confusion()) {
+ myError = "Sphere builder :: radius is negative or null.";
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_Sphere::build()
+{
+ myCreatedFaces.clear();
+
+ const gp_Pnt& aCenterPoint = myCenterPoint->impl<gp_Pnt>();
+
+ // Construct the sphere
+ BRepPrimAPI_MakeSphere *aSphereMaker = new BRepPrimAPI_MakeSphere(aCenterPoint, myRadius);
+
+ aSphereMaker->Build();
+
+ if (!aSphereMaker->IsDone()) {
+ return;
+ }
+
+ TopoDS_Shape aResult = aSphereMaker->Shape();
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aResult));
+ setShape(aShape);
+
+ // Test on the shapes
+ if (!aShape.get() || aShape->isNull()) {
+ myError = "Sphere builder :: resulting shape is null.";
+ return;
+ }
+
+ setImpl(aSphereMaker);
+
+ setDone(true);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_Sphere.h
+// Created: 16 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#ifndef GEOMALGOAPI_SPHERE_H_
+#define GEOMALGOAPI_SPHERE_H_
+
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Pnt.h>
+
+/**\class GeomAlgoAPI_Sphere
+ * \ingroup DataAlgo
+ * \brief Allows to create Sphere Primitives
+ */
+class GeomAlgoAPI_Sphere : public GeomAlgoAPI_MakeShape
+{
+ public:
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Sphere();
+
+ /// Creates a sphere.
+ /// \param theCenterPoint The center point of the sphere
+ /// \param theRadius The radius of the sphere
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Sphere(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
+ const double theRadius);
+
+ /// Checks if data for the sphere construction is OK.
+ GEOMALGOAPI_EXPORT bool check();
+
+ /// Builds the sphere.
+ GEOMALGOAPI_EXPORT void build();
+
+ private:
+ std::shared_ptr<GeomAPI_Pnt> myCenterPoint; /// Center of the sphere.
+ double myRadius;
+};
+
+#endif // GEOMALGOAPI_SPHERE_H_
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_Torus.cpp
+// Created: 20 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#include <GeomAlgoAPI_Torus.h>
+
+#include <gp_Ax2.hxx>
+
+#include <BRepPrimAPI_MakeTorus.hxx>
+
+//=================================================================================================
+GeomAlgoAPI_Torus::GeomAlgoAPI_Torus()
+{
+}
+
+//=================================================================================================
+GeomAlgoAPI_Torus::GeomAlgoAPI_Torus(std::shared_ptr<GeomAPI_Ax2> theAxis,
+ const double theRadius,
+ const double theRingRadius)
+{
+ myAxis = theAxis;
+ myRadius = theRadius;
+ myRingRadius = theRingRadius;
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_Torus::check()
+{
+ if (!myAxis) {
+ myError = "Torus builder :: axis is not valid.";
+ return false;
+ } else if (myRadius < Precision::Confusion()) {
+ myError = "Torus builder :: radius is negative or null.";
+ return false;
+ } else if (myRingRadius < Precision::Confusion()) {
+ myError = "Torus builder :: ring radius is negative or null.";
+ return false;
+ } else if (myRadius < myRingRadius) {
+ myError = "Torus builder :: ring radius is greater than the radius.";
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_Torus::build()
+{
+ myCreatedFaces.clear();
+
+ const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
+
+ // Construct the torus
+ BRepPrimAPI_MakeTorus *aTorusMaker =
+ new BRepPrimAPI_MakeTorus(anAxis, myRadius, myRingRadius);
+
+ aTorusMaker->Build();
+
+ if (!aTorusMaker->IsDone()) {
+ return;
+ }
+
+ TopoDS_Shape aResult = aTorusMaker->Shape();
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aResult));
+ setShape(aShape);
+
+ // Test on the shapes
+ if (!aShape.get() || aShape->isNull()) {
+ myError = "Torus builder :: resulting shape is null.";
+ return;
+ }
+
+ setImpl(aTorusMaker);
+
+ setDone(true);
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_Torus.h
+// Created: 20 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#ifndef GEOMALGOAPI_TORUS_H_
+#define GEOMALGOAPI_TORUS_H_
+
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Ax2.h>
+
+/**\class GeomAlgoAPI_Torus
+ * \ingroup DataAlgo
+ * \brief Allows to create Torus Primitives
+ */
+class GeomAlgoAPI_Torus : public GeomAlgoAPI_MakeShape
+{
+ public:
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Torus();
+
+ /// Creates a torus.
+ /// \param theAxis The axis of the torus
+ /// \param theRadius The radius of the torus
+ /// \param theRingRadius The ring radius of the torus
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Torus(std::shared_ptr<GeomAPI_Ax2> theAxis,
+ const double theRadius,
+ const double theRingRadius);
+
+ /// Checks if data for the torus construction is OK.
+ GEOMALGOAPI_EXPORT bool check();
+
+ /// Builds the torus.
+ GEOMALGOAPI_EXPORT void build();
+
+ private:
+ std::shared_ptr<GeomAPI_Ax2> myAxis; /// Axis of the torus.
+ double myRadius; /// Radius of the torus.
+ double myRingRadius; /// Ring radius of the torus.
+};
+
+#endif // GEOMALGOAPI_TORUS_H_
\ No newline at end of file
SET(PROJECT_HEADERS
PrimitivesAPI.h
PrimitivesAPI_Box.h
+ PrimitivesAPI_Cone.h
PrimitivesAPI_Cylinder.h
+ PrimitivesAPI_Sphere.h
+ PrimitivesAPI_Torus.h
)
SET(PROJECT_SOURCES
PrimitivesAPI_Box.cpp
+ PrimitivesAPI_Cone.cpp
PrimitivesAPI_Cylinder.cpp
+ PrimitivesAPI_Sphere.cpp
+ PrimitivesAPI_Torus.cpp
)
SET(PROJECT_LIBRARIES
// shared pointers
%shared_ptr(PrimitivesAPI_Box)
+%shared_ptr(PrimitivesAPI_Cone)
%shared_ptr(PrimitivesAPI_Cylinder)
+%shared_ptr(PrimitivesAPI_Sphere)
+%shared_ptr(PrimitivesAPI_Torus)
// all supported interfaces
%include "PrimitivesAPI_Box.h"
+%include "PrimitivesAPI_Cone.h"
%include "PrimitivesAPI_Cylinder.h"
+%include "PrimitivesAPI_Sphere.h"
+%include "PrimitivesAPI_Torus.h"
--- /dev/null
+// 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 <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& 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<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& theBasePoint,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theBaseRadius,
+ const ModelHighAPI_Double& theTopRadius,
+ const ModelHighAPI_Double& theHeight)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID());
+ return ConePtr(new PrimitivesAPI_Cone(aFeature, theBasePoint, theAxis, theBaseRadius,
+ theTopRadius, theHeight));
+}
+
+//==================================================================================================
+ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& 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<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID());
+ return ConePtr(new PrimitivesAPI_Cone(aFeature, aBasePoint, anAxis, theBaseRadius,
+ theTopRadius, theHeight));
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File: PrimitivesAPI_Cone.h
+// Created: 20 Mar 2017
+// Author: Clarisse Genrault
+
+#ifndef PRIMITIVESAPI_CONE_H_
+#define PRIMITIVESAPI_CONE_H_
+
+#include "PrimitivesAPI.h"
+
+#include <PrimitivesPlugin_Cone.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class PrimitivesAPI_Cone
+/// \ingroup CPPHighAPI
+/// \brief Interface for primitive Cone feature.
+class PrimitivesAPI_Cone: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theBasePoint,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theBaseRadius,
+ const ModelHighAPI_Double& theTopRadius,
+ const ModelHighAPI_Double& theHeight);
+
+ /// Destructor.
+ PRIMITIVESAPI_EXPORT
+ virtual ~PrimitivesAPI_Cone();
+
+ INTERFACE_5(PrimitivesPlugin_Cone::ID(),
+ basePoint, PrimitivesPlugin_Cone::BASE_POINT_ID(),
+ ModelAPI_AttributeSelection, /** Base point */,
+ axis, PrimitivesPlugin_Cone::AXIS_ID(),
+ ModelAPI_AttributeSelection, /** Axis */,
+ baseRadius, PrimitivesPlugin_Cone::BASE_RADIUS_ID(),
+ ModelAPI_AttributeDouble, /** Base radius */,
+ topRadius, PrimitivesPlugin_Cone::TOP_RADIUS_ID(),
+ ModelAPI_AttributeDouble, /** Top radius */,
+ height, PrimitivesPlugin_Cone::HEIGHT_ID(),
+ ModelAPI_AttributeDouble, /** Height */)
+
+ /// Set radius
+ PRIMITIVESAPI_EXPORT
+ void setRadius(const ModelHighAPI_Double& theBaseRadius,
+ const ModelHighAPI_Double& theTopRadius);
+
+ /// Set height
+ PRIMITIVESAPI_EXPORT
+ void setHeight(const ModelHighAPI_Double& theHeight);
+
+ /// Dump wrapped feature
+ PRIMITIVESAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on primitive Cone object
+typedef std::shared_ptr<PrimitivesAPI_Cone> ConePtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Cone feature.
+PRIMITIVESAPI_EXPORT
+ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& theBasePoint,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theBaseRadius,
+ const ModelHighAPI_Double& theTopRadius,
+ const ModelHighAPI_Double& theHeight);
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Cone feature.
+PRIMITIVESAPI_EXPORT
+ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theBaseRadius,
+ const ModelHighAPI_Double& theTopRadius,
+ const ModelHighAPI_Double& theHeight);
+
+#endif // PRIMITIVESAPI_CONE_H_
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
-#include <iostream>
-
//==================================================================================================
PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature)
: ModelHighAPI_Interface(theFeature)
//==================================================================================================
PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const ModelHighAPI_Selection& theBasePoint,
- const ModelHighAPI_Selection& theAxis,
- const ModelHighAPI_Double& theRadius,
- const ModelHighAPI_Double& theHeight)
+ const ModelHighAPI_Selection& theBasePoint,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theHeight)
: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
//==================================================================================================
PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const ModelHighAPI_Selection& theBasePoint,
- const ModelHighAPI_Selection& theAxis,
- const ModelHighAPI_Double& theRadius,
- const ModelHighAPI_Double& theHeight,
- const ModelHighAPI_Double& theAngle)
+ const ModelHighAPI_Selection& theBasePoint,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theHeight,
+ const ModelHighAPI_Double& theAngle)
: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
class ModelHighAPI_Double;
class ModelHighAPI_Selection;
-/// \class PrimitivesAPI_Box
+/// \class PrimitivesAPI_Cylinder
/// \ingroup CPPHighAPI
-/// \brief Interface for primitive Box feature.
+/// \brief Interface for primitive Cylinder feature.
class PrimitivesAPI_Cylinder: public ModelHighAPI_Interface
{
public:
PRIMITIVESAPI_EXPORT
explicit PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature);
- /// Constructor with values.
- /*PRIMITIVESAPI_EXPORT
- explicit PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const ModelHighAPI_Double& theDx,
- const ModelHighAPI_Double& theDy,
- const ModelHighAPI_Double& theDz);*/
-
/// Constructor with values.
PRIMITIVESAPI_EXPORT
explicit PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
creationMethod, PrimitivesPlugin_Cylinder::CREATION_METHOD(),
ModelAPI_AttributeString, /** Creation method */,
basePoint, PrimitivesPlugin_Cylinder::BASE_POINT_ID(),
- ModelAPI_AttributeSelection, /** Dimension in X */,
+ ModelAPI_AttributeSelection, /** Base point */,
axis, PrimitivesPlugin_Cylinder::AXIS_ID(),
- ModelAPI_AttributeSelection, /** Dimension in Y */,
+ ModelAPI_AttributeSelection, /** Axis */,
radius, PrimitivesPlugin_Cylinder::RADIUS_ID(),
- ModelAPI_AttributeDouble, /** Dimension in Z */,
+ ModelAPI_AttributeDouble, /** Radius */,
height, PrimitivesPlugin_Cylinder::HEIGHT_ID(),
- ModelAPI_AttributeDouble, /** First point */,
+ ModelAPI_AttributeDouble, /** Height */,
angle, PrimitivesPlugin_Cylinder::ANGLE_ID(),
- ModelAPI_AttributeDouble, /** Second point */)
+ ModelAPI_AttributeDouble, /** Angle */)
/// Set dimensions
PRIMITIVESAPI_EXPORT
virtual void dump(ModelHighAPI_Dumper& theDumper) const;
};
-/// Pointer on primitive Box object
+/// Pointer on primitive Cylinder object
typedef std::shared_ptr<PrimitivesAPI_Cylinder> CylinderPtr;
/// \ingroup CPPHighAPI
-/// \brief Create primitive Box feature.
+/// \brief Create primitive Cylinder feature.
PRIMITIVESAPI_EXPORT
CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Selection& theBasePoint,
const ModelHighAPI_Double& theHeight);
/// \ingroup CPPHighAPI
-/// \brief Create primitive Box feature.
+/// \brief Create primitive Cylinder feature.
PRIMITIVESAPI_EXPORT
CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Selection& theBasePoint,
const ModelHighAPI_Double& theAngle);
/// \ingroup CPPHighAPI
-/// \brief Create primitive Box feature.
+/// \brief Create primitive Cylinder feature.
PRIMITIVESAPI_EXPORT
CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Double& theRadius,
const ModelHighAPI_Double& theHeight);
/// \ingroup CPPHighAPI
-/// \brief Create primitive Box feature.
+/// \brief Create primitive Cylinder feature.
PRIMITIVESAPI_EXPORT
CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Double& theRadius,
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File: PrimitivesAPI_Sphere.h
+// Created: 16 Mar 2017
+// Author: Clarisse Genrault
+
+#include "PrimitivesAPI_Sphere.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theCenterPoint,
+ const ModelHighAPI_Double& theRadius)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ fillAttribute(theCenterPoint, centerPoint());
+ setRadius(theRadius);
+ }
+}
+
+//==================================================================================================
+PrimitivesAPI_Sphere::~PrimitivesAPI_Sphere()
+{
+}
+
+//==================================================================================================
+void PrimitivesAPI_Sphere::setCenterPoint(const ModelHighAPI_Selection& theCenterPoint)
+{
+ fillAttribute(theCenterPoint, centerPoint());
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRadius)
+{
+ fillAttribute(theRadius, radius());
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ theDumper << aBase << " = model.addSphere(" << aDocName;
+
+ AttributeSelectionPtr anAttrCenterPoint =
+ aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID());
+ AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID());
+ theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius;
+
+ theDumper << ")" << std::endl;
+}
+
+//==================================================================================================
+SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& theCenterPoint,
+ const ModelHighAPI_Double& theRadius)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
+ return SpherePtr(new PrimitivesAPI_Sphere(aFeature, theCenterPoint, theRadius));
+}
+
+//==================================================================================================
+SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theRadius)
+{
+ ModelHighAPI_Selection aCenterPoint("VERTEX", "PartSet/Origin");
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
+ return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius));
+}
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File: PrimitivesAPI_Sphere.h
+// Created: 16 Mar 2017
+// Author: Clarisse Genrault
+
+#ifndef PRIMITIVESAPI_SPHERE_H_
+#define PRIMITIVESAPI_SPHERE_H_
+
+#include "PrimitivesAPI.h"
+
+#include <PrimitivesPlugin_Sphere.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class PrimitivesAPI_Sphere
+/// \ingroup CPPHighAPI
+/// \brief Interface for primitive Sphere feature.
+class PrimitivesAPI_Sphere: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theCenterPoint,
+ const ModelHighAPI_Double& theRadius);
+
+ /// Destructor.
+ PRIMITIVESAPI_EXPORT
+ virtual ~PrimitivesAPI_Sphere();
+
+ INTERFACE_2(PrimitivesPlugin_Sphere::ID(),
+ centerPoint, PrimitivesPlugin_Sphere::CENTER_POINT_ID(),
+ ModelAPI_AttributeSelection, /** Center point */,
+ radius, PrimitivesPlugin_Sphere::RADIUS_ID(),
+ ModelAPI_AttributeDouble, /** Radius */)
+
+ /// Set center point
+ PRIMITIVESAPI_EXPORT
+ void setCenterPoint(const ModelHighAPI_Selection& theCenterPoint);
+
+ /// Set radius
+ PRIMITIVESAPI_EXPORT
+ void setRadius(const ModelHighAPI_Double& theRadius);
+
+ /// Dump wrapped feature
+ PRIMITIVESAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on primitive Sphere object
+typedef std::shared_ptr<PrimitivesAPI_Sphere> SpherePtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Sphere feature.
+PRIMITIVESAPI_EXPORT
+SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& theCenterPoint,
+ const ModelHighAPI_Double& theRadius);
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Sphere feature.
+PRIMITIVESAPI_EXPORT
+SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theRadius);
+
+#endif // PRIMITIVESAPI_SPHERE_H_
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File: PrimitivesAPI_Torus.cpp
+// Created: 20 Mar 2017
+// Author: Clarisse Genrault
+
+#include "PrimitivesAPI_Torus.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+PrimitivesAPI_Torus::PrimitivesAPI_Torus(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+PrimitivesAPI_Torus::PrimitivesAPI_Torus(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theBasePoint,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theRingRadius)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ fillAttribute(theBasePoint, basePoint());
+ fillAttribute(theAxis, axis());
+ setRadius(theRadius, theRingRadius);
+ }
+}
+
+//==================================================================================================
+PrimitivesAPI_Torus::~PrimitivesAPI_Torus()
+{
+}
+
+//==================================================================================================
+void PrimitivesAPI_Torus::setRadius(const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theRingRadius)
+{
+ fillAttribute(theRadius, radius());
+ fillAttribute(theRingRadius, ringRadius());
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Torus::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ theDumper << aBase << " = model.addTorus(" << aDocName;
+
+ AttributeSelectionPtr anAttrBasePoint =
+ aBase->selection(PrimitivesPlugin_Torus::BASE_POINT_ID());
+ AttributeSelectionPtr anAttrAxis =
+ aBase->selection(PrimitivesPlugin_Torus::AXIS_ID());
+ theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
+
+ AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Torus::RADIUS_ID());
+ AttributeDoublePtr anAttrRingRadius = aBase->real(PrimitivesPlugin_Torus::RING_RADIUS_ID());
+ theDumper << ", " << anAttrRadius << ", " << anAttrRingRadius;
+
+ theDumper << ")" << std::endl;
+}
+
+//==================================================================================================
+TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& theBasePoint,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theRingRadius)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Torus::ID());
+ return TorusPtr(new PrimitivesAPI_Torus(aFeature, theBasePoint, theAxis,
+ theRadius, theRingRadius));
+}
+
+//==================================================================================================
+TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theRingRadius)
+{
+ ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin");
+ ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ");
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Torus::ID());
+ return TorusPtr(new PrimitivesAPI_Torus(aFeature, aBasePoint, anAxis, theRadius, theRingRadius));
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File: PrimitivesAPI_Torus.h
+// Created: 20 Mar 2017
+// Author: Clarisse Genrault
+
+#ifndef PRIMITIVESAPI_TORUS_H_
+#define PRIMITIVESAPI_TORUS_H_
+
+#include "PrimitivesAPI.h"
+
+#include <PrimitivesPlugin_Torus.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class PrimitivesAPI_Torus
+/// \ingroup CPPHighAPI
+/// \brief Interface for primitive Cone feature.
+class PrimitivesAPI_Torus: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Torus(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Torus(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theBasePoint,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theRingRadius);
+
+ /// Destructor.
+ PRIMITIVESAPI_EXPORT
+ virtual ~PrimitivesAPI_Torus();
+
+ INTERFACE_4(PrimitivesPlugin_Torus::ID(),
+ basePoint, PrimitivesPlugin_Torus::BASE_POINT_ID(),
+ ModelAPI_AttributeSelection, /** Base point */,
+ axis, PrimitivesPlugin_Torus::AXIS_ID(),
+ ModelAPI_AttributeSelection, /** Axis */,
+ radius, PrimitivesPlugin_Torus::RADIUS_ID(),
+ ModelAPI_AttributeDouble, /** Radius */,
+ ringRadius, PrimitivesPlugin_Torus::RING_RADIUS_ID(),
+ ModelAPI_AttributeDouble, /** Ring radius */)
+
+ /// Set radius
+ PRIMITIVESAPI_EXPORT
+ void setRadius(const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theRingRadius);
+
+ /// Dump wrapped feature
+ PRIMITIVESAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on primitive Cone object
+typedef std::shared_ptr<PrimitivesAPI_Torus> TorusPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Cone feature.
+PRIMITIVESAPI_EXPORT
+TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& theBasePoint,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theRingRadius);
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Cone feature.
+PRIMITIVESAPI_EXPORT
+TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theRadius,
+ const ModelHighAPI_Double& theRingRadius);
+
+#endif // PRIMITIVESAPI_TORUS_H_
#include "PrimitivesAPI.h"
#include "PrimitivesAPI_Box.h"
+ #include "PrimitivesAPI_Cone.h"
#include "PrimitivesAPI_Cylinder.h"
+ #include "PrimitivesAPI_Sphere.h"
+ #include "PrimitivesAPI_Torus.h"
#endif // PRIMITIVESAPI_SWIG_H_
PrimitivesPlugin.h
PrimitivesPlugin_Plugin.h
PrimitivesPlugin_Box.h
+ PrimitivesPlugin_Cone.h
PrimitivesPlugin_Cylinder.h
+ PrimitivesPlugin_Sphere.h
+ PrimitivesPlugin_Torus.h
)
SET(PROJECT_SOURCES
PrimitivesPlugin_Plugin.cpp
PrimitivesPlugin_Box.cpp
+ PrimitivesPlugin_Cone.cpp
PrimitivesPlugin_Cylinder.cpp
+ PrimitivesPlugin_Sphere.cpp
+ PrimitivesPlugin_Torus.cpp
)
SET(XML_RESOURCES
plugin-Primitives.xml
box_widget.xml
+ cone_widget.xml
cylinder_widget.xml
+ sphere_widget.xml
+ torus_widget.xml
)
INCLUDE_DIRECTORIES(
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File: PrimitivesPlugin_Cone.cpp
+// Created: 17 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#include <PrimitivesPlugin_Cone.h>
+
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
+
+#include <GeomAlgoAPI_PointBuilder.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Session.h>
+
+//=================================================================================================
+PrimitivesPlugin_Cone::PrimitivesPlugin_Cone()
+{
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Cone::initAttributes()
+{
+ data()->addAttribute(PrimitivesPlugin_Cone::BASE_POINT_ID(),
+ ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(PrimitivesPlugin_Cone::AXIS_ID(),
+ ModelAPI_AttributeSelection::typeId());
+
+ data()->addAttribute(PrimitivesPlugin_Cone::BASE_RADIUS_ID(),
+ ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Cone::TOP_RADIUS_ID(),
+ ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Cone::HEIGHT_ID(),
+ ModelAPI_AttributeDouble::typeId());
+
+ // Initialize the base point of the cone at the origin if the base point is not filled.
+ AttributeSelectionPtr aCenterPoint =
+ data()->selection(PrimitivesPlugin_Cone::BASE_POINT_ID());
+ if (!aCenterPoint->isInitialized()) {
+ ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument()
+ ->objectByName(ModelAPI_ResultConstruction::group(), "Origin");
+ if (aPointObj.get()) {
+ ResultPtr aPointRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPointObj);
+ aCenterPoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
+ }
+ }
+
+ // Initialize the axis at the OZ axis if the axis is not filled.
+ AttributeSelectionPtr anAxis = data()->selection(PrimitivesPlugin_Cone::AXIS_ID());
+ if (!anAxis->isInitialized()) {
+ ObjectPtr anAxisObj = ModelAPI_Session::get()->moduleDocument()
+ ->objectByName(ModelAPI_ResultConstruction::group(), "OZ");
+ if (anAxisObj.get()) {
+ ResultPtr anAxisRes = std::dynamic_pointer_cast<ModelAPI_Result>(anAxisObj);
+ anAxis->setValue(anAxisRes, std::shared_ptr<GeomAPI_Shape>());
+ }
+ }
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Cone::execute()
+{
+ // Getting base point.
+ std::shared_ptr<GeomAPI_Pnt> aBasePoint;
+ std::shared_ptr<ModelAPI_AttributeSelection> aPointRef =
+ selection(PrimitivesPlugin_Cone::BASE_POINT_ID());
+ if (aPointRef.get() != NULL) {
+ GeomShapePtr aShape1 = aPointRef->value();
+ if (!aShape1.get()) {
+ aShape1 = aPointRef->context()->shape();
+ }
+ if (aShape1) {
+ aBasePoint = GeomAlgoAPI_PointBuilder::point(aShape1);
+ }
+ }
+
+ // Getting axis.
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ std::shared_ptr<GeomAPI_Edge> anEdge;
+ std::shared_ptr<ModelAPI_AttributeSelection> anEdgeRef =
+ selection(PrimitivesPlugin_Cone::AXIS_ID());
+ if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->value()));
+ } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() &&
+ anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->context()->shape()));
+ }
+ if(anEdge) {
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
+ anEdge->line()->direction()));
+ }
+
+ // Getting base radius, top radius and height
+ double aBaseRadius = real(PrimitivesPlugin_Cone::BASE_RADIUS_ID())->value();
+ double aTopRadius = real(PrimitivesPlugin_Cone::TOP_RADIUS_ID())->value();
+ double aHeight = real(PrimitivesPlugin_Cone::HEIGHT_ID())->value();
+
+ std::shared_ptr<GeomAlgoAPI_Cone> aConeAlgo =
+ std::shared_ptr<GeomAlgoAPI_Cone>(new GeomAlgoAPI_Cone(anAxis,
+ aBaseRadius,
+ aTopRadius,
+ aHeight));
+
+ // These checks should be made to the GUI for the feature but
+ // the corresponding validator does not exist yet.
+ if (!aConeAlgo->check()) {
+ setError(aConeAlgo->getError());
+ return;
+ }
+
+ // Build the sphere
+ aConeAlgo->build();
+
+ // Check if the creation of the cylinder
+ if(!aConeAlgo->isDone()) {
+ setError(aConeAlgo->getError());
+ return;
+ }
+ if(!aConeAlgo->checkValid("Cone builder")) {
+ setError(aConeAlgo->getError());
+ return;
+ }
+
+ int aResultIndex = 0;
+ ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
+ loadNamingDS(aConeAlgo, aResultBox);
+ setResult(aResultBox, aResultIndex);
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Cone::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Cone> theConeAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultCone)
+{
+ // Load the result
+ theResultCone->store(theConeAlgo->shape());
+
+ // Prepare the naming
+ theConeAlgo->prepareNamingFaces();
+
+ // Insert to faces
+ int num = 1;
+ std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
+ theConeAlgo->getCreatedFaces();
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
+ it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
+ std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
+ theResultCone->generated(aFace, (*it).first, num++);
+ }
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File: PrimitivesPlugin_Cone.h
+// Created: 17 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#ifndef PRIMITIVESPLUGIN_CONE_H_
+#define PRIMITIVESPLUGIN_CONE_H_
+
+#include <PrimitivesPlugin.h>
+#include <ModelAPI_Feature.h>
+#include <GeomAlgoAPI_Cone.h>
+
+/**\class PrimitivesPlugin_Cone
+ * \ingroup Plugins
+ * \brief Feature for creation of a cone.
+ *
+ * Creates a cone from a
+ */
+class PrimitivesPlugin_Cone : public ModelAPI_Feature
+{
+ public:
+ /// Cone kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_CONE_ID("Cone");
+ return MY_CONE_ID;
+ }
+
+ /// Attribute name of the base point
+ inline static const std::string& BASE_POINT_ID()
+ {
+ static const std::string MY_BASE_POINT_ID("base_point");
+ return MY_BASE_POINT_ID;
+ }
+
+ /// Attribute name of the axis
+ inline static const std::string& AXIS_ID()
+ {
+ static const std::string MY_AXIS_ID("axis");
+ return MY_AXIS_ID;
+ }
+
+ /// Attribute name of the base radius
+ inline static const std::string& BASE_RADIUS_ID()
+ {
+ static const std::string MY_BASE_RADIUS_ID("base_radius");
+ return MY_BASE_RADIUS_ID;
+ }
+
+ /// Attribute name of the radius
+ inline static const std::string& TOP_RADIUS_ID()
+ {
+ static const std::string MY_TOP_RADIUS_ID("top_radius");
+ return MY_TOP_RADIUS_ID;
+ }
+
+ /// Attribute name of the radius
+ inline static const std::string& HEIGHT_ID()
+ {
+ static const std::string MY_HEIGHT_ID("height");
+ return MY_HEIGHT_ID;
+ }
+
+ /// Returns the kind of a feature
+ PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = PrimitivesPlugin_Cone::ID();
+ return MY_KIND;
+ }
+
+ /// Creates a new part document if needed
+ PRIMITIVESPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ PRIMITIVESPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Use plugin manager for features creation
+ PrimitivesPlugin_Cone();
+
+ private:
+ /// Load Naming data structure of the feature to the document
+ void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Cone> theConeAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultCone);
+
+};
+
+#endif // PRIMITIVESPLUGIN_CONE_H_
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Session.h>
-#include <iostream>
-
//=================================================================================================
PrimitivesPlugin_Cylinder::PrimitivesPlugin_Cylinder()
{
#include <PrimitivesPlugin_Plugin.h>
#include <PrimitivesPlugin_Box.h>
+#include <PrimitivesPlugin_Cone.h>
#include <PrimitivesPlugin_Cylinder.h>
+#include <PrimitivesPlugin_Sphere.h>
+#include <PrimitivesPlugin_Torus.h>
+
#include <ModelAPI_Session.h>
#include <string>
{
if (theFeatureID == PrimitivesPlugin_Box::ID()) {
return FeaturePtr(new PrimitivesPlugin_Box);
+ } else if (theFeatureID == PrimitivesPlugin_Cone::ID()) {
+ return FeaturePtr(new PrimitivesPlugin_Cone);
} else if (theFeatureID == PrimitivesPlugin_Cylinder::ID()) {
return FeaturePtr(new PrimitivesPlugin_Cylinder);
+ } else if (theFeatureID == PrimitivesPlugin_Sphere::ID()) {
+ return FeaturePtr(new PrimitivesPlugin_Sphere);
+ } else if (theFeatureID == PrimitivesPlugin_Torus::ID()) {
+ return FeaturePtr(new PrimitivesPlugin_Torus);
}
// feature of such kind is not found
return FeaturePtr();
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File: PrimitivesPlugin_Sphere.h
+// Created: 15 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#include <PrimitivesPlugin_Sphere.h>
+
+#include <GeomAlgoAPI_PointBuilder.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Session.h>
+
+//=================================================================================================
+PrimitivesPlugin_Sphere::PrimitivesPlugin_Sphere()
+{
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Sphere::initAttributes()
+{
+ data()->addAttribute(PrimitivesPlugin_Sphere::CENTER_POINT_ID(),
+ ModelAPI_AttributeSelection::typeId());
+
+ data()->addAttribute(PrimitivesPlugin_Sphere::RADIUS_ID(),
+ ModelAPI_AttributeDouble::typeId());
+
+ // Initialize the center point of the sphere at the origin if the center point is not filled.
+ AttributeSelectionPtr aCenterPoint =
+ data()->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID());
+ if (!aCenterPoint->isInitialized()) {
+ ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument()
+ ->objectByName(ModelAPI_ResultConstruction::group(), "Origin");
+ if (aPointObj.get()) {
+ ResultPtr aPointRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPointObj);
+ aCenterPoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
+ }
+ }
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Sphere::execute()
+{
+ // Getting point.
+ std::shared_ptr<GeomAPI_Pnt> aCenterPoint;
+ std::shared_ptr<ModelAPI_AttributeSelection> aPointRef =
+ selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID());
+ if (aPointRef.get() != NULL) {
+ GeomShapePtr aShape1 = aPointRef->value();
+ if (!aShape1.get()) {
+ aShape1 = aPointRef->context()->shape();
+ }
+ if (aShape1) {
+ aCenterPoint = GeomAlgoAPI_PointBuilder::point(aShape1);
+ }
+ }
+
+ // Getting radius
+ double aRadius = real(PrimitivesPlugin_Sphere::RADIUS_ID())->value();
+
+ std::shared_ptr<GeomAlgoAPI_Sphere> aSphereAlgo =
+ std::shared_ptr<GeomAlgoAPI_Sphere>(new GeomAlgoAPI_Sphere(aCenterPoint, aRadius));
+
+ // These checks should be made to the GUI for the feature but
+ // the corresponding validator does not exist yet.
+ if (!aSphereAlgo->check()) {
+ setError(aSphereAlgo->getError());
+ return;
+ }
+
+ // Build the sphere
+ aSphereAlgo->build();
+
+ // Check if the creation of the cylinder
+ if(!aSphereAlgo->isDone()) {
+ setError(aSphereAlgo->getError());
+ return;
+ }
+ if(!aSphereAlgo->checkValid("Sphere builder")) {
+ setError(aSphereAlgo->getError());
+ return;
+ }
+
+ int aResultIndex = 0;
+ ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
+ loadNamingDS(aSphereAlgo, aResultBox);
+ setResult(aResultBox, aResultIndex);
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Sphere::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Sphere> theSphereAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultSphere)
+{
+ // Load the result
+ theResultSphere->store(theSphereAlgo->shape());
+
+ // Prepare the naming
+ theSphereAlgo->prepareNamingFaces();
+
+ // Insert to faces
+ int num = 1;
+ std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
+ theSphereAlgo->getCreatedFaces();
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
+ it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
+ std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
+ theResultSphere->generated(aFace, (*it).first, num++);
+ }
+}
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File: PrimitivesPlugin_Sphere.h
+// Created: 15 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#ifndef PRIMITIVESPLUGIN_SPHERE_H_
+#define PRIMITIVESPLUGIN_SPHERE_H_
+
+#include <PrimitivesPlugin.h>
+#include <ModelAPI_Feature.h>
+#include <GeomAlgoAPI_Sphere.h>
+
+/**\class PrimitivesPlugin_Sphere
+ * \ingroup Plugins
+ * \brief Feature for creation of a sphere.
+ *
+ * Creates a sphere from a radius and a center point defaulting to the origin
+ */
+class PrimitivesPlugin_Sphere : public ModelAPI_Feature
+{
+ public:
+ /// Sphere kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_SPHERE_ID("Sphere");
+ return MY_SPHERE_ID;
+ }
+
+ /// Attribute name of the base point
+ inline static const std::string& CENTER_POINT_ID()
+ {
+ static const std::string MY_CENTER_POINT_ID("center_point");
+ return MY_CENTER_POINT_ID;
+ }
+
+ /// Attribute name of the radius
+ inline static const std::string& RADIUS_ID()
+ {
+ static const std::string MY_RADIUS_ID("radius");
+ return MY_RADIUS_ID;
+ }
+
+ /// Returns the kind of a feature
+ PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = PrimitivesPlugin_Sphere::ID();
+ return MY_KIND;
+ }
+
+ /// Creates a new part document if needed
+ PRIMITIVESPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ PRIMITIVESPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Use plugin manager for features creation
+ PrimitivesPlugin_Sphere();
+
+ private:
+ /// Load Naming data structure of the feature to the document
+ void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Sphere> theSphereAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultSphere);
+
+};
+
+#endif // PRIMITIVESPLUGIN_SPHERE_H_
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File: PrimitivesPlugin_Torus.cpp
+// Created: 17 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#include <PrimitivesPlugin_Torus.h>
+
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
+
+#include <GeomAlgoAPI_PointBuilder.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Session.h>
+
+//=================================================================================================
+PrimitivesPlugin_Torus::PrimitivesPlugin_Torus()
+{
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Torus::initAttributes()
+{
+ data()->addAttribute(PrimitivesPlugin_Torus::BASE_POINT_ID(),
+ ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(PrimitivesPlugin_Torus::AXIS_ID(),
+ ModelAPI_AttributeSelection::typeId());
+
+ data()->addAttribute(PrimitivesPlugin_Torus::RADIUS_ID(),
+ ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Torus::RING_RADIUS_ID(),
+ ModelAPI_AttributeDouble::typeId());
+
+ // Initialize the base point of the torus at the origin if the base point is not filled.
+ AttributeSelectionPtr aCenterPoint =
+ data()->selection(PrimitivesPlugin_Torus::BASE_POINT_ID());
+ if (!aCenterPoint->isInitialized()) {
+ ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument()
+ ->objectByName(ModelAPI_ResultConstruction::group(), "Origin");
+ if (aPointObj.get()) {
+ ResultPtr aPointRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPointObj);
+ aCenterPoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
+ }
+ }
+
+ // Initialize the axis at the OZ axis if the axis is not filled.
+ AttributeSelectionPtr anAxis = data()->selection(PrimitivesPlugin_Torus::AXIS_ID());
+ if (!anAxis->isInitialized()) {
+ ObjectPtr anAxisObj = ModelAPI_Session::get()->moduleDocument()
+ ->objectByName(ModelAPI_ResultConstruction::group(), "OZ");
+ if (anAxisObj.get()) {
+ ResultPtr anAxisRes = std::dynamic_pointer_cast<ModelAPI_Result>(anAxisObj);
+ anAxis->setValue(anAxisRes, std::shared_ptr<GeomAPI_Shape>());
+ }
+ }
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Torus::execute()
+{
+ // Getting base point.
+ std::shared_ptr<GeomAPI_Pnt> aBasePoint;
+ std::shared_ptr<ModelAPI_AttributeSelection> aPointRef =
+ selection(PrimitivesPlugin_Torus::BASE_POINT_ID());
+ if (aPointRef.get() != NULL) {
+ GeomShapePtr aShape1 = aPointRef->value();
+ if (!aShape1.get()) {
+ aShape1 = aPointRef->context()->shape();
+ }
+ if (aShape1) {
+ aBasePoint = GeomAlgoAPI_PointBuilder::point(aShape1);
+ }
+ }
+
+ // Getting axis.
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ std::shared_ptr<GeomAPI_Edge> anEdge;
+ std::shared_ptr<ModelAPI_AttributeSelection> anEdgeRef =
+ selection(PrimitivesPlugin_Torus::AXIS_ID());
+ if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->value()));
+ } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() &&
+ anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->context()->shape()));
+ }
+ if(anEdge) {
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
+ anEdge->line()->direction()));
+ }
+
+ // Getting radius and ring radius
+ double aRadius = real(PrimitivesPlugin_Torus::RADIUS_ID())->value();
+ double aRingRadius = real(PrimitivesPlugin_Torus::RING_RADIUS_ID())->value();
+
+ std::shared_ptr<GeomAlgoAPI_Torus> aTorusAlgo =
+ std::shared_ptr<GeomAlgoAPI_Torus>(new GeomAlgoAPI_Torus(anAxis,
+ aRadius,
+ aRingRadius));
+
+ // These checks should be made to the GUI for the feature but
+ // the corresponding validator does not exist yet.
+ if (!aTorusAlgo->check()) {
+ setError(aTorusAlgo->getError());
+ return;
+ }
+
+ // Build the sphere
+ aTorusAlgo->build();
+
+ // Check if the creation of the cylinder
+ if(!aTorusAlgo->isDone()) {
+ setError(aTorusAlgo->getError());
+ return;
+ }
+ if(!aTorusAlgo->checkValid("Torus builder")) {
+ setError(aTorusAlgo->getError());
+ return;
+ }
+
+ int aResultIndex = 0;
+ ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
+ loadNamingDS(aTorusAlgo, aResultBox);
+ setResult(aResultBox, aResultIndex);
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Torus::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Torus> theTorusAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultTorus)
+{
+ // Load the result
+ theResultTorus->store(theTorusAlgo->shape());
+
+ // Prepare the naming
+ theTorusAlgo->prepareNamingFaces();
+
+ // Insert to faces
+ int num = 1;
+ std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
+ theTorusAlgo->getCreatedFaces();
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
+ it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
+ std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
+ theResultTorus->generated(aFace, (*it).first, num++);
+ }
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File: PrimitivesPlugin_Torus.h
+// Created: 17 Mar 2017
+// Author: Clarisse Genrault (CEA)
+
+#ifndef PRIMITIVESPLUGIN_TORUS_H_
+#define PRIMITIVESPLUGIN_TORUS_H_
+
+#include <PrimitivesPlugin.h>
+#include <ModelAPI_Feature.h>
+#include <GeomAlgoAPI_Torus.h>
+
+/**\class PrimitivesPlugin_Torus
+ * \ingroup Plugins
+ * \brief Feature for creation of a torus.
+ *
+ * Creates a torus from a
+ */
+class PrimitivesPlugin_Torus : public ModelAPI_Feature
+{
+ public:
+ /// Torus kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_TORUS_ID("Torus");
+ return MY_TORUS_ID;
+ }
+
+ /// Attribute name of the base point
+ inline static const std::string& BASE_POINT_ID()
+ {
+ static const std::string MY_BASE_POINT_ID("base_point");
+ return MY_BASE_POINT_ID;
+ }
+
+ /// Attribute name of the axis
+ inline static const std::string& AXIS_ID()
+ {
+ static const std::string MY_AXIS_ID("axis");
+ return MY_AXIS_ID;
+ }
+
+ /// Attribute name of the radius
+ inline static const std::string& RADIUS_ID()
+ {
+ static const std::string MY_RADIUS_ID("radius");
+ return MY_RADIUS_ID;
+ }
+
+ /// Attribute name of the section radius
+ inline static const std::string& RING_RADIUS_ID()
+ {
+ static const std::string MY_RING_RADIUS_ID("ring_radius");
+ return MY_RING_RADIUS_ID;
+ }
+
+ /// Returns the kind of a feature
+ PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = PrimitivesPlugin_Torus::ID();
+ return MY_KIND;
+ }
+
+ /// Creates a new part document if needed
+ PRIMITIVESPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ PRIMITIVESPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Use plugin manager for features creation
+ PrimitivesPlugin_Torus();
+
+ private:
+ /// Load Naming data structure of the feature to the document
+ void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Torus> theTorusAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultTorus);
+
+};
+
+#endif // PRIMITIVESPLUGIN_TORUS_H_
--- /dev/null
+<!-- Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+<source>
+ <shape_selector
+ id="base_point"
+ label="base_point"
+ default=""
+ shape_types="vertex"
+ icon="icons/Primitives/point.png"
+ tooltip="Select the center of the base of the cone">
+ <validator id="GeomValidators_ConstructionComposite"/>
+ <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+ </shape_selector>
+ <shape_selector
+ id="axis"
+ label="axis"
+ default=""
+ shape_types="edge"
+ icon="icons/Primitives/axis.png"
+ tooltip="Select the axis of the cone">
+ <validator id="GeomValidators_ConstructionComposite"/>
+ <validator id="GeomValidators_ShapeType" parameters="line"/>
+ </shape_selector>
+ <doublevalue
+ id="base_radius"
+ label="Base radius"
+ step="1."
+ default="10."
+ tooltip="Enter the base radius of the cone">
+ </doublevalue>
+ <doublevalue
+ id="top_radius"
+ label="Top radius"
+ step="1."
+ default="5."
+ tooltip="Enter the top radius of the cone">
+ </doublevalue>
+ <doublevalue
+ id="height"
+ label="height"
+ step="1."
+ default="10."
+ icon="icons/Primitives/dimension_v.png"
+ tooltip="Enter the height of the cone">
+ </doublevalue>
+</source>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ id="svg4157"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ viewBox="0 0 16 16"
+ sodipodi:docname="cone.svg"
+ inkscape:export-filename="/export/home/ldigallo/DOC_ALYOTECH/icones/Primitives/cone.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4159" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="44.791208"
+ inkscape:cx="10.619534"
+ inkscape:cy="7.8334642"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ showguides="true"
+ inkscape:snap-others="true"
+ inkscape:snap-nodes="false"
+ inkscape:snap-object-midpoints="false"
+ inkscape:snap-center="true"
+ inkscape:snap-text-baseline="false"
+ inkscape:object-nodes="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:snap-page="false"
+ inkscape:snap-grids="false"
+ inkscape:object-paths="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1006"
+ inkscape:window-x="0"
+ inkscape:window-y="25"
+ inkscape:window-maximized="1"
+ inkscape:showpageshadow="false">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4705" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata4162">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ transform="translate(0,-16)">
+ <g
+ id="g4140"
+ transform="matrix(0.48922312,0,0,0.49910601,0.29944485,16.003478)">
+ <ellipse
+ ry="2.0393512"
+ rx="3.7681725"
+ cy="4.1903658"
+ cx="15.684584"
+ id="path4707"
+ style="fill:#000000;fill-opacity:1;stroke:#1b4955;stroke-width:4.19104528;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:open="true"
+ d="m 27.924641,24.480045 a 12.381138,4.5885401 0 0 1 -5.389494,4.630461 12.381138,4.5885401 0 0 1 -13.6070929,0 12.381138,4.5885401 0 0 1 -5.3894938,-4.630461"
+ sodipodi:end="3.3161256"
+ sodipodi:start="6.1086524"
+ sodipodi:ry="4.5885401"
+ sodipodi:rx="12.381138"
+ sodipodi:cy="25.276836"
+ sodipodi:cx="15.731601"
+ sodipodi:type="arc"
+ id="path4713"
+ style="fill:none;fill-opacity:1;stroke:#1b4955;stroke-width:4.19104528;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4786"
+ d="M 11.916411,4.190366 3.5058978,24.55204"
+ style="fill:none;fill-rule:evenodd;stroke:#1b4955;stroke-width:4.19099998;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4788"
+ d="m 19.452756,4.190366 8.523265,20.406455"
+ style="fill:none;fill-rule:evenodd;stroke:#1b4955;stroke-width:4.19104528;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4792"
+ d="M 14.290381,28.788695 C 10.180956,28.613169 6.4375964,27.579732 5.0085088,26.226233 4.6609485,25.897057 4.4594815,25.552368 4.4594815,25.286905 c 0,-0.138879 0.9795392,-2.55794 3.8491936,-9.505936 2.1170569,-5.125808 3.8663729,-9.3363317 3.8873699,-9.356719 0.021,-0.020387 0.142544,0.025619 0.270103,0.1022359 0.127559,0.076617 0.427949,0.2108717 0.667533,0.2983439 0.917499,0.3349788 1.766737,0.459885 2.862003,0.4209446 1.069767,-0.038034 1.89748,-0.229734 2.734381,-0.6332892 0.250542,-0.1208116 0.45974,-0.2144914 0.464884,-0.2081775 0.0052,0.00631 1.764658,4.2160153 3.910029,9.3548903 2.91379,6.979495 3.900674,9.39029 3.900674,9.528701 0,0.578492 -0.809317,1.319189 -2.086026,1.909156 -1.978433,0.914234 -4.683823,1.458828 -7.928702,1.596046 -1.178869,0.04985 -1.440285,0.04942 -2.700543,-0.0044 l 0,-3e-6 z"
+ style="fill:#b7d9ea;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <ellipse
+ ry="1.8799957"
+ rx="3.5278082"
+ cy="3.3025274"
+ cx="15.636511"
+ id="path4707-9"
+ style="fill:#b7d9ea;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ id="svg4700"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ viewBox="0 0 16 16"
+ sodipodi:docname="torus.svg"
+ inkscape:export-filename="/export/home/ldigallo/DOC_ALYOTECH/icones/Primitives/torus.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4702">
+ <marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker4450"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path4452"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
+ transform="matrix(0.8,0,0,0.8,10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker4434"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path4436"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
+ transform="matrix(0.8,0,0,0.8,10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lstart"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path4170"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
+ transform="matrix(0.8,0,0,0.8,10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="42.71875"
+ inkscape:cx="7.4081323"
+ inkscape:cy="8.3624015"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ showguides="true"
+ inkscape:snap-object-midpoints="false"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1006"
+ inkscape:window-x="0"
+ inkscape:window-y="25"
+ inkscape:window-maximized="1"
+ inkscape:snap-others="true"
+ inkscape:snap-nodes="false"
+ inkscape:snap-grids="false"
+ inkscape:showpageshadow="false"
+ showborder="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid5248" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata4705">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ transform="translate(0,-16)">
+ <g
+ id="g4179"
+ transform="matrix(1,0,0,1.1022834,-0.04681784,-2.5396163)">
+ <ellipse
+ ry="2.1029613"
+ rx="2.5721776"
+ cy="24.088104"
+ cx="8.0245848"
+ id="path5250"
+ style="fill:none;fill-opacity:1;stroke:#1b4955;stroke-width:2.28365493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <ellipse
+ ry="5.5472407"
+ rx="6.7849512"
+ cy="24.088104"
+ cx="8.0245848"
+ id="path5250-7"
+ style="opacity:1;fill:none;fill-opacity:1;stroke:#1b4955;stroke-width:2.28365493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4163"
+ d="M 7.3830656,28.970613 C 6.9591888,28.93369 6.5847252,28.865163 6.1216233,28.739766 3.939623,28.148936 2.3343232,26.553308 2.0542907,24.69694 c -0.059727,-0.395941 -0.026579,-1.199534 0.06393,-1.549817 0.2441973,-0.945074 0.7282812,-1.715403 1.5083369,-2.400239 1.0414383,-0.914309 2.439622,-1.460679 3.968098,-1.550617 2.6285644,-0.154668 5.0553554,1.09409 6.0316174,3.103697 0.249677,0.513954 0.374766,1.022658 0.401375,1.632277 0.129471,2.966315 -3.01956,5.354123 -6.6445827,5.038372 z m 1.4750261,-2.21691 c 0.5665465,-0.119025 1.0649768,-0.349607 1.5010603,-0.694414 1.344125,-1.062792 1.365432,-2.81722 0.04742,-3.904876 -0.4423445,-0.365035 -0.933834,-0.599155 -1.5404683,-0.7338 -0.3675822,-0.08159 -1.0965106,-0.10042 -1.4681193,-0.03793 -0.6943238,0.116752 -1.2018962,0.334626 -1.7037842,0.731346 -0.4370814,0.345495 -0.7235718,0.734014 -0.9039922,1.225935 -0.083643,0.228056 -0.091134,0.286581 -0.093426,0.730023 -0.00271,0.522574 0.017695,0.620916 0.2185705,1.053794 0.3591292,0.77391 1.2591819,1.416179 2.2924167,1.635845 0.5068234,0.107752 1.1197254,0.105554 1.6503207,-0.0059 z"
+ style="opacity:1;fill:#b7d9ea;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ </g>
+ </g>
+</svg>
<source path="cylinder_widget.xml"/>
</feature>
</group>
+ <group id="Primitives">
+ <feature id="Sphere" title="Sphere" tooltip="Create a sphere" icon="icons/Primitives/sphere.png">
+ <source path="sphere_widget.xml"/>
+ </feature>
+ </group>
+ <group id="Primitives">
+ <feature id="Torus" title="Torus" tooltip="Create a Torus" icon="icons/Primitives/torus.png">
+ <source path="torus_widget.xml"/>
+ </feature>
+ </group>
+ <group id="Primitives">
+ <feature id="Cone" title="Cone" tooltip="Create a Cone" icon="icons/Primitives/cone.png">
+ <source path="cone_widget.xml"/>
+ </feature>
+ </group>
</workbench>
</plugin>
--- /dev/null
+<!-- Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+<source>
+ <shape_selector id="center_point"
+ label="Center point"
+ icon="icons/Primitives/point.png"
+ tooltip="Select a center point"
+ shape_types="vertex">
+ </shape_selector>
+ <doublevalue id="radius"
+ label="Radius"
+ icon="icons/Primitives/radius.png"
+ tooltip="Enter a radius"
+ step="1."
+ default="10.">
+ </doublevalue>
+</source>
\ No newline at end of file
--- /dev/null
+<!-- Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+<source>
+ <shape_selector
+ id="base_point"
+ label="base_point"
+ default=""
+ shape_types="vertex"
+ icon="icons/Primitives/point.png"
+ tooltip="Select the center of the torus">
+ <validator id="GeomValidators_ConstructionComposite"/>
+ <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+ </shape_selector>
+ <shape_selector
+ id="axis"
+ label="axis"
+ default=""
+ shape_types="edge"
+ icon="icons/Primitives/axis.png"
+ tooltip="Select the axis of the torus">
+ <validator id="GeomValidators_ConstructionComposite"/>
+ <validator id="GeomValidators_ShapeType" parameters="line"/>
+ </shape_selector>
+ <doublevalue
+ id="radius"
+ label="Radius"
+ step="1."
+ default="15."
+ tooltip="Enter the radius of the torus">
+ </doublevalue>
+ <doublevalue
+ id="ring_radius"
+ label="Ring radius"
+ step="1."
+ default="3."
+ tooltip="Enter the ring radius of the torus">
+ </doublevalue>
+</source>
\ No newline at end of file
"""
from FeaturesAPI import addPlacement, addRotation, addScale, addSymmetry, addTranslation
-from FeaturesAPI import addMultiTranslation
+from FeaturesAPI import addMultiTranslation, addMultiRotation
from FeaturesAPI import addExtrusion, addExtrusionCut, addExtrusionFuse
from FeaturesAPI import addRevolution, addRevolutionCut, addRevolutionFuse
from FeaturesAPI import addPipe
"""Package for Primitives plugin for the Parametric Geometry API of the Modeler.
"""
-from PrimitivesAPI import addBox, addCylinder
+from PrimitivesAPI import addBox, addCone, addCylinder, addSphere, addTorus