Python API feature to process ellipsoid has been implemented.
SET(PROJECT_HEADERS
GDMLAPI.h
GDMLAPI_ConeSegment.h
+ GDMLAPI_Ellipsoid.h
)
SET(PROJECT_SOURCES
GDMLAPI_ConeSegment.cpp
+ GDMLAPI_Ellipsoid.cpp
)
SET(PROJECT_LIBRARIES
// shared pointers
%shared_ptr(GDMLAPI_ConeSegment)
+%shared_ptr(GDMLAPI_Ellipsoid)
// all supported interfaces
%include "GDMLAPI_ConeSegment.h"
-
+%include "GDMLAPI_Ellipsoid.h"
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "GDMLAPI_Ellipsoid.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+GDMLAPI_Ellipsoid::GDMLAPI_Ellipsoid(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+ : ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+GDMLAPI_Ellipsoid::GDMLAPI_Ellipsoid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ)
+ : ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ setSizes(theAX, theBY, theCZ);
+ fillAttribute("", useZCut1());
+ fillAttribute("", useZCut1());
+ }
+}
+
+GDMLAPI_Ellipsoid::GDMLAPI_Ellipsoid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ,
+ const ModelHighAPI_Double& theZCut1,
+ const ModelHighAPI_Double& theZCut2)
+ : ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ setSizes(theAX, theBY, theCZ);
+ setZCut1(theZCut1);
+ setZCut2(theZCut2);
+ }
+}
+
+GDMLAPI_Ellipsoid::~GDMLAPI_Ellipsoid()
+{
+}
+
+void GDMLAPI_Ellipsoid::setSizes(const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ)
+{
+ fillAttribute(theAX, ax());
+ fillAttribute(theBY, by());
+ fillAttribute(theCZ, cz());
+
+ execute();
+}
+
+void GDMLAPI_Ellipsoid::setZCut1(const ModelHighAPI_Double& theZCut1)
+{
+ fillAttribute("true", useZCut1());
+ fillAttribute(theZCut1, zCut1());
+
+ execute();
+}
+
+void GDMLAPI_Ellipsoid::setZCut2(const ModelHighAPI_Double& theZCut2)
+{
+ fillAttribute("true", useZCut2());
+ fillAttribute(theZCut2, zCut2());
+
+ execute();
+}
+
+
+//==================================================================================================
+void GDMLAPI_Ellipsoid::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ AttributeDoublePtr anAttrAX = aBase->real(GDMLPlugin_Ellipsoid::AX_ID());
+ AttributeDoublePtr anAttrBY = aBase->real(GDMLPlugin_Ellipsoid::BY_ID());
+ AttributeDoublePtr anAttrCZ = aBase->real(GDMLPlugin_Ellipsoid::CZ_ID());
+
+ theDumper << aBase << " = model.addEllipsoid(" << aDocName << ", "
+ << anAttrAX << ", " << anAttrBY << ", " << anAttrCZ;
+
+ AttributeStringPtr anAttrUseZCut1 = aBase->string(GDMLPlugin_Ellipsoid::USE_ZCUT1_ID());
+ AttributeDoublePtr anAttrZCut1 = aBase->real(GDMLPlugin_Ellipsoid::ZCUT1_ID());
+ AttributeStringPtr anAttrUseZCut2 = aBase->string(GDMLPlugin_Ellipsoid::USE_ZCUT2_ID());
+ AttributeDoublePtr anAttrZCut2 = aBase->real(GDMLPlugin_Ellipsoid::ZCUT2_ID());
+
+ bool isZCut1 = !anAttrUseZCut1->value().empty();
+ bool isZCut2 = !anAttrUseZCut2->value().empty();
+ if (isZCut1 && isZCut2)
+ theDumper << ", " << anAttrZCut1 << ", " << anAttrZCut2 << ")" << std::endl;
+ else {
+ theDumper << ")" << std::endl;
+
+ if (isZCut1 && !isZCut2)
+ theDumper << theDumper.name(aBase) << ".setZCut1(" << anAttrZCut1 << ")" << std::endl;
+ else if (!isZCut1 && isZCut2)
+ theDumper << theDumper.name(aBase) << ".setZCut2(" << anAttrZCut2 << ")" << std::endl;
+ }
+}
+
+
+//==================================================================================================
+EllipsoidPtr addEllipsoid(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(GDMLAPI_Ellipsoid::ID());
+ return EllipsoidPtr(new GDMLAPI_Ellipsoid(aFeature, theAX, theBY, theCZ));
+}
+
+EllipsoidPtr addEllipsoid(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ,
+ const ModelHighAPI_Double& theZCut1,
+ const ModelHighAPI_Double& theZCut2)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(GDMLAPI_Ellipsoid::ID());
+ return EllipsoidPtr(new GDMLAPI_Ellipsoid(aFeature, theAX, theBY, theCZ, theZCut1, theZCut2));
+}
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef GDMLAPI_Ellipsoid_H_
+#define GDMLAPI_Ellipsoid_H_
+
+#include "GDMLAPI.h"
+
+#include <GDMLPlugin_Ellipsoid.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+
+/// \class GDMLAPI_Ellipsoid
+/// \ingroup CPPHighAPI
+/// \brief Interface for primitive Ellipsoid feature.
+class GDMLAPI_Ellipsoid: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ GDMLAPI_EXPORT
+ explicit GDMLAPI_Ellipsoid(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ GDMLAPI_EXPORT
+ explicit GDMLAPI_Ellipsoid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ);
+
+ /// Constructor with values.
+ GDMLAPI_EXPORT
+ explicit GDMLAPI_Ellipsoid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ,
+ const ModelHighAPI_Double& theZCut1,
+ const ModelHighAPI_Double& theZCut2);
+
+ /// Destructor.
+ GDMLAPI_EXPORT
+ virtual ~GDMLAPI_Ellipsoid();
+
+ INTERFACE_7(GDMLPlugin_Ellipsoid::ID(),
+ ax, GDMLPlugin_Ellipsoid::AX_ID(),
+ ModelAPI_AttributeDouble,
+ /** Ellipsoid size along X axis */,
+ by, GDMLPlugin_Ellipsoid::BY_ID(),
+ ModelAPI_AttributeDouble,
+ /** Ellipsoid size along Y axis */,
+ cz, GDMLPlugin_Ellipsoid::CZ_ID(),
+ ModelAPI_AttributeDouble,
+ /** Ellipsoid size along Z axis */,
+ useZCut1, GDMLPlugin_Ellipsoid::USE_ZCUT1_ID(),
+ ModelAPI_AttributeString,
+ /** First cut of the ellipsoid along Z axis */,
+ zCut1, GDMLPlugin_Ellipsoid::ZCUT1_ID(),
+ ModelAPI_AttributeDouble,
+ /** Position of the first cut */,
+ useZCut2, GDMLPlugin_Ellipsoid::USE_ZCUT2_ID(),
+ ModelAPI_AttributeString,
+ /** Second cut of the ellipsoid along Z axis */,
+ zCut2, GDMLPlugin_Ellipsoid::ZCUT2_ID(),
+ ModelAPI_AttributeDouble,
+ /** Position of the second cut */)
+
+ /// Set dimensions
+ GDMLAPI_EXPORT
+ void setSizes(const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ);
+
+ /// Set Z cut no.1
+ GDMLAPI_EXPORT
+ void setZCut1(const ModelHighAPI_Double& theZCut1);
+
+ /// Set Z cut no.2
+ GDMLAPI_EXPORT
+ void setZCut2(const ModelHighAPI_Double& theZCut2);
+
+ /// Dump wrapped feature
+ GDMLAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on primitive Ellipsoid object
+typedef std::shared_ptr<GDMLAPI_Ellipsoid> EllipsoidPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create GDML Ellipsoid feature.
+GDMLAPI_EXPORT
+EllipsoidPtr addEllipsoid(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ);
+
+/// \ingroup CPPHighAPI
+/// \brief Create GDML Ellipsoid feature.
+GDMLAPI_EXPORT
+EllipsoidPtr addEllipsoid(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theAX,
+ const ModelHighAPI_Double& theBY,
+ const ModelHighAPI_Double& theCZ,
+ const ModelHighAPI_Double& theZCut1,
+ const ModelHighAPI_Double& theZCut2);
+#endif // GDMLAPI_Ellipsoid_H_
#include "GDMLAPI.h"
#include "GDMLAPI_ConeSegment.h"
+ #include "GDMLAPI_Ellipsoid.h"
#endif // GDMLAPI_swig_H_
"""Package for GDML plugin for the Parametric Geometry API of the Modeler.
"""
-from GDMLAPI import addConeSegment
+from GDMLAPI import addConeSegment, addEllipsoid