: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
+ fillAttribute(PrimitivesPlugin_Sphere::CREATION_METHOD_BY_PT_RADIUS(), creationMethod());
fillAttribute(theCenterPoint, centerPoint());
setRadius(theRadius);
}
}
+//==================================================================================================
+PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& thePhiMin,
+ const ModelHighAPI_Double& thePhiMax,
+ const ModelHighAPI_Double& theThetaMin,
+ const ModelHighAPI_Double& theThetaMax)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ fillAttribute(PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS(), creationMethod());
+ fillAttribute(theRMin, rmin());
+ fillAttribute(theRMax, rmax());
+ fillAttribute(thePhiMin, phimin());
+ fillAttribute(thePhiMax, phimax());
+ fillAttribute(theThetaMin, thetamin());
+ fillAttribute(theThetaMax, thetamax());
+ execute();
+ }
+}
+
//==================================================================================================
PrimitivesAPI_Sphere::~PrimitivesAPI_Sphere()
{
execute();
}
+//==================================================================================================
+void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax)
+{
+ fillAttribute(theRMin, rmin());
+ fillAttribute(theRMax, rmax());
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Sphere::setPhi(const ModelHighAPI_Double& thePhiMin,
+ const ModelHighAPI_Double& thePhiMax)
+{
+ fillAttribute(thePhiMin, phimin());
+ fillAttribute(thePhiMax, phimax());
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Sphere::setTheta(const ModelHighAPI_Double& theThetaMin,
+ const ModelHighAPI_Double& theThetaMax)
+{
+ fillAttribute(theThetaMin, thetamin());
+ fillAttribute(theThetaMax, thetamax());
+ execute();
+}
+
//==================================================================================================
void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const
{
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;
+ std::string aCreationMethod = aBase->string(PrimitivesPlugin_Sphere::CREATION_METHOD())->value();
+
+ if(aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_PT_RADIUS()) {
+ AttributeSelectionPtr anAttrCenterPoint =
+ aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID());
+ AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID());
+ theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius;
+ } else if(aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS()) {
+ AttributeDoublePtr anAttrRMin = aBase->real(PrimitivesPlugin_Sphere::RMIN_ID());
+ AttributeDoublePtr anAttrRMax = aBase->real(PrimitivesPlugin_Sphere::RMAX_ID());
+ AttributeDoublePtr anAttrPhiMin = aBase->real(PrimitivesPlugin_Sphere::PHIMIN_ID());
+ AttributeDoublePtr anAttrPhiMax = aBase->real(PrimitivesPlugin_Sphere::PHIMAX_ID());
+ AttributeDoublePtr anAttrThetaMin = aBase->real(PrimitivesPlugin_Sphere::THETAMIN_ID());
+ AttributeDoublePtr anAttrThetaMax = aBase->real(PrimitivesPlugin_Sphere::THETAMAX_ID());
+ theDumper << ", " << anAttrRMin << ", " << anAttrRMax;
+ theDumper << ", " << anAttrPhiMin << ", " << anAttrPhiMax;
+ theDumper << ", " << anAttrThetaMin << ", " << anAttrThetaMax;
+ }
theDumper << ")" << std::endl;
}
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius));
}
+
+//==================================================================================================
+SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& thePhiMin,
+ const ModelHighAPI_Double& thePhiMax,
+ const ModelHighAPI_Double& theThetaMin,
+ const ModelHighAPI_Double& theThetaMax)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
+ return SpherePtr(new PrimitivesAPI_Sphere(aFeature, theRMin, theRMax, thePhiMin, thePhiMax,
+ theThetaMin, theThetaMax));
+}