#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
-
+//=================================================================================================
FeaturesAPI_BoundingBox::
FeaturesAPI_BoundingBox(const std::shared_ptr<ModelAPI_Feature>& theFeature)
: ModelHighAPI_Interface(theFeature)
initialize();
}
+//=================================================================================================
FeaturesAPI_BoundingBox::FeaturesAPI_BoundingBox(
const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Selection& theobject)
}
}
-
+//=================================================================================================
FeaturesAPI_BoundingBox::~FeaturesAPI_BoundingBox()
{
}
+//=================================================================================================
void FeaturesAPI_BoundingBox::dump(ModelHighAPI_Dumper& theDumper) const
{
FeaturePtr aBase = feature();
theDumper << ")" << std::endl;
}
+//=================================================================================================
BoundingBoxPtr getBoundingBox(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Selection& theobject)
{
FeaturesPlugin_GeometryCalculation.h
FeaturesPlugin_BoundingBox.h
FeaturesPlugin_CreateBoundingBox.h
+ FeaturesPlugin_CommonBoundingBox.h
FeaturesPlugin_FusionFaces.h
FeaturesPlugin_RemoveResults.h
FeaturesPlugin_Chamfer.h
FeaturesPlugin_GeometryCalculation.cpp
FeaturesPlugin_BoundingBox.cpp
FeaturesPlugin_CreateBoundingBox.cpp
+ FeaturesPlugin_CommonBoundingBox.cpp
FeaturesPlugin_FusionFaces.cpp
FeaturesPlugin_RemoveResults.cpp
FeaturesPlugin_Chamfer.cpp
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeDoubleArray.h>
#include <ModelAPI_AttributeBoolean.h>
-#include <GeomAlgoAPI_BoundingBox.h>
#include <ModelAPI_AttributeString.h>
+
+#include <GeomAlgoAPI_BoundingBox.h>
+
#include <ModelAPI_Data.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
-#include <GeomAlgoAPI_PointBuilder.h>
-#include <GeomAPI_Vertex.h>
#include <Config_PropManager.h>
-#include <ModelAPI_ResultBody.h>
#include <FeaturesPlugin_CreateBoundingBox.h>
#include <iomanip>
#include <sstream>
-#include <iostream>
+//=================================================================================================
FeaturesPlugin_BoundingBox::FeaturesPlugin_BoundingBox()
{
}
+//=================================================================================================
void FeaturesPlugin_BoundingBox::initAttributes()
{
// attribute for object selected
}
+//=================================================================================================
void FeaturesPlugin_BoundingBox::execute()
{
updateValues();
- if(boolean(CREATEBOX_ID())->value())
- {
- if( !myCreateFeature.get() )
+ createBoxByTwoPoints();
+
+ if (boolean(CREATEBOX_ID())->value()) {
+ if (!myCreateFeature.get())
createBox();
updateBox();
- }else{
- if( myCreateFeature.get() )
- {
+ } else {
+ if (myCreateFeature.get()) {
myCreateFeature->eraseResults();
SessionPtr aSession = ModelAPI_Session::get();
DocumentPtr aDoc = aSession->activeDocument();
}
}
+//=================================================================================================
void FeaturesPlugin_BoundingBox::attributeChanged(const std::string& theID)
{
if (theID == OBJECTS_LIST_ID()) {
updateValues();
- if( myCreateFeature.get() )
+ createBoxByTwoPoints();
+ if (myCreateFeature.get())
updateBox();
}
}
+//=================================================================================================
+AttributePtr FeaturesPlugin_BoundingBox::attributResultValues()
+{
+ return attribute(RESULT_VALUES_ID());
+}
+
+//=================================================================================================
void FeaturesPlugin_BoundingBox::updateValues()
{
AttributeSelectionPtr aSelection = selection(OBJECTS_LIST_ID());
if (!aShape && aSelection->context())
aShape = aSelection->context()->shape();
}
- if (aShape){
+ if (aShape) {
double aXmin, aXmax, aYmin,aYmax,aZmin,aZmax;
std::string aError;
- if( !GetBoundingBox(aShape,
+ if (!GetBoundingBox(aShape,
true,
aXmin, aXmax,
aYmin,aYmax,
}
}
+//=================================================================================================
void FeaturesPlugin_BoundingBox::updateBox()
{
myCreateFeature->selection(FeaturesPlugin_CreateBoundingBox::OBJECTS_LIST_ID())
#ifndef FeaturesPlugin_BoundingBox_H_
#define FeaturesPlugin_BoundingBox_H_
-#include "FeaturesPlugin.h"
-#include <ModelAPI_Feature.h>
-
-#include <GeomAPI_IPresentable.h>
-#include <GeomAPI_IScreenParams.h>
-#include <GeomAlgoAPI_Box.h>
+#include <FeaturesPlugin_CommonBoundingBox.h>
/// \class FeaturesPlugin_BoundingBox
/// \ingroup Plugins
/// \brief Feature to view the Bounding Box.
-class FeaturesPlugin_BoundingBox : public ModelAPI_Feature
+class FeaturesPlugin_BoundingBox : public FeaturesPlugin_CommonBoundingBox
{
public:
inline static const std::string& ID()
return MY_Z_MIN_COOD_ID;
}
- /// Attribute name for x max coodinate.
+ /// Attribute name for x max coodinate.
inline static const std::string& X_MAX_COOD_ID()
{
static const std::string MY_X_MAX_COOD_ID("xmaxcoordinate");
FeaturesPlugin_BoundingBox();
private:
+ /// Return Attribut values of result.
+ virtual AttributePtr attributResultValues();
+
+ /// Update values displayed.
void updateValues();
+ /// Create Box
void createBox();
+ /// Update Box
void updateBox();
+
+ /// Feature to create box
FeaturePtr myCreateFeature;
};
--- /dev/null
+// Copyright (C) 2018-2020 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
+//
+
+#include "FeaturesPlugin_CommonBoundingBox.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeDoubleArray.h>
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <GeomAlgoAPI_BoundingBox.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Vertex.h>
+#include <Config_PropManager.h>
+#include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_ShapeTools.h>
+
+#include <PrimitivesPlugin_Box.h>
+
+#include <iomanip>
+#include <sstream>
+#include <iostream>
+
+
+//=================================================================================================
+void FeaturesPlugin_CommonBoundingBox::createBoxByTwoPoints()
+{
+ AttributeDoubleArrayPtr aValues =
+ std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attributResultValues());
+
+ SessionPtr aSession = ModelAPI_Session::get();
+
+ DocumentPtr aDoc = aSession->activeDocument();
+
+ GeomVertexPtr vertexFirst =
+ GeomAlgoAPI_PointBuilder::vertex( aValues->value(0),
+ aValues->value(2),
+ aValues->value(4));
+
+ GeomVertexPtr vertexSecond =
+ GeomAlgoAPI_PointBuilder::vertex( aValues->value(1),
+ aValues->value(3),
+ aValues->value(5));
+
+
+ std::shared_ptr<GeomAlgoAPI_Box> aBoxAlgo;
+
+
+ aBoxAlgo = std::shared_ptr<GeomAlgoAPI_Box>(
+ new GeomAlgoAPI_Box(vertexFirst->point(),vertexSecond->point()));
+
+
+ // These checks should be made to the GUI for the feature but
+ // the corresponding validator does not exist yet.
+ if (!aBoxAlgo->check()) {
+ setError(aBoxAlgo->getError());
+ return;
+ }
+
+ // Build the box
+ aBoxAlgo->build();
+
+ // Check if the creation of the box
+ if (!aBoxAlgo->isDone()) {
+ // The error is not displayed in a popup window. It must be in the message console.
+ setError(aBoxAlgo->getError());
+ return;
+ }
+ if (!aBoxAlgo->checkValid("Box builder with two points")) {
+ // The error is not displayed in a popup window. It must be in the message console.
+ setError(aBoxAlgo->getError());
+ return;
+ }
+
+ int aResultIndex = 0;
+ ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
+ loadNamingDS(aBoxAlgo, aResultBox);
+ setResult(aResultBox, aResultIndex);
+}
+
+//=================================================================================================
+void FeaturesPlugin_CommonBoundingBox::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Box> theBoxAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBox)
+{
+ // Load the result
+ theResultBox->store(theBoxAlgo->shape());
+
+ // Prepare the naming
+ theBoxAlgo->prepareNamingFaces();
+
+ // Insert to faces
+ std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
+ theBoxAlgo->getCreatedFaces();
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
+ it != listOfFaces.end();
+ ++it) {
+ theResultBox->generated((*it).second, (*it).first);
+ }
+}
+
--- /dev/null
+// Copyright (C) 2018-2020 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
+//
+
+#ifndef FeaturesPlugin_CommonBoundingBox_H_
+#define FeaturesPlugin_CommonBoundingBox_H_
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+
+#include <GeomAPI_IPresentable.h>
+#include <GeomAPI_IScreenParams.h>
+#include <GeomAlgoAPI_Box.h>
+
+#include <ModelAPI_Attribute.h>
+
+/// \class FeaturesPlugin_CommonBoundingBox
+/// \ingroup Plugins
+/// \brief Feature to view the Bounding Box.
+
+class FeaturesPlugin_CommonBoundingBox : public ModelAPI_Feature
+{
+public:
+
+ /// Performs the algorithm and stores results it in the data structure.
+ FEATURESPLUGIN_EXPORT virtual void execute(){};
+
+ /// Return Attribut values of result.
+ virtual AttributePtr attributResultValues() = 0;
+
+ protected:
+ FeaturesPlugin_CommonBoundingBox() {}
+
+ /// Create box with two points
+ void createBoxByTwoPoints();
+
+ /// Create namming
+ void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Box> theBoxAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBox);
+
+};
+
+#endif
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeDoubleArray.h>
#include <ModelAPI_AttributeBoolean.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <GeomAlgoAPI_BoundingBox.h>
#include <ModelAPI_AttributeString.h>
+
#include <ModelAPI_Data.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
-#include <GeomAlgoAPI_PointBuilder.h>
-#include <GeomAPI_Vertex.h>
+
+#include <GeomAlgoAPI_BoundingBox.h>
+
#include <Config_PropManager.h>
#include <ModelAPI_ResultBody.h>
-#include <GeomAlgoAPI_ShapeTools.h>
#include <PrimitivesPlugin_Box.h>
#include <iomanip>
#include <sstream>
-#include <iostream>
+//=================================================================================================
FeaturesPlugin_CreateBoundingBox::FeaturesPlugin_CreateBoundingBox()
{
}
+//=================================================================================================
void FeaturesPlugin_CreateBoundingBox::initAttributes()
{
// attribute for object selected
}
+//=================================================================================================
void FeaturesPlugin_CreateBoundingBox::execute()
{
updateValues();
createBoxByTwoPoints();
}
+//=================================================================================================
void FeaturesPlugin_CreateBoundingBox::attributeChanged(const std::string& theID)
{
if (theID == OBJECTS_LIST_ID()) {
}
}
+//=================================================================================================
void FeaturesPlugin_CreateBoundingBox::updateValues()
{
AttributeSelectionPtr aSelection = selection(OBJECTS_LIST_ID());
}
//=================================================================================================
-void FeaturesPlugin_CreateBoundingBox::createBoxByTwoPoints()
+AttributePtr FeaturesPlugin_CreateBoundingBox::attributResultValues()
{
- AttributeDoubleArrayPtr aValues =
- std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
-
- SessionPtr aSession = ModelAPI_Session::get();
-
- DocumentPtr aDoc = aSession->activeDocument();
-
- GeomVertexPtr vertexFirst =
- GeomAlgoAPI_PointBuilder::vertex( aValues->value(0),
- aValues->value(2),
- aValues->value(4));
-
- GeomVertexPtr vertexSecond =
- GeomAlgoAPI_PointBuilder::vertex( aValues->value(1),
- aValues->value(3),
- aValues->value(5));
-
-
- std::shared_ptr<GeomAlgoAPI_Box> aBoxAlgo;
-
-
- aBoxAlgo = std::shared_ptr<GeomAlgoAPI_Box>(
- new GeomAlgoAPI_Box(vertexFirst->point(),vertexSecond->point()));
-
-
- // These checks should be made to the GUI for the feature but
- // the corresponding validator does not exist yet.
- if (!aBoxAlgo->check()) {
- setError(aBoxAlgo->getError());
- return;
- }
-
- // Build the box
- aBoxAlgo->build();
-
- // Check if the creation of the box
- if(!aBoxAlgo->isDone()) {
- // The error is not displayed in a popup window. It must be in the message console.
- setError(aBoxAlgo->getError());
- return;
- }
- if(!aBoxAlgo->checkValid("Box builder with two points")) {
- // The error is not displayed in a popup window. It must be in the message console.
- setError(aBoxAlgo->getError());
- return;
- }
-
- int aResultIndex = 0;
- ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
- loadNamingDS(aBoxAlgo, aResultBox);
- setResult(aResultBox, aResultIndex);
-}
-
-//=================================================================================================
-void FeaturesPlugin_CreateBoundingBox::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Box> theBoxAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBox)
-{
- // Load the result
- theResultBox->store(theBoxAlgo->shape());
-
- // Prepare the naming
- theBoxAlgo->prepareNamingFaces();
-
- // Insert to faces
- std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
- theBoxAlgo->getCreatedFaces();
- for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
- it != listOfFaces.end();
- ++it)
- {
- theResultBox->generated((*it).second, (*it).first);
- }
+ return attribute(RESULT_VALUES_ID());
}
-
#ifndef FeaturesPlugin_CreateBoundingBox_H_
#define FeaturesPlugin_CreateBoundingBox_H_
-#include "FeaturesPlugin.h"
-#include <ModelAPI_Feature.h>
-
-#include <GeomAPI_IPresentable.h>
-#include <GeomAPI_IScreenParams.h>
-#include <GeomAlgoAPI_Box.h>
+#include <FeaturesPlugin_CommonBoundingBox.h>
/// \class FeaturesPlugin_BoundingBox
/// \ingroup Plugins
/// \brief Feature to view the Bounding Box.
-class FeaturesPlugin_CreateBoundingBox : public ModelAPI_Feature
+class FeaturesPlugin_CreateBoundingBox : public FeaturesPlugin_CommonBoundingBox
{
public:
inline static const std::string& ID()
/// \param theID identifier of changed attribute
FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+ /// Return Attribut values of result.
+ FEATURESPLUGIN_EXPORT virtual AttributePtr attributResultValues();
+
/// Use plugin manager for features creation
FeaturesPlugin_CreateBoundingBox();
private:
+ /// Update values displayed.
void updateValues();
- void createBoxByTwoPoints();
- void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Box> theBoxAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBox);
};
# Initialization of the test
#=========================================================================
-import salome
import os
import math