FIND_LIBRARY(TKVInspector TKVInspector "${TINSPECTOR_LIB_DIR}")
SET(TKVInspector ${TKVInspector})
+ FIND_LIBRARY(DFBrowserAPI DFBrowserAPI "${TINSPECTOR_LIB_DIR}")
+ SET(DFBrowserAPI ${DFBrowserAPI})
+
+ FIND_LIBRARY(TKDFTreeModel TKDFTreeModel "${TINSPECTOR_LIB_DIR}")
+ SET(TKDFTreeModel ${TKDFTreeModel})
+
ENDIF(TKTInspector)
ENDIF(EXISTS ${TINSPECTOR_ROOT_DIR})
#include <ModelAPI_Document.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Session.h>
#include "FeaturesPlugin_CompositeBoolean.h"
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Boolean.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_Session.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Result.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Copy.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
#include <FeaturesPlugin_Tools.h>
#include <GeomAPI_Face.h>
#include <GeomAPI_Lin.h>
#include <GeomAPI_Pln.h>
+#include <GeomAPI_Trsf.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
#include <GeomAlgoAPI_PointBuilder.h>
SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_14")
SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 30)
SketchArc_2 = Sketch_1.addArc(-8.152231059872202, 11.25015706261054, -38.72043789437247, 5.632510332222703, -20.37351638704503, 39.82660556161157, True)
+SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 30)
SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_2.endPoint())
SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_15")
SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_2.result())
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
+#include <gp_GTrsf.hxx>
#include <gp_Trsf.hxx>
#define MY_TRSF implPtr<gp_Trsf>()
#include <ModelAPI_AttributeSelection.h>
#include "ModelAPI_Object.h"
+#include <GeomAPI_Shape.h>
+
bool GeomValidators_DifferentShapes::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
#include "GeomValidators_IntersectionSelection.h"
+#include <GeomAPI_Shape.h>
+
#include <Events_InfoMessage.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeValidator.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
#include <Model_ResultConstruction.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_CompositeFeature.h>
if (aConstr.get()) {
Handle(TDataStd_Integer) anIndex;
if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) {
- if (anIndex->Get() == 0) // it is just reference to construction, nothing is in value
- return true;
- return aConstr->shape(anIndex->Get(), owner()->document()).get() != NULL;
+ // for the whole shape it may return null, so, if index exists, returns true
+ return true;
}
}
}
#include "Model_Events.h"
#include "Model_Data.h"
+#include <GeomAPI_Shape.h>
+
#include <TDF_AttributeIterator.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_RelocationTable.hxx>
if (myWasChangedButBlocked.empty() || *(myWasChangedButBlocked.rbegin()) != theAttr)
myWasChangedButBlocked.push_back(theAttr);
}
+ } else {
+ // trim: need to redisplay
+ if (myObject) {
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
+ }
}
}
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <Events_Loop.h>
#include <Events_InfoMessage.h>
#include <Model_ResultBody.h>
#include <Model_BodyBuilder.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <Config_PropManager.h>
#include <ModelAPI_Events.h>
#include <Model_Data.h>
#include <ModelAPI_CompositeFeature.h>
#include <Model_SelectionNaming.h>
+#include <ModelAPI_Events.h>
#include <Config_PropManager.h>
#include <GeomAPI_PlanarEdges.h>
#include <GeomAPI_Shape.h>
#include <GeomAlgoAPI_SketchBuilder.h>
#include <Events_Loop.h>
-#include <ModelAPI_Events.h>
+#include <TDF_Reference.hxx>
#include <TDF_ChildIterator.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Builder.hxx>
-#include <TopoDS_Shape.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_IntPackedMap.hxx>
#include <TDataStd_Name.hxx>
+#include <TDataStd_UAttribute.hxx>
#include <TColStd_MapOfTransient.hxx>
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp_Explorer.hxx>
#include <Precision.hxx>
+// identifier that it is full result selected, but in external document (for internal index is 0)
+Standard_GUID kFULL_RESULT_ID("ee87e529-da6f-46af-be25-5e0fefde52f7");
+
void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName,
std::string& theDefault)
static void registerSubShape(TDF_Label theMainLabel, TopoDS_Shape theShape,
const int theID, std::shared_ptr<Model_Document> theDoc,
+ bool theSelectionMode,
std::map<int, int>& theOrientations,
// name of sub-elements by ID to be exported instead of indexes
std::map<int, std::string>& theSubNames,
TDataStd_Integer::Set(aLab, theOrientation);
}
TNaming_Builder aBuilder(aLab);
- aBuilder.Generated(theShape);
+ // wire never happens as sub, it must be generated to be found
+ // by SelectionNaming TNaming_Tool::NamedShape
+ if (theSelectionMode && theShape.ShapeType() != TopAbs_WIRE)
+ aBuilder.Select(theShape, theShape);
+ else
+ aBuilder.Generated(theShape);
std::stringstream aName;
// #1839 : do not store name of the feature in the tree, since this name could be changed
//aName<<theContextFeature->name();
// set the naming structure at index
TDF_Label aLab = aDataLab.FindChild(anIndex, Standard_True);
- TNaming_Builder aBuilder(aLab);
- if (aSubShape.IsNull())
- return anIndex - 1; // just keep empty named shape
- aBuilder.Generated(aSubShape);
+
+ // if the subshape is part of a result face, select the whole face (#1997)
+ bool isSelectionMode = false; // and other don't set shapes - all the naming is in face label
+ if (!aSubShape.IsNull() && aSubShape.ShapeType() > TopAbs_FACE) {
+ for(int aFaceIndex = 0; aFaceIndex < facesNum(); aFaceIndex++) {
+ TopExp_Explorer anExp(face(aFaceIndex)->impl<TopoDS_Shape>(), aSubShape.ShapeType());
+ for(; anExp.More(); anExp.Next()) {
+ if (aSubShape.IsSame(anExp.Current())) { // this is the case: select the whole face
+ // here just store the face index (to update face if update of edge is needed)
+ TNaming_Builder aBuilder(aLab);
+ aBuilder.Select(aSubShape, aSubShape);
+ int aFaceSelID = select(face(aFaceIndex), theExtDoc, -1);
+ TDF_Reference::Set(aLab, aLab.Father().FindChild(aFaceSelID));
+ isSelectionMode = true;
+ break;
+ }
+ }
+ }
+ }
+
+ // external full result is not identified by index == 0, so, add here the ID
+ if (!theSubShape.get()) {
+ TDataStd_UAttribute::Set(aLab, kFULL_RESULT_ID);
+ // empty NS
+ TNaming_Builder aBuilder(aLab);
+ // store all sub-faces naming since faces may be used for extrusion, where all edges are needed
+ Handle(TDataStd_IntPackedMap) anIndices = TDataStd_IntPackedMap::Set(aLab);
+ std::list<int> aFacesIndexes;
+ for(int a = 0; a < facesNum(); a++) {
+ anIndices->Add(select(face(a), theExtDoc, -1));
+ }
+ return anIndex - 1;
+ }
+
+ { // this to have erased Builder after the shape was generated (NS on this label may be changed)
+ TNaming_Builder aBuilder(aLab);
+ if (aSubShape.IsNull()) {
+ return anIndex - 1; // just keep empty named shape
+ }
+ // wire never happens as sub, it must be generated to be found
+ // by SelectionNaming TNaming_Tool::NamedShape
+ if (isSelectionMode && aSubShape.ShapeType() != TopAbs_WIRE) {
+ aBuilder.Select(aSubShape, aSubShape);
+ } else {
+ aBuilder.Generated(aSubShape);
+ }
+ }
if (anIndex == 1 && isInfinite()) { // infinitive results has no sub-selection
return anIndex - 1;
// saving of context is enough: result construction contains exactly the needed shape
return anIndex - 1;
}
+
// identify the results of sub-object of the composite by edges
// save type of the selected shape in integer attribute
TopAbs_ShapeEnum aShapeType = aSubShape.ShapeType();
TDF_Label aSubLab = aLab.FindChild(anID);
std::string aName = "Edge-" + Model_SelectionNaming::shortName(aConstr, 0);
TNaming_Builder aBuilder(aSubLab);
- aBuilder.Generated(anEdge);
+ if (isSelectionMode)
+ aBuilder.Select(anEdge, anEdge);
+ else
+ aBuilder.Generated(anEdge);
aMyDoc->addNamingName(aSubLab, aName.c_str());
TDataStd_Name::Set(aSubLab, aName.c_str());
std::string aName = "Vertex-"
+ Model_SelectionNaming::shortName(aConstr, aDelta / kSTART_VERTEX_DELTA);
TNaming_Builder aBuilder(aLab);
- aBuilder.Generated(aV);
+ if (isSelectionMode)
+ aBuilder.Select(aV, aV);
+ else
+ aBuilder.Generated(aV);
aMyDoc->addNamingName(aLab, aName.c_str());
TDataStd_Name::Set(aLab, aName.c_str());
}
}
}
// store the selected as primitive
- registerSubShape(aLab, aSubShape, 0, aMyDoc, anOrientations, aSubNames, aRefs);
-
+ registerSubShape(aLab, aSubShape, 0, aMyDoc, isSelectionMode, anOrientations, aSubNames, aRefs);
return anIndex - 1;
}
Handle(TNaming_NamedShape) aSelection;
if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aSelection)) {
TopoDS_Shape aSelShape = aSelection->Get();
+ if (aSelShape.IsNull())
+ return aResult; // shape equal to context => null
aResult = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
aResult->setImpl(new TopoDS_Shape(aSelShape));
}
theModified = false;
bool anExt;
TDF_Label aLab = startLabel(theExtDoc, anExt).FindChild(theIndex + 1, Standard_True);
- if (theIndex == 0) {
+ if (theIndex == 0 || aLab.IsAttribute(kFULL_RESULT_ID)) { // full for external same as index == 0
// it is just reference to construction, not sub-shape
// if there is a sketch, the sketch-naming must be updated
if (!isInfinite()) {
- BRep_Builder aCompoundBuilder;
- TopoDS_Compound aComp;
- aCompoundBuilder.MakeCompound(aComp);
- for(int a = 0; a < facesNum(); a++) {
- TopoDS_Shape aFace = face(a)->impl<TopoDS_Shape>();
- aCompoundBuilder.Add(aComp, aFace);
+ // update all faces named by the whole result
+ bool aRes = true;
+ Handle(TDataStd_IntPackedMap) anIndices;
+ if (aLab.FindAttribute(TDataStd_IntPackedMap::GetID(), anIndices)) {
+ TColStd_MapIteratorOfPackedMapOfInteger anIndexIter(anIndices->GetMap());
+ for(; anIndexIter.More(); anIndexIter.Next()) {
+ if (!update(anIndexIter.Key(), theExtDoc, theModified))
+ aRes = false;
+ }
}
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
- aShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aComp));
- select(aShape, theExtDoc, theIndex);
+ return aRes;
} else {
// For correct naming selection, put the shape into the naming structure.
// It seems sub-shapes are not needed: only this shape is (and can be ) selected.
// take the face that more close by the indexes
ResultPtr aThisPtr = std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner());
FeaturePtr aContextFeature = document()->feature(aThisPtr);
+
// sketch sub-element
if (std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aContextFeature).get())
{
+ // update the referenced object if it is sub
+ Handle(TDF_Reference) aRef;
+ if (aLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
+ int aFaceIndex = aRef->Get().Tag();
+ // don't check selection ,since face may disappear, but the shape stays correct
+ Model_ResultConstruction::update(aFaceIndex, theExtDoc, theModified);
+ }
// getting a type of selected shape
Handle(TDataStd_Integer) aTypeAttr;
if (!aLab.FindAttribute(TDataStd_Integer::GetID(), aTypeAttr)) {
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
+#include <GeomAPI_Trsf.h>
+
#include <TNaming_Tool.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Name.hxx>
#include <Config_ValidatorMessage.h>
#include <Config_ModuleReader.h>
#include <Config_ValidatorReader.h>
+
+#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_Tools.h>
Test1757.py
Test1998.py
Test1995.py
+ TestExternalConstruction.py
)
#include "ModelAPI_AttributeSelection.h"
#include <ModelAPI_Result.h>
+class GeomAPI_Shape;
+
/**\class ModelAPI_AttributeSelectionList
* \ingroup DataModel
* \brief Attribute that contains list of references to the sub-shapes with
/// \param theTemporarily if it is true, do not store and name the added in the data framework
/// (used to remove immediately, without the following updates)
virtual void append(const ResultPtr& theContext,
- const GeomShapePtr& theSubShape,
+ const std::shared_ptr<GeomAPI_Shape>& theSubShape,
const bool theTemporarily = false) = 0;
/// Adds the new reference to the end of the list by the naming name of the selected shape
#define ModelAPI_Result_H_
#include "ModelAPI_Object.h"
-#include <GeomAPI_Shape.h>
+class GeomAPI_Shape;
class ModelAPI_Feature;
#define ModelAPI_ResultPart_H_
#include "ModelAPI_Result.h"
-#include <GeomAPI_Trsf.h>
+class GeomAPI_Trsf;
#include <string>
#include "ModelAPI_Tools.h"
#include <ModelAPI_Session.h>
+#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_AttributeDocRef.h>
return theResult->shape();
}
-void shapesOfType(const FeaturePtr& theFeature,
- const GeomAPI_Shape::ShapeType& theType,
- std::set<ResultPtr>& theShapeResults)
-{
- theShapeResults.clear();
- std::list<ResultPtr> aResults = theFeature->results();
- std::list<ResultPtr>::const_iterator aRIter = aResults.cbegin();
- for (; aRIter != aResults.cend(); aRIter++) {
- ResultPtr aResult = *aRIter;
- GeomShapePtr aShape = aResult->shape();
- if (aShape.get() && aShape->shapeType() == theType)
- theShapeResults.insert(aResult);
- }
-}
-
const char* toString(ModelAPI_ExecState theExecState)
{
#define TO_STRING(__NAME__) case __NAME__: return #__NAME__;
#include "ModelAPI.h"
-#include <ModelAPI_CompositeFeature.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Result.h>
-#include <ModelAPI_ResultParameter.h>
-#include <ModelAPI_ResultCompSolid.h>
+class ModelAPI_CompositeFeature;
+class ModelAPI_Document;
+class ModelAPI_Feature;
+class ModelAPI_Result;
+class ModelAPI_ResultParameter;
+class ModelAPI_ResultCompSolid;
-#include <GeomAPI_Shape.h>
+class GeomAPI_Shape;
+#include <memory>
#include <vector>
#include <map>
#include <set>
+#include <list>
namespace ModelAPI_Tools {
/// Returns shape from the given Result object
-MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
-
-/// Creates a container of shape of the feature results satisfied the given shape type
-/// \param theFeature a source feature
-/// \param theType shape type
-/// \param an output container for result of shapes
-MODELAPI_EXPORT void shapesOfType(const FeaturePtr& theFeature,
- const GeomAPI_Shape::ShapeType& theType,
- std::set<ResultPtr>& theShapeResults);
+MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(
+ const std::shared_ptr<ModelAPI_Result>& theResult);
/*! Returns the feature error generated according to feature error and exec state
* \param theFeature a feature
* \return error value or empty string
*/
-MODELAPI_EXPORT std::string getFeatureError(const FeaturePtr& theFeature);
+MODELAPI_EXPORT std::string getFeatureError(const std::shared_ptr<ModelAPI_Feature>& theFeature);
/*!
* Searches for variable with name \param theName in \param theDocument.
* If found, set it value in the \param outValue and returns true.
* theSearcher must be located later in the history than the found variable.
*/
-MODELAPI_EXPORT bool findVariable(const DocumentPtr& theDocument, FeaturePtr theSearcher,
- const std::string& theName, double& outValue, ResultParameterPtr& theParam);
+MODELAPI_EXPORT bool findVariable(const std::shared_ptr<ModelAPI_Document>& theDocument,
+ std::shared_ptr<ModelAPI_Feature> theSearcher,
+ const std::string& theName, double& outValue,
+ std::shared_ptr<ModelAPI_ResultParameter>& theParam);
/*!
* Searches for variable with name \param theName in the active document (Part), when
* and returns true. If \param theDocument is empty active document is used.
* theSearcher must be located later in the history than the found variable.
*/
-MODELAPI_EXPORT bool findVariable(FeaturePtr theSearcher, const std::string& theName,
- double& outValue, ResultParameterPtr& theParam,
- const DocumentPtr& theDocument = DocumentPtr());
+MODELAPI_EXPORT bool findVariable(std::shared_ptr<ModelAPI_Feature> theSearcher,
+ const std::string& theName,
+ double& outValue, std::shared_ptr<ModelAPI_ResultParameter>& theParam,
+ const std::shared_ptr<ModelAPI_Document>& theDocument = std::shared_ptr<ModelAPI_Document>());
/*!
* Searches for Part result that contains the reference to the given document.
* \param theSub document that is searched, the resulting feature references to it
* \returns null if not found
*/
-MODELAPI_EXPORT ResultPtr findPartResult(const DocumentPtr& theMain, const DocumentPtr& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_Result> findPartResult(
+ const std::shared_ptr<ModelAPI_Document>& theMain,
+ const std::shared_ptr<ModelAPI_Document>& theSub);
/*!
* Searches for Part the feature that contains in result the reference to the given document.
* \param theSub document that is searched, the resulting feature references to it
* \returns null if not found
*/
-MODELAPI_EXPORT FeaturePtr findPartFeature(const DocumentPtr& theMain, const DocumentPtr& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> findPartFeature(
+ const std::shared_ptr<ModelAPI_Document>& theMain,
+ const std::shared_ptr<ModelAPI_Document>& theSub);
/*!
* Returns the composite feature - parent of this feature.
* \param theFeature the sub-element of composite
* \returns null if it is not sub-element of composite
*/
-MODELAPI_EXPORT CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_CompositeFeature> compositeOwner(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature);
/*!
* Returns the compsolid result - parent of this result.
* \param theSub the sub-element of comp-solid
* \returns null if it is not sub-element of composite
*/
-MODELAPI_EXPORT ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_ResultCompSolid> compSolidOwner(
+ const std::shared_ptr<ModelAPI_Result>& theSub);
/*!
-* Returns true if the result contains a not empty list of sub results. It processes result compsolid.
+* Returns true if the result contains a not empty list of sub results.
+* It processes result compsolid.
* \param theResult a result object
* \returns boolean value
*/
-MODELAPI_EXPORT bool hasSubResults(const ResultPtr& theResult);
+MODELAPI_EXPORT bool hasSubResults(const std::shared_ptr<ModelAPI_Result>& theResult);
/*!
* Adds the results of the given feature to theResults list: including disabled and sub-results
*/
-MODELAPI_EXPORT void allResults(const FeaturePtr& theFeature, std::list<ResultPtr>& theResults);
+MODELAPI_EXPORT void allResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
/*!
Returns true if there are no parts in the document, which are not activated
*/
MODELAPI_EXPORT bool allDocumentsActivated(std::string& theNotActivatedNames);
-
/*! Removes features from the document
* \param theFeatures a list of features to be removed
* \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
* \return true if at least one feature is removed
*/
-MODELAPI_EXPORT bool removeFeaturesAndReferences(const std::set<FeaturePtr>& theFeatures,
+MODELAPI_EXPORT bool removeFeaturesAndReferences(
+ const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
const bool theFlushRedisplay = false,
const bool theUseComposite = false,
const bool theUseRecursion = true);
* \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
* \return true if at least one feature is removed
*/
-MODELAPI_EXPORT bool removeFeatures(const std::set<FeaturePtr>& theFeatures,
- const bool theFlushRedisplay);
+MODELAPI_EXPORT bool removeFeatures(
+ const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
+ const bool theFlushRedisplay);
/*! Build a map of references for the given set of features
* \param theFeatures a list of features
list are put into the result container. E.g. if theFeatures contains "Sketch_2", map will
contain references to this feature also.
*/
-MODELAPI_EXPORT void findAllReferences(const std::set<FeaturePtr>& theFeatures,
- std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
- const bool theUseComposite = true,
- const bool theUseRecursion = true);
+MODELAPI_EXPORT void findAllReferences(
+ const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
+ std::map<std::shared_ptr<ModelAPI_Feature>,
+ std::set<std::shared_ptr<ModelAPI_Feature> > >& theReferences,
+ const bool theUseComposite = true,
+ const bool theUseRecursion = true);
/*! In the map of references find all features referenced to the source feature
* \param theFeatures a list of features to find references
* \param theReferences a map of all references to the features
* \param theFeaturesRefsTo an out list of referenced features
*/
-MODELAPI_EXPORT void findRefsToFeatures(const std::set<FeaturePtr>& aFeatures,
- const std::map<FeaturePtr, std::set<FeaturePtr> >& aReferences,
- std::set<FeaturePtr>& aFeaturesRefsTo);
+MODELAPI_EXPORT void findRefsToFeatures(
+ const std::set<std::shared_ptr<ModelAPI_Feature> >& aFeatures,
+ const std::map<std::shared_ptr<ModelAPI_Feature>,
+ std::set<std::shared_ptr<ModelAPI_Feature> > >& aReferences,
+ std::set<std::shared_ptr<ModelAPI_Feature> >& aFeaturesRefsTo);
/*! Finds referenced of the feature to objects and collects concealed results.
* \param theFeatures a model feature
* \param theResults container for concealed results. It has no duplications
*/
-MODELAPI_EXPORT void getConcealedResults(const FeaturePtr& theFeature,
- std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
+MODELAPI_EXPORT void getConcealedResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
}
#endif
--- /dev/null
+# The test for correct referencing for Part feature of whole construction result created in PartSet
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOZ"))
+SketchLine_1 = Sketch_1.addLine(-104, 73, 102, 265)
+SketchLine_2 = Sketch_1.addLine(102, 265, 192, -1)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(192, -1, -104, 73)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
+model.do()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "PartSet/Sketch_1")], model.selection("EDGE", "PartSet/Sketch_1/Edge-SketchLine_3"), 360, 0)
+model.end()
+
+assert(model.checkPythonDump())
SET(PROJECT_HEADERS
ModelGeomAlgo.h
ModelGeomAlgo_Point2D.h
+ ModelGeomAlgo_Shape.h
)
SET(PROJECT_SOURCES
ModelGeomAlgo_Point2D.cpp
+ ModelGeomAlgo_Shape.cpp
)
SET(PROJECT_LIBRARIES
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Tools.h>
+#include <ModelGeomAlgo_Shape.h>
+
#include <GeomAPI_ShapeIterator.h>
#include <GeomAlgoAPI_ShapeTools.h>
GeomShapePtr aFeatureShape;
{
std::set<ResultPtr> anEdgeShapes;
- ModelAPI_Tools::shapesOfType(theBaseFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+ ModelGeomAlgo_Shape::shapesOfType(theBaseFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
if (anEdgeShapes.empty())
return;
aFeatureShape = (*anEdgeShapes.begin())->shape();
continue;
if (aFeature.get()) {
std::set<ResultPtr> anEdgeShapes;
- ModelAPI_Tools::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+ ModelGeomAlgo_Shape::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
if (anEdgeShapes.empty())
continue;
ResultPtr aResult = *anEdgeShapes.begin();
if (thePointToAttributeOrObject.find(aProjectedPoint) != thePointToAttributeOrObject.end())
thePointToAttributeOrObject.at(aProjectedPoint).first.push_back(anAttribute);
else {
- //std::list< std::shared_ptr<GeomDataAPI_Point2D> > anAttributes;
- //anAttributes.push_back(anAttribute);
- //thePointToAttributeOrObject.insert(aProjectedPoint, anAttributes);
-
std::list<std::shared_ptr<GeomDataAPI_Point2D> > anAttributes;
std::list<std::shared_ptr<ModelAPI_Object> > anObjects;
anAttributes.push_back(anAttribute);
thePointToAttributeOrObject[aProjectedPoint] = std::make_pair(anAttributes, anObjects);
}
- //thePoints.push_back(aProjectedPoint);
- //theAttributeToPoint[anAttribute] = aProjectedPoint;
}
}
}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModelAPI_Tools.cpp
+// Created: 19 Mar 2017
+// Author: Natalia ERMOLAEVA
+
+#include <GeomAPI_Shape.h>
+
+#include "ModelGeomAlgo_Shape.h"
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
+
+
+#ifdef WIN32
+#pragma warning(disable : 4996) // for sprintf
+#endif
+
+namespace ModelGeomAlgo_Shape
+{
+ void shapesOfType(const FeaturePtr& theFeature,
+ const GeomAPI_Shape::ShapeType& theType,
+ std::set<ResultPtr>& theShapeResults)
+ {
+ theShapeResults.clear();
+ std::list<ResultPtr> aResults = theFeature->results();
+ std::list<ResultPtr>::const_iterator aRIter = aResults.cbegin();
+ for (; aRIter != aResults.cend(); aRIter++) {
+ ResultPtr aResult = *aRIter;
+ GeomShapePtr aShape = aResult->shape();
+ if (aShape.get() && aShape->shapeType() == theType)
+ theShapeResults.insert(aResult);
+ }
+ }
+} // namespace ModelGeomAlgo_Shape
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModelGeomAlgo_Point2D.h
+// Created: 20 Jul 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef ModelGeomAlgo_Shape_H
+#define ModelGeomAlgo_Shape_H
+
+#include "ModelGeomAlgo.h"
+#include "GeomAPI_Shape.h"
+
+#include <set>
+
+class ModelAPI_Feature;
+class ModelAPI_Result;
+
+namespace ModelGeomAlgo_Shape {
+
+ /// Searches Shape results of the feature satisfied the given shape type
+ /// \param theFeature a feature to obtain AttributeRefAttr
+ /// \param theType shape type
+ /// \param theShapeResults a list of results
+ MODELGEOMALGO_EXPORT void shapesOfType(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const GeomAPI_Shape::ShapeType& theType,
+ std::set<std::shared_ptr<ModelAPI_Result> >& theShapeResults);
+}
+
+#endif
#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <GeomAPI_PlanarEdges.h>
#include <Events_InfoMessage.h>
#include <ModelAPI_AttributeValidator.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <GeomAPI_PlanarEdges.h>
#include <Events_InfoMessage.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Object.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
PartSet_WidgetFeaturePointSelector::PartSet_WidgetFeaturePointSelector(QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData)
-: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData), myBaseSelected(false)
+: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData)
{
}
bool PartSet_WidgetFeaturePointSelector::isValidSelection(
const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
{
- return true;
+ return ModuleBase_WidgetShapeSelector::isValidSelection(theValue);
+ //return true;
}
//********************************************************************
Handle(Graphic3d_HighlightStyle) aSStyle = aContext->SelectionStyle();
if (toActivate) {
std::vector<int> aColors;
- aColors = Config_PropManager::color("Visualization", "sketch_entity_color");
+ aColors = Config_PropManager::color("Visualization", "sketch_entity_color");
aColor = Quantity_Color(aColors[0] / 255., aColors[1] / 255., aColors[2] / 255.,
Quantity_TOC_RGB);
myHighlightColor = aHStyle->Color();
mySelectionColor = aSStyle->Color();
-
- aHStyle->SetTransparency(0.5f);
}
else {
aColor = myHighlightColor;
{
ModuleBase_WidgetShapeSelector::activateCustom();
- myBaseSelected = false;
-
myWorkshop->module()->activateCustomPrs(myFeature,
ModuleBase_IModule::CustomizeHighlightedObjects, true);
}
if (theEvent->button() != Qt::LeftButton)
return;
- myBaseSelected = true;
+ // set parameters of preview into parameters of selection in the feature
+ std::shared_ptr<ModelAPI_AttributeReference> aRefSelectedAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ feature()->data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
+ std::shared_ptr<ModelAPI_AttributeReference> aRefPreviewAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
+ aRefSelectedAttr->setValue(aRefPreviewAttr->value());
+
+ std::shared_ptr<GeomDataAPI_Point2D> aPointSelectedAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ feature()->data()->attribute(SketchPlugin_Trim::SELECTED_POINT()));
+ std::shared_ptr<GeomDataAPI_Point2D> aPointPreviewAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
+ aPointSelectedAttr->setValue(aPointPreviewAttr->x(), aPointPreviewAttr->y());
+
+ updateObject(feature());
+
emit focusOutWidget(this);
// we need to deselect base feature for better visibility of selected feature
XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(false);
std::shared_ptr<ModelAPI_AttributeReference> aRef =
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- feature()->data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
aRef->setValue(anObject);
std::shared_ptr<GeomDataAPI_Point2D> anAttributePoint =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- feature()->data()->attribute(SketchPlugin_Trim::ENTITY_POINT()));
+ feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
anAttributePoint->setValue(aX, anY);
// redisplay AIS presentation in viewer
#ifndef HIGHLIGHT_STAYS_PROBLEM
XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(true);
#endif
updateObject(feature());
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+
aFilled = true;
return aFilled;
return QList<ModuleBase_ViewerPrsPtr>();
}
-//********************************************************************
-void PartSet_WidgetFeaturePointSelector::updateSelectionName()
-{
- if (myBaseSelected)
- ModuleBase_WidgetShapeSelector::updateSelectionName();
-}
-
//********************************************************************
bool PartSet_WidgetFeaturePointSelector::setSelection(
QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
virtual ~PartSet_WidgetFeaturePointSelector();
- /// Checks all widget validator if the owner is valid. Firstly it checks custom widget validating,
- /// next, the attribute's validating. It trying on the give selection to current attribute by
- /// setting the value inside and calling validators. After this, the previous attribute value is
- /// restored.The valid/invalid value is cashed.
+ /// Checks all widget validator if the owner is valid. Firstly it checks custom widget
+ /// validating, next, the attribute's validating. It trying on the give selection to current
+ /// attribute by setting the value inside and calling validators. After this, the previous
+ /// attribute value is restored.The valid/invalid value is cashed.
/// \param theValue a selected presentation in the view
/// \return a boolean value
virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
/// \param theEvent a mouse event
virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
- /// Returns values which should be highlighted when the whidget is active
- /// \param theValues a list of presentations
- //virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
-
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// The method is called by the current operation to process the operation preselection.
const bool theToValidate);
/// Fill preselection used in mouseReleased
- //virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected);
virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
ModuleBase_IViewWindow* theWnd,
QMouseEvent* theEvent);
/// a shape. If the attribute do not uses the shape, it is empty
virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
- /// Computes and updates name of selected object in the widget
- virtual void updateSelectionName();
-
protected:
/// The methiod called when widget is activated
virtual void activateCustom();
CompositeFeaturePtr mySketch;
Quantity_Color myHighlightColor;
Quantity_Color mySelectionColor;
- bool myBaseSelected;
};
#endif
\ No newline at end of file
#include <GeomAlgoAPI_ShapeTools.h>
#include <ModelGeomAlgo_Point2D.h>
+#include <ModelGeomAlgo_Shape.h>
#include <ModelGeomAlgo_Point2D.h>
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
// edges on feature
std::set<ResultPtr> anEdgeResults;
- ModelAPI_Tools::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeResults);
+ ModelGeomAlgo_Shape::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeResults);
if (!anEdgeResults.empty()) {
GeomShapePtr aFeatureShape = (*anEdgeResults.begin())->shape();
from TestSketcher import SketcherTestCase
class SketcherSetFillet(SketcherTestCase):
- # TODO: Remove tearDown method to check Python dump in super-class
- def tearDown(self):
- model.end()
- #assert(model.checkPythonDump())
- model.reset()
-
def test_fillet(self):
l1 = self.sketch.addLine(0, 0, 0, 1)
l2 = self.sketch.addLine(0, 1, 1, 1)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Trim::ID());
- fillAttribute(theFeature, aFeature->reference(SketchPlugin_Trim::BASE_OBJECT()));
+ fillAttribute(theFeature, aFeature->reference(SketchPlugin_Trim::SELECTED_OBJECT()));
- AttributePtr anAttribute = aFeature->attribute(SketchPlugin_Trim::ENTITY_POINT());
+ AttributePtr anAttribute = aFeature->attribute(SketchPlugin_Trim::SELECTED_POINT());
if (anAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) {
AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttribute);
fillAttribute(thePositionPoint, aPointAttr);
new SketchPlugin_FilletVertexValidator);
aFactory->registerValidator("SketchPlugin_SplitValidator",
new SketchPlugin_SplitValidator);
+ aFactory->registerValidator("SketchPlugin_TrimValidator",
+ new SketchPlugin_TrimValidator);
aFactory->registerValidator("SketchPlugin_MiddlePointAttr",
new SketchPlugin_MiddlePointAttrValidator);
aFactory->registerValidator("SketchPlugin_ArcTangentPoint",
#include <GeomAPI_XY.h>
#include <GeomDataAPI_Point2D.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelGeomAlgo_Shape.h>
+
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_ConstraintMiddle.h>
#include <SketchPlugin_Circle.h>
void SketchPlugin_Trim::initAttributes()
{
- data()->addAttribute(SketchPlugin_Trim::BASE_OBJECT(), ModelAPI_AttributeReference::typeId());
- data()->addAttribute(ENTITY_POINT(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Trim::SELECTED_OBJECT(),
+ ModelAPI_AttributeReference::typeId());
+ data()->addAttribute(SELECTED_POINT(), GeomDataAPI_Point2D::typeId());
+
+ data()->addAttribute(PREVIEW_POINT(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(PREVIEW_OBJECT(), ModelAPI_AttributeReference::typeId());
+
+ data()->attribute(PREVIEW_POINT())->setIsArgument(false);
+ data()->attribute(SELECTED_POINT())->setIsArgument(false);
+ data()->attribute(PREVIEW_OBJECT())->setIsArgument(false);
+
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), PREVIEW_POINT());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), PREVIEW_OBJECT());
}
-void SketchPlugin_Trim::findShapePoints(std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
+void SketchPlugin_Trim::findShapePoints(const std::string& theObjectAttributeId,
+ const std::string& thePointAttributeId,
+ std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
std::shared_ptr<GeomAPI_Pnt>& aLastPoint)
{
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(theObjectAttributeId));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(ENTITY_POINT()));
+ data()->attribute(thePointAttributeId));
std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
std::shared_ptr<GeomAPI_Pnt> anAttributePnt = sketch()->to3D(anAttributePnt2d->x(),
anAttributePnt2d->y());
if (myCashedShapes.find(aBaseObject) == myCashedShapes.end())
- fillObjectShapes(aBaseObject);
+ fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
const std::set<GeomShapePtr>& aShapes = myCashedShapes[aBaseObject];
if (!aShapes.empty()) {
std::shared_ptr<GeomAPI_Pnt2d> aPoint;
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
if (myObjectToPoints.find(aBaseObject) == myObjectToPoints.end())
- return aPoint;
+ fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
bool aFound = false;
const PointToRefsMap& aRefsMap = myObjectToPoints.at(aBaseObject);
}
}
if (!aFound) {
- // returns an end of the shape to define direction of split if feature's attribute participates
+ // returns an end of the shape to define direction of split if feature's attribute
+ // participates
std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
aPoint = thePoint->to2D(aPlane);
}
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
if(!aBaseObjectAttr->isInitialized()) {
setError("Error: Base object is not initialized.");
return;
/// points of trim
std::shared_ptr<GeomAPI_Pnt> aStartShapePoint, aLastShapePoint;
- findShapePoints(aStartShapePoint, aLastShapePoint);
+ findShapePoints(SELECTED_OBJECT(), SELECTED_POINT(), aStartShapePoint, aLastShapePoint);
std::shared_ptr<GeomAPI_Pnt2d> aStartShapePoint2d = convertPoint(aStartShapePoint);
std::shared_ptr<GeomAPI_Pnt2d> aLastShapePoint2d = convertPoint(aLastShapePoint);
aFurtherCoincidences, aModifiedAttributes);
aFeaturesToDelete.insert(aBaseFeature);
- // as circle is removed, temporary fill this attribute
+ // as circle is removed, erase it from dependencies(arguments) of this feature
+ // otherwise Trim feature will be removed with the circle before
+ // this operation is finished
aBaseObjectAttr->setObject(ResultPtr());
+
+ AttributeReferencePtr aPreviewObjectAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
+ aPreviewObjectAttr->setObject(ResultPtr());
+
}
else if (aKind == SketchPlugin_Line::ID()) {
trimLine(aStartShapePoint2d, aLastShapePoint2d,
}
//
+ if (myObjectToPoints.find(aBaseObject) == myObjectToPoints.end())
+ fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
+
const PointToRefsMap& aRefsMap = myObjectToPoints.at(aBaseObject);
std::set<AttributePoint2DPtr>::const_iterator anIt = aFurtherCoincidences.begin(),
aLast = aFurtherCoincidences.end();
AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious)
{
AISObjectPtr anAIS = thePrevious;
- // feature for trim
- AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
- ObjectPtr aBaseObject = aBaseObjectAttr->value();
- if (!aBaseObject.get())
+
+ std::list<std::shared_ptr<GeomAPI_Shape> > aShapes;
+ GeomShapePtr aPreviewShape = getSubShape(PREVIEW_OBJECT(), PREVIEW_POINT());
+ if (aPreviewShape.get())
+ aShapes.push_back(aPreviewShape);
+ GeomShapePtr aSelectedShape = getSubShape(SELECTED_OBJECT(), SELECTED_POINT());
+ if (aSelectedShape.get())
+ aShapes.push_back(aSelectedShape);
+
+ if (aShapes.empty())
return AISObjectPtr();
- FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
+
+ GeomShapePtr aBaseShape = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
+ if (!aBaseShape.get())
+ return AISObjectPtr();
+
+ if (aBaseShape.get()) {
+ if (!anAIS)
+ anAIS = AISObjectPtr(new GeomAPI_AISObject);
+ anAIS->createShape(aBaseShape);
+
+ std::vector<int> aColor;
+ aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color");
+ double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
+ int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
+ anAIS->setColor(aColor[0], aColor[1], aColor[2]);
+ // width when there is not base object should be extened in several points
+ // in order to see this preview over highlight
+ anAIS->setWidth(aWidth+4);
+ anAIS->setLineStyle(aLineStyle);
+ }
+ else
+ anAIS = AISObjectPtr();
+
+ return anAIS;
+}
+
+GeomShapePtr SketchPlugin_Trim::getSubShape(const std::string& theObjectAttributeId,
+ const std::string& thePointAttributeId)
+{
+ GeomShapePtr aBaseShape;
+
+ AttributeReferencePtr anObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ data()->attribute(theObjectAttributeId));
+ ObjectPtr aBaseObject = anObjectAttr->value();
+ if (!aBaseObject.get())
+ return aBaseShape;
// point on feature
AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(ENTITY_POINT()));
+ data()->attribute(thePointAttributeId));
std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
std::shared_ptr<GeomAPI_Pnt> anAttributePnt = sketch()->to3D(anAttributePnt2d->x(),
anAttributePnt2d->y());
if (myCashedShapes.find(aBaseObject) == myCashedShapes.end())
- fillObjectShapes(aBaseObject);
-
- GeomShapePtr aBaseShape;
+ fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
const std::set<GeomShapePtr>& aShapes = myCashedShapes[aBaseObject];
if (!aShapes.empty()) {
aBaseShape = aShape;
}
}
-
- if (aBaseShape.get()) {
- if (!anAIS)
- anAIS = AISObjectPtr(new GeomAPI_AISObject);
- anAIS->createShape(aBaseShape);
-
- std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
- aBaseFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
-
- bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
- std::vector<int> aColor;
- aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color");
- double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
- int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
- if (isConstruction) {
- aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY();
- aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY();
- }
- anAIS->setColor(aColor[0], aColor[1], aColor[2]);
- // width is extened in several points in order to see this preview over highlight
- anAIS->setWidth(aWidth + 2);
- anAIS->setLineStyle(aLineStyle);
- }
- else
- anAIS = AISObjectPtr();
-
- return anAIS;
+ return aBaseShape;
}
void SketchPlugin_Trim::getFeaturePoints(const FeaturePtr& theFeature,
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- aData->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ aData->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
ResultPtr aBaseFeatureResult = getFeatureResult(aBaseFeature);
{
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
(aBaseFeature->attribute(aModifiedAttribute)));
}
else {
- // result is two lines: start line point - start shape point, last shape point - last line point
+ // result is two lines: start line point - start shape point,
+ // last shape point - last line point
// create second line
FeaturePtr anNewFeature = createLineFeature(aBaseFeature, aLastShapePoint, aLastFeaturePoint);
thePoints.insert(std::dynamic_pointer_cast<GeomDataAPI_Point2D>
{
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
{
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
}
//********************************************************************
-bool SketchPlugin_Trim::useGraphicIntersection() const
-{
- return true;
-}
-
-//********************************************************************
-void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject)
+void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject,
+ const ObjectPtr& theSketch,
+ std::map<ObjectPtr, std::set<GeomShapePtr> >& theCashedShapes,
+ std::map<ObjectPtr, PointToRefsMap>& theObjectToPoints)
{
PointToRefsMap aPointsInfo;
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
std::set<ResultPtr> anEdgeShapes;
// edges on feature
- ModelAPI_Tools::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+ ModelGeomAlgo_Shape::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
if (!anEdgeShapes.empty()) {
GeomShapePtr aFeatureShape = (*anEdgeShapes.begin())->shape();
ModelGeomAlgo_Point2D::getPointsOfReference(aFeature, SketchPlugin_ConstraintCoincidence::ID(),
aRefAttributes, SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID());
// layed on feature coincidences to divide it on several shapes
- SketchPlugin_Sketch* aSketch = sketch();
- std::shared_ptr<ModelAPI_Data> aData = aSketch->data();
+ //SketchPlugin_Sketch* aSketch = sketch();
+ std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
ModelGeomAlgo_Point2D::getPointsInsideShape(aFeatureShape, aRefAttributes, aC->pnt(),
aX->dir(), aY, aPointsInfo);
- // intersection points
- if (useGraphicIntersection()) {
- std::list<FeaturePtr> aFeatures;
- for (int i = 0; i < aSketch->numberOfSubs(); i++) {
- FeaturePtr aFeature = aSketch->subFeature(i);
- if (aFeature.get())
- aFeatures.push_back(aFeature);
- }
- ModelGeomAlgo_Point2D::getPointsIntersectedShape(aFeature, aFeatures, aPointsInfo);
+ std::list<FeaturePtr> aFeatures;
+ CompositeFeaturePtr aSketchComposite =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theSketch);
+ for (int i = 0; i < aSketchComposite->numberOfSubs(); i++) {
+ FeaturePtr aFeature = aSketchComposite->subFeature(i);
+ if (aFeature.get())
+ aFeatures.push_back(aFeature);
}
- GeomAlgoAPI_ShapeTools::splitShape(aFeatureShape, aPointsInfo, aShapes);
- }
- myObjectToPoints[theObject] = aPointsInfo;
- myCashedShapes[theObject] = aShapes;
-}
+ ModelGeomAlgo_Point2D::getPointsIntersectedShape(aFeature, aFeatures, aPointsInfo);
-//********************************************************************
-void SketchPlugin_Trim::attributeChanged(const std::string& theID)
-{
- //data()->addAttribute(SketchPlugin_Trim::BASE_OBJECT(), ModelAPI_AttributeReference::typeId());
- if (theID == SketchPlugin_Trim::BASE_OBJECT()) {
- bool isValidAttribute = false;
- // feature for trim
- AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
- ObjectPtr aBaseObject = aBaseObjectAttr->value();
- if (aBaseObject.get()) {
- FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
- // point on feature
- AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(ENTITY_POINT()));
- std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
- std::shared_ptr<GeomAPI_Pnt> anAttributePnt = sketch()->to3D(anAttributePnt2d->x(),
- anAttributePnt2d->y());
-
- if (myCashedShapes.find(aBaseObject) == myCashedShapes.end())
- fillObjectShapes(aBaseObject);
-
- const std::set<GeomShapePtr>& aShapes = myCashedShapes[aBaseObject];
- isValidAttribute = !aShapes.empty();
-
- if (!isValidAttribute) {
- bool aWasBlocked = data()->blockSendAttributeUpdated(true);
- aBaseObjectAttr->setValue(ObjectPtr());
- data()->blockSendAttributeUpdated(aWasBlocked);
- }
- }
+ GeomAlgoAPI_ShapeTools::splitShape(aFeatureShape, aPointsInfo, aShapes);
}
+ theObjectToPoints[theObject] = aPointsInfo;
+ theCashedShapes[theObject] = aShapes;
}
class GeomDataAPI_Point2D;
class ModelAPI_Feature;
class ModelAPI_Result;
+class ModelAPI_Object;
typedef std::pair<std::string, std::shared_ptr<GeomDataAPI_Point2D> > IdToPointPair;
}
/// The value parameter for the constraint
- inline static const std::string& BASE_OBJECT()
+ inline static const std::string& SELECTED_OBJECT()
{
- static const std::string MY_CONSTRAINT_BASE_OBJECT("BaseObject");
- return MY_CONSTRAINT_BASE_OBJECT;
+ static const std::string MY_SELECTED_OBJECT("SelectedObject");
+ return MY_SELECTED_OBJECT;
}
/// Start 2D point of the split segment
- inline static const std::string& ENTITY_POINT()
+ inline static const std::string& SELECTED_POINT()
{
- static const std::string MY_ENTITY_POINT("ConstraintEntityPoint");
- return MY_ENTITY_POINT;
+ static const std::string MY_SELECTED_POINT("SelectedPoint");
+ return MY_SELECTED_POINT;
+ }
+
+ /// The value parameter for the preview object
+ inline static const std::string& PREVIEW_OBJECT()
+ {
+ static const std::string MY_PREVIEW_OBJECT("PreviewObject");
+ return MY_PREVIEW_OBJECT;
+ }
+
+ /// Start 2D point of the split segment
+ inline static const std::string& PREVIEW_POINT()
+ {
+ static const std::string MY_PREVIEW_POINT("PreviewPoint");
+ return MY_PREVIEW_POINT;
}
/// \brief Creates a new part document if needed
/// This is necessary to perform execute only by apply the feature
SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
- /// Called on change of any argument-attribute of this object
- /// \param theID identifier of changed attribute
- SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
-
/// \brief Use plugin manager for features creation
SketchPlugin_Trim();
/// Moves the feature : Empty
SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
+ typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
+ std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
+ std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
+
+ static void fillObjectShapes(const std::shared_ptr<ModelAPI_Object>& theObject,
+ const std::shared_ptr<ModelAPI_Object>& theSketch,
+ std::map<std::shared_ptr<ModelAPI_Object>, std::set<GeomShapePtr> >& theCashedShapes,
+ std::map<std::shared_ptr<ModelAPI_Object>, PointToRefsMap>& theObjectToPoints);
+
private:
+ GeomShapePtr getSubShape(const std::string& theObjectAttributeId,
+ const std::string& thePointAttributeId);
+
/// Returns geom point attribute of the feature bounds. It processes line or arc.
/// For circle feature, the result attributes are null
/// \param theFeature a source feature
/// by the coincident attribute
/// \param theObject an investigated object
/// \param theCoincidencesToBaseFeature a container of list of referenced attributes
- void getCoincidencesToObject(const ObjectPtr& theObject,
+ void getCoincidencesToObject(const std::shared_ptr<ModelAPI_Object>& theObject,
std::map<AttributePtr, FeaturePtr>& theCoincidencesToBaseFeature);
/// Move constraints from attribute of base feature to attribute after modification
const std::shared_ptr<ModelAPI_Feature>& theFeature);
private:
- bool useGraphicIntersection() const;
-
- void fillObjectShapes(const ObjectPtr& theObject);
-
- void findShapePoints(std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
+ void findShapePoints(const std::string& theObjectAttributeId,
+ const std::string& thePointAttributeId,
+ std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
std::shared_ptr<GeomAPI_Pnt>& aLastPoint);
std::shared_ptr<GeomAPI_Pnt2d> convertPoint(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
private:
- std::map<ObjectPtr, std::set<GeomShapePtr> > myCashedShapes;
-
- typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
- std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
- std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
-
- std::map<ObjectPtr, PointToRefsMap> myObjectToPoints;
+ std::map<std::shared_ptr<ModelAPI_Object>, std::set<GeomShapePtr> > myCashedShapes;
+ std::map<std::shared_ptr<ModelAPI_Object>, PointToRefsMap> myObjectToPoints;
};
#endif
#include "SketchPlugin_Line.h"
#include "SketchPlugin_Point.h"
#include "SketchPlugin_Sketch.h"
+#include "SketchPlugin_Trim.h"
#include "SketchPlugin_Tools.h"
#include "SketcherPrs_Tools.h"
#include <ModelAPI_ResultConstruction.h>
#include <ModelGeomAlgo_Point2D.h>
+#include <ModelGeomAlgo_Shape.h>
#include <GeomAPI_Circ.h>
#include <GeomAPI_Lin.h>
aKind == SketchPlugin_Circle::ID()) {
std::set<ResultPtr> anEdgeShapes;
- ModelAPI_Tools::shapesOfType(anAttrFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+ ModelGeomAlgo_Shape::shapesOfType(anAttrFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
if (anEdgeShapes.empty() || anEdgeShapes.size() > 1 /*there case has not existed yet*/)
return aValid;
return aValid;
}
+bool SketchPlugin_TrimValidator::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ bool aValid = false;
+
+ if (theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) {
+ theError = "The attribute with the %1 type is not processed";
+ theError.arg(theAttribute->attributeType());
+ return aValid;
+ }
+ AttributeReferencePtr aBaseObjectAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+
+ std::shared_ptr<SketchPlugin_Feature> aTrimFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
+
+ ObjectPtr aBaseObject = aBaseObjectAttr->value();
+ if (!aBaseObject) {
+ AttributePtr aPreviewAttr = aTrimFeature->attribute(SketchPlugin_Trim::PREVIEW_OBJECT());
+ aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(aPreviewAttr);
+ aBaseObject = aBaseObjectAttr->value();
+
+ //return aValid;
+ }
+
+ FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObject);
+ if (!aBaseFeature)
+ return aValid;
+
+ std::string aKind = aBaseFeature->getKind();
+ if (aKind != SketchPlugin_Line::ID() &&
+ aKind != SketchPlugin_Arc::ID() &&
+ aKind != SketchPlugin_Circle::ID())
+ return aValid;
+
+ // point on feature
+ AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aTrimFeature->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
+
+ SketchPlugin_Sketch* aSketch = aTrimFeature->sketch();
+
+ std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
+ std::shared_ptr<GeomAPI_Pnt> anAttributePnt = aSketch->to3D(anAttributePnt2d->x(),
+ anAttributePnt2d->y());
+
+ std::map<ObjectPtr, std::set<GeomShapePtr> > aCashedShapes;
+ std::map<ObjectPtr, std::map<std::shared_ptr<GeomAPI_Pnt>,
+ std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
+ std::list<std::shared_ptr<ModelAPI_Object> > > > > anObjectToPoints;
+ SketchPlugin_Trim::fillObjectShapes(aBaseObject, aSketch->data()->owner(),
+ aCashedShapes, anObjectToPoints);
+ const std::set<GeomShapePtr>& aShapes = aCashedShapes[aBaseObject];
+
+ return aShapes.size() > 1;
+}
+
bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
Events_InfoMessage& theError) const;
};
+/**\class SketchPlugin_TrimValidator
+ * \ingroup Validators
+ * \brief Validator for the entity of the following type:
+ * - Linear segment with point(s) coinident to this line or intersected it
+ * - Arc with point(s) coincident to the arc or intersected it
+ * - Circle with at least 2 split-points on this circle or intersected it
+ *
+ * Checks that there are coincident point on selected feature.
+ */
+class SketchPlugin_TrimValidator : public ModelAPI_AttributeValidator
+{
+ public:
+ //! returns true if attribute is valid
+ //! \param theAttribute the checked attribute
+ //! \param theArguments arguments of the attribute
+ //! \param theError error message
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const;
+};
+
/**\class SketchPlugin_IntersectionValidator
* \ingroup Validators
* \brief Validator for the attribute to be intersected with the sketch plane.
assert (math.fabs(aLine2Len - anExtLineLen) < 1.e-10)
assert (model.dof(aSketchFeature) == 12)
#=========================================================================
+# Remove costraint to check the DOF
+#=========================================================================
+aSession.startOperation()
+aDocument.removeFeature(aConstraintEqLen2)
+aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 13)
+#=========================================================================
# End of test
#=========================================================================
# Verify the objects of fillet are created
#=========================================================================
checkSmoothness(aSketchFeature)
-assert model.dof(aSketchFeature) == 14, "PlaneGCS limitation: if you see this message, then maybe PlaneGCS has solved DoF for sketch with fillet correctly (expected DoF = 10, observed = {0}".format(model.dof(aSketchFeature))
+assert (model.dof(aSketchFeature) == 10)
+#=========================================================================
+# Move a line and check the fillet is correct
+#=========================================================================
+DELTA_X = DELTA_Y = 10.
+aSession.startOperation()
+aEndPoint1.setValue(aEndPoint1.x() + DELTA_X, aEndPoint1.y() + DELTA_Y)
+aSession.finishOperation()
+checkSmoothness(aSketchFeature)
+assert (model.dof(aSketchFeature) == 10)
+
#=========================================================================
# Create another sketch
# Verify the objects of fillet are created
#=========================================================================
checkSmoothness(aSketchFeature)
-assert model.dof(aSketchFeature) == 10, "PlaneGCS limitation: if you see this message, then maybe PlaneGCS has solved DoF for sketch with fillet correctly (expected DoF = 8, observed = {0}".format(model.dof(aSketchFeature))
+assert (model.dof(aSketchFeature) == 8)
+#=========================================================================
+# Move a line and check the fillet is correct
+#=========================================================================
+DELTA_X = 1.
+DELTA_Y = -2.
+aSession.startOperation()
+aStartPoint1.setValue(aStartPoint1.x() + DELTA_X, aStartPoint1.y() + DELTA_Y)
+aSession.finishOperation()
+checkSmoothness(aSketchFeature)
+assert (model.dof(aSketchFeature) == 8)
#=========================================================================
# End of test
#=========================================================================
# TODO: Improve Fillet test case by moving one of filleted objectes and check coincidence and tangency are correct
-# TODO: Checking of Python dump has been disabled until the Fillet redesigned.
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
def tearDown(self):
model.end()
- # TODO: Revert commented line to check Python dump
- #self.assertTrue(model.checkPythonDump())
+ self.assertTrue(model.checkPythonDump())
model.reset()
return [aFeatureA, aFeatureB]
- @unittest.expectedFailure
def test_fillet_two_lines(self):
""" Test 1. Fillet on two connected lines
"""
# remove fillet for correct python dump
self.myDocument.removeFeature(aFillet.feature())
- @unittest.expectedFailure
def test_fillet_arc_line(self):
""" Test 3. Fillet on connected arc and line
"""
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_two_arcs(self):
""" Test 4. Fillet on two connected arcs
"""
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_with_horizontal_vertical(self):
""" Test 5. Fillet on two connected lines in case of Horizontal or Vertical constraints applied
"""
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_with_orthogonal(self):
""" Test 6. Fillet on two connected lines in case of Perpendicular constraint applied
"""
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_with_parallel(self):
""" Test 7. Fillet on two connected lines in case of Parallel constraint applied
"""
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [4])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [8])
- @unittest.expectedFailure
def test_fillet_with_equal_lines(self):
""" Test 8. Fillet on two connected lines in case of Equal constraint applied
"""
model.do()
self.checkDOF()
self.mySketch.setFillet(aSketchLineA.startPoint())
- self.myDOF += 2
+ self.myDOF += 2 # Equal has been removed
model.do()
self.checkFillet()
self.checkDOF()
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_with_equal_arcs(self):
""" Test 9. Fillet on two connected arcs in case of Equal constraint applied
"""
model.do()
self.checkDOF()
self.mySketch.setFillet(aSketchArc1.endPoint())
- self.myDOF += 1
+ self.myDOF += 2 # Equal has been removed
model.do()
self.checkFillet()
self.checkDOF()
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_with_length(self):
""" Test 10. Fillet on two connected lines in case of Length constraint applied
"""
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_with_radius(self):
""" Test 11. Fillet on connected arc and line in case of Radius constraint is applied to arc
"""
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_with_distance(self):
""" Test 12. Fillet on two connected lines in case of Distance constraint applied
"""
model.do()
self.checkDOF()
self.mySketch.setFillet(aSketchLineA.startPoint())
- self.myDOF += 1
+ self.myDOF += 2 # Distance has been removed
model.do()
self.checkFillet()
self.checkDOF()
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [4])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [8])
- @unittest.expectedFailure
def test_fillet_with_fixed_point(self):
""" Test 13. Fillet on two connected lines in case of Fixed constraint applied to the fillet point
"""
model.do()
self.checkDOF()
self.mySketch.setFillet(aSketchLineA.startPoint())
- self.myDOF += 1
+ self.myDOF += 3 # Fixed constraint has been removed
model.do()
self.checkFillet()
self.checkDOF()
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_with_fixed_line(self):
""" Test 14. Fillet on two connected lines in case of Fixed constraint applied to one of lines
"""
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
- @unittest.expectedFailure
def test_fillet_with_angle(self):
""" Test 15. Fillet on two connected lines in case of Perpendicular constraint applied
"""
model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
-# TODO: Remove unittest.expectedFailure if the Tangency in PlaneGCS will be updated
if __name__ == '__main__':
unittest.main()
<toolbox id="ArcType">
<box id="CenterStartEnd" title="Center and two points" icon="icons/Sketch/arc_base_32x32.png">
<sketch-2dpoint_selector id="ArcCenter" accept_expressions="0" title="Center" tooltip="Center of a circle"
- enable_value="enable_by_preferences" />
+ enable_value="enable_by_preferences" reference_attribute="ArcCenterRef" />
<!--reference_attribute="ArcCenterRef" />-->
<sketch-2dpoint_selector id="ArcStartPoint" accept_expressions="0" title="Start point" tooltip="Start point"
enable_value="enable_by_preferences"/>
tooltip="Trim selected segment arc or circle on intersection points nearest to the graphic selection"
icon="icons/Sketch/trim.png">
<sketch_feature_point_selector
- id="BaseObject"
+ id="SelectedObject"
label="Split feature"
tooltip="Select feature for split"
shape_types="edge"
use_external="false"
use_graphic_intersection="true">
- <!--<validator id="SketchPlugin_SplitValidator" parameters="use_graphic_intersection"/> -->
+ <validator id="SketchPlugin_TrimValidator"/>
</sketch_feature_point_selector>
<validator id="PartSet_SplitSelection"/>
</feature>
INCLUDE(Common)
SET(SKETCHSOLVER_HEADERS
- SketchSolver.h
SketchSolver_Error.h
SketchSolver_Group.h
- SketchSolver_IConstraintWrapper.h
- SketchSolver_IEntityWrapper.h
SketchSolver_Manager.h
SketchSolver_Storage.h
)
PlaneGCSSolver_Solver.h
PlaneGCSSolver_Storage.h
PlaneGCSSolver_ConstraintWrapper.h
- PlaneGCSSolver_EntityWrapper.h
+ PlaneGCSSolver_EdgeWrapper.h
+ PlaneGCSSolver_EdgeWrapper.h
PlaneGCSSolver_PointWrapper.h
PlaneGCSSolver_ScalarWrapper.h
PlaneGCSSolver_AngleWrapper.h
PlaneGCSSolver_Solver.cpp
PlaneGCSSolver_Storage.cpp
PlaneGCSSolver_ConstraintWrapper.cpp
- PlaneGCSSolver_EntityWrapper.cpp
+ PlaneGCSSolver_EdgeWrapper.cpp
PlaneGCSSolver_PointWrapper.cpp
PlaneGCSSolver_ScalarWrapper.cpp
PlaneGCSSolver_AngleWrapper.cpp
#define PlaneGCSSolver_ConstraintWrapper_H_
#include <PlaneGCSSolver_Defs.h>
-#include <PlaneGCSSolver_Solver.h>
#include <PlaneGCSSolver_ScalarWrapper.h>
-#include <SketchSolver_IConstraintWrapper.h>
-
/**
* Wrapper providing operations with PlaneGCS constraints.
*/
-class PlaneGCSSolver_ConstraintWrapper : public SketchSolver_IConstraintWrapper
+class PlaneGCSSolver_ConstraintWrapper
{
public:
PlaneGCSSolver_ConstraintWrapper(const GCSConstraintPtr& theConstraint,
void setConstraints(const std::list<GCSConstraintPtr>& theConstraints)
{ myGCSConstraints = theConstraints; }
+ /// \brief Return ID of current constraint
+ const ConstraintID& id() const
+ { return myID; }
/// \brief Change constraint ID
virtual void setId(const ConstraintID& theID);
{ return myValueParam; }
private:
+ ConstraintID myID;
SketchSolver_ConstraintType myType;
ScalarWrapperPtr myValueParam;
std::list<GCSConstraintPtr> myGCSConstraints;
};
+typedef std::shared_ptr<PlaneGCSSolver_ConstraintWrapper> ConstraintWrapperPtr;
+
#endif
#ifndef PlaneGCSSolver_Defs_H_
#define PlaneGCSSolver_Defs_H_
-#include <SketchSolver.h>
-
#include <Constraints.h>
#include <Geo.h>
#include <memory>
typedef std::shared_ptr<GCS::Curve> GCSCurvePtr;
typedef std::shared_ptr<GCS::Constraint> GCSConstraintPtr;
+// Tolerance for value of parameters
+const double tolerance = 1.e-10;
+
+#define PI 3.1415926535897932
+
+// Types for data entities enumeration
+typedef int ConstraintID;
+
+// Predefined values for identifiers
+const ConstraintID CID_UNKNOWN = 0;
+const ConstraintID CID_MOVEMENT = -1;
+
+/// Types of entities
+enum SketchSolver_EntityType {
+ ENTITY_UNKNOWN = 0,
+ ENTITY_SCALAR,
+ ENTITY_ANGLE,
+ ENTITY_POINT,
+ ENTITY_LINE,
+ ENTITY_CIRCLE,
+ ENTITY_ARC
+};
+
+/// Types of constraints
+enum SketchSolver_ConstraintType {
+ CONSTRAINT_UNKNOWN = 0,
+ CONSTRAINT_COINCIDENCE, // base coincidence if we don't know exact type yet
+ CONSTRAINT_PT_PT_COINCIDENT,
+ CONSTRAINT_PT_ON_LINE,
+ CONSTRAINT_PT_ON_CIRCLE,
+ CONSTRAINT_MIDDLE_POINT,
+ CONSTRAINT_DISTANCE, // base distance if we don't know the measured objects yet
+ CONSTRAINT_PT_PT_DISTANCE,
+ CONSTRAINT_PT_LINE_DISTANCE,
+ CONSTRAINT_RADIUS,
+ CONSTRAINT_ANGLE,
+ CONSTRAINT_FIXED,
+ CONSTRAINT_HORIZONTAL,
+ CONSTRAINT_VERTICAL,
+ CONSTRAINT_PARALLEL,
+ CONSTRAINT_PERPENDICULAR,
+ CONSTRAINT_SYMMETRIC,
+ CONSTRAINT_EQUAL, // base equality if we don't know the measured objects yet
+ CONSTRAINT_EQUAL_LINES,
+ CONSTRAINT_EQUAL_LINE_ARC,
+ CONSTRAINT_EQUAL_RADIUS,
+ CONSTRAINT_TANGENT, // base tangency if we don't know the measured objects yet
+ CONSTRAINT_TANGENT_CIRCLE_LINE,
+ CONSTRAINT_TANGENT_CIRCLE_CIRCLE,
+ CONSTRAINT_COLLINEAR,
+ CONSTRAINT_MULTI_TRANSLATION,
+ CONSTRAINT_MULTI_ROTATION
+};
+
#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PlaneGCSSolver_EdgeWrapper.cpp
+// Created: 14 Dec 2015
+// Author: Artem ZHIDKOV
+
+#include <PlaneGCSSolver_EdgeWrapper.h>
+
+PlaneGCSSolver_EdgeWrapper::PlaneGCSSolver_EdgeWrapper(const GCSCurvePtr theEntity)
+ : myEntity(theEntity)
+{
+ std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(myEntity);
+ if (aLine) myType = ENTITY_LINE;
+ else {
+ std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(myEntity);
+ if (anArc) myType = ENTITY_ARC;
+ else {
+ std::shared_ptr<GCS::Circle> aCircle = std::dynamic_pointer_cast<GCS::Circle>(myEntity);
+ if (aCircle) myType = ENTITY_CIRCLE;
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PlaneGCSSolver_EdgeWrapper.h
+// Created: 14 Dec 2015
+// Author: Artem ZHIDKOV
+
+#ifndef PlaneGCSSolver_EdgeWrapper_H_
+#define PlaneGCSSolver_EdgeWrapper_H_
+
+#include <PlaneGCSSolver_Defs.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
+
+/**
+ * Wrapper providing operations with PlaneGCS entities (lines, circles and arcs).
+ */
+class PlaneGCSSolver_EdgeWrapper : public PlaneGCSSolver_EntityWrapper
+{
+public:
+ PlaneGCSSolver_EdgeWrapper(const GCSCurvePtr theEntity);
+
+ /// \brief Return PlaneGCS geometric entity
+ const GCSCurvePtr& entity() const
+ { return myEntity; }
+ /// \brief Return PlaneGCS geometric entity to change
+ GCSCurvePtr& changeEntity()
+ { return myEntity; }
+
+ /// \brief Return type of current entity
+ virtual SketchSolver_EntityType type() const
+ { return myType; }
+
+private:
+ SketchSolver_EntityType myType;
+ GCSCurvePtr myEntity;
+};
+
+typedef std::shared_ptr<PlaneGCSSolver_EdgeWrapper> EdgeWrapperPtr;
+
+#endif
#include <PlaneGCSSolver_PointWrapper.h>
#include <PlaneGCSSolver_ScalarWrapper.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
static void destroyScalar(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
{
static void destroyLine(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
{
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
- std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+ std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(anEntity->entity());
theParams.insert(aLine->p1.x);
theParams.insert(aLine->p1.y);
static void destroyCircle(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
{
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
- std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+ std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
std::shared_ptr<GCS::Circle> aCirc = std::dynamic_pointer_cast<GCS::Circle>(anEntity->entity());
theParams.insert(aCirc->center.x);
theParams.insert(aCirc->center.y);
static void destroyArc(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
{
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
- std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+ std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anEntity->entity());
theParams.insert(anArc->center.x);
theParams.insert(anArc->center.y);
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: PlaneGCSSolver_EntityWrapper.cpp
-// Created: 14 Dec 2015
-// Author: Artem ZHIDKOV
-
-#include <PlaneGCSSolver_EntityWrapper.h>
-
-PlaneGCSSolver_EntityWrapper::PlaneGCSSolver_EntityWrapper(const GCSCurvePtr theEntity)
- : myEntity(theEntity)
-{
- std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(myEntity);
- if (aLine) myType = ENTITY_LINE;
- else {
- std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(myEntity);
- if (anArc) myType = ENTITY_ARC;
- else {
- std::shared_ptr<GCS::Circle> aCircle = std::dynamic_pointer_cast<GCS::Circle>(myEntity);
- if (aCircle) myType = ENTITY_CIRCLE;
- }
- }
-}
// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
// File: PlaneGCSSolver_EntityWrapper.h
-// Created: 14 Dec 2015
+// Created: 30 Nov 2015
// Author: Artem ZHIDKOV
#ifndef PlaneGCSSolver_EntityWrapper_H_
#define PlaneGCSSolver_EntityWrapper_H_
#include <PlaneGCSSolver_Defs.h>
-#include <SketchSolver_IEntityWrapper.h>
+
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_Feature.h>
+
+#include <list>
+#include <memory>
/**
- * Wrapper providing operations with PlaneGCS entities (lines, circles and arcs).
+ * Wrapper providing operations with entities regardless the solver.
*/
-class PlaneGCSSolver_EntityWrapper : public SketchSolver_IEntityWrapper
+class PlaneGCSSolver_EntityWrapper
{
public:
- PlaneGCSSolver_EntityWrapper(const GCSCurvePtr theEntity);
-
- /// \brief Return PlaneGCS geometric entity
- const GCSCurvePtr& entity() const
- { return myEntity; }
- /// \brief Return PlaneGCS geometric entity to change
- GCSCurvePtr& changeEntity()
- { return myEntity; }
+ PlaneGCSSolver_EntityWrapper() : myExternal(false) {}
+ virtual ~PlaneGCSSolver_EntityWrapper() {}
/// \brief Return type of current entity
- virtual SketchSolver_EntityType type() const
- { return myType; }
+ virtual SketchSolver_EntityType type() const = 0;
+
+ /// \brief Change flag indicating the entity cannot be changed in the solver
+ void setExternal(bool theExternal) { myExternal = theExternal; }
+ /// \brief Return the External flag
+ bool isExternal() const { return myExternal; }
private:
- SketchSolver_EntityType myType;
- GCSCurvePtr myEntity;
+ bool myExternal;
};
+typedef std::shared_ptr<PlaneGCSSolver_EntityWrapper> EntityWrapperPtr;
+
#endif
// Author: Artem ZHIDKOV
#include <PlaneGCSSolver_FeatureBuilder.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
#include <PlaneGCSSolver_PointWrapper.h>
#include <PlaneGCSSolver_ScalarWrapper.h>
aNewLine->p2 = *(aPoint->point());
}
- return EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(aNewLine));
+ return EntityWrapperPtr(new PlaneGCSSolver_EdgeWrapper(aNewLine));
}
EntityWrapperPtr createCircle(const AttributeEntityMap& theAttributes)
}
}
- return EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(aNewCircle));
+ return EntityWrapperPtr(new PlaneGCSSolver_EdgeWrapper(aNewCircle));
}
static double* createParameter(PlaneGCSSolver_Storage* theStorage)
aNewArc->center, aNewArc->end, aNewArc->endAngle)));
}
- return EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(aNewArc));
+ return EntityWrapperPtr(new PlaneGCSSolver_EdgeWrapper(aNewArc));
}
bool isAttributeApplicable(const std::string& theAttrName, const std::string& theOwnerName)
#define PlaneGCSSolver_PointWrapper_H_
#include <PlaneGCSSolver_Defs.h>
-#include <SketchSolver_IEntityWrapper.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
/**
* Wrapper providing operations with PlaneGCS points.
*/
-class PlaneGCSSolver_PointWrapper : public SketchSolver_IEntityWrapper
+class PlaneGCSSolver_PointWrapper : public PlaneGCSSolver_EntityWrapper
{
public:
PlaneGCSSolver_PointWrapper(const GCSPointPtr thePoint);
GCSPointPtr myPoint;
};
+typedef std::shared_ptr<PlaneGCSSolver_PointWrapper> PointWrapperPtr;
+
#endif
#define PlaneGCSSolver_ScalarWrapper_H_
#include <PlaneGCSSolver_Defs.h>
-#include <SketchSolver_IEntityWrapper.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
/**
* Wrapper providing operations with PlaneGCS scalars.
*/
-class PlaneGCSSolver_ScalarWrapper : public SketchSolver_IEntityWrapper
+class PlaneGCSSolver_ScalarWrapper : public PlaneGCSSolver_EntityWrapper
{
public:
PlaneGCSSolver_ScalarWrapper(double *const theParam);
myDOF = 0;
}
-void PlaneGCSSolver_Solver::addConstraint(GCSConstraintPtr theConstraint,
- const SketchSolver_ConstraintType theType)
+void PlaneGCSSolver_Solver::addConstraint(GCSConstraintPtr theConstraint)
{
myEquationSystem->addConstraint(theConstraint.get());
myConstraints[theConstraint->getTag()].insert(theConstraint);
myDOF = -1;
-
- // Workaround: avoid tangent constraint in the list of redundant
- if (theType == CONSTRAINT_TANGENT_CIRCLE_LINE ||
- theType == CONSTRAINT_TANGENT_CIRCLE_CIRCLE ||
- theType == CONSTRAINT_PT_PT_COINCIDENT ||
- theType == CONSTRAINT_PT_ON_CIRCLE ||
- theType == CONSTRAINT_PT_ON_LINE)
- myConstraintIDsNotRedundant.insert(theConstraint->getTag());
}
void PlaneGCSSolver_Solver::removeConstraint(ConstraintID theID)
{
myConstraints.erase(theID);
- myConstraintIDsNotRedundant.erase(theID);
if (myConstraints.empty()) {
myEquationSystem->clear();
myDOF = (int)myParameters.size();
myConflictingIDs.insert(aConflict.begin(), aConflict.end());
myEquationSystem->getRedundant(aConflict);
- // Workaround: avoid conflicting tangent constraints
- GCS::VEC_I aTemp = aConflict;
- aConflict.clear();
- for (GCS::VEC_I::iterator anIt = aTemp.begin(); anIt != aTemp.end(); ++anIt)
- if (myConstraintIDsNotRedundant.find(*anIt) == myConstraintIDsNotRedundant.end())
- aConflict.push_back(*anIt);
myConflictingIDs.insert(aConflict.begin(), aConflict.end());
myConfCollected = true;
#ifndef PlaneGCSSolver_Solver_H_
#define PlaneGCSSolver_Solver_H_
-#include <SketchSolver_IConstraintWrapper.h>
#include <PlaneGCSSolver_Defs.h>
+#include <PlaneGCSSolver_ConstraintWrapper.h>
#include <GCS.h>
void clear();
/// \brief Add constraint to the system of equations
- void addConstraint(GCSConstraintPtr theConstraint, const SketchSolver_ConstraintType theType);
+ void addConstraint(GCSConstraintPtr theConstraint);
/// \brief Remove constraint from the system of equations
void removeConstraint(ConstraintID theID);
GCS::VEC_pD myParameters; ///< list of unknowns
ConstraintMap myConstraints; ///< list of constraints
- /// IDs of constraints (coincidence, tangency) which will not be treated as conflicting
- /// if they are reported as redundant
- GCS::SET_I myConstraintIDsNotRedundant;
-
std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints
#include <PlaneGCSSolver_Storage.h>
#include <PlaneGCSSolver_Solver.h>
#include <PlaneGCSSolver_ConstraintWrapper.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
#include <PlaneGCSSolver_PointWrapper.h>
#include <PlaneGCSSolver_AttributeBuilder.h>
std::dynamic_pointer_cast<PlaneGCSSolver_ConstraintWrapper>(theConstraint)->constraints();
std::list<GCSConstraintPtr>::const_iterator anIt = aConstraints.begin();
for (; anIt != aConstraints.end(); ++anIt)
- theSolver->addConstraint(*anIt, theConstraint->type());
+ theSolver->addConstraint(*anIt);
}
if (aRelated && aRelated->type() == ENTITY_ARC) {
/// TODO: this code should be shared with FeatureBuilder somehow
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
- std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(aRelated);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+ std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(aRelated);
std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anEntity->entity());
static std::shared_ptr<GeomAPI_Dir2d> OX(new GeomAPI_Dir2d(1.0, 0.0));
std::map<ConstraintPtr, ConstraintWrapperPtr>::iterator
aFound = myConstraintMap.find(theConstraint);
if (aFound != myConstraintMap.end()) {
- ConstraintID anID = aFound->second->id();
+ ConstraintWrapperPtr aCW = aFound->second;
+ ConstraintID anID = aCW->id();
+
// Remove solver's constraints
mySketchSolver->removeConstraint(anID);
+
+ // Remove value if exists
+ const ScalarWrapperPtr& aValue = aCW->valueParameter();
+ if (aValue) {
+ GCS::SET_pD aParToRemove;
+ aParToRemove.insert(aValue->scalar());
+ removeParameters(aParToRemove);
+ }
+
// Remove constraint
myConstraintMap.erase(aFound);
for (; aFIter != myFeatureMap.end(); aFIter++)
if (!aFIter->first->data() || !aFIter->first->data()->isValid()) {
anInvalidFeatures.push_back(aFIter->first);
- aDestroyer.remove(aFIter->second);
+ if (aFIter->second)
+ aDestroyer.remove(aFIter->second);
// remove invalid arc
std::map<EntityWrapperPtr, ConstraintWrapperPtr>::iterator
#define PlaneGCSSolver_Storage_H_
#include <PlaneGCSSolver_Defs.h>
-
-#include <SketchSolver.h>
#include <SketchSolver_Storage.h>
class PlaneGCSSolver_EntityBuilder;
// Author: Artem ZHIDKOV
#include <PlaneGCSSolver_Tools.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
#include <PlaneGCSSolver_PointWrapper.h>
#include <PlaneGCSSolver_ScalarWrapper.h>
#include <PlaneGCSSolver_ConstraintWrapper.h>
#include <cmath>
-#define GCS_ENTITY_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(x)
+#define GCS_EDGE_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(x)
#define GCS_POINT_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(x)
#define GCS_SCALAR_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(x)
static ConstraintWrapperPtr
createConstraintPointOnEntity(const SketchSolver_ConstraintType& theType,
std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
static ConstraintWrapperPtr
createConstraintDistancePointPoint(std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint1,
static ConstraintWrapperPtr
createConstraintDistancePointLine(std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
static ConstraintWrapperPtr
createConstraintRadius(std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
static ConstraintWrapperPtr
createConstraintAngle(ConstraintPtr theConstraint,
std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2);
static ConstraintWrapperPtr
createConstraintHorizVert(const SketchSolver_ConstraintType& theType,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
static ConstraintWrapperPtr
- createConstraintParallel(std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2);
+ createConstraintParallel(std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2);
static ConstraintWrapperPtr
- createConstraintPerpendicular(std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2);
+ createConstraintPerpendicular(std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2);
static ConstraintWrapperPtr
createConstraintEqual(const SketchSolver_ConstraintType& theType,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2,
std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theIntermed);
-static ConstraintWrapperPtr
- createConstraintTangent(const SketchSolver_ConstraintType& theType,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2);
static ConstraintWrapperPtr
createConstraintMiddlePoint(std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
break;
case CONSTRAINT_PT_ON_LINE:
case CONSTRAINT_PT_ON_CIRCLE:
- aResult = createConstraintPointOnEntity(theType, aPoint1, GCS_ENTITY_WRAPPER(theEntity1));
+ aResult = createConstraintPointOnEntity(theType, aPoint1, GCS_EDGE_WRAPPER(theEntity1));
break;
case CONSTRAINT_MIDDLE_POINT:
- aResult = createConstraintMiddlePoint(aPoint1, GCS_ENTITY_WRAPPER(theEntity1));
+ aResult = createConstraintMiddlePoint(aPoint1, GCS_EDGE_WRAPPER(theEntity1));
break;
case CONSTRAINT_PT_PT_DISTANCE:
aResult = createConstraintDistancePointPoint(GCS_SCALAR_WRAPPER(theValue), aPoint1, aPoint2);
case CONSTRAINT_PT_LINE_DISTANCE:
aResult = createConstraintDistancePointLine(GCS_SCALAR_WRAPPER(theValue),
aPoint1,
- GCS_ENTITY_WRAPPER(theEntity1));
+ GCS_EDGE_WRAPPER(theEntity1));
break;
case CONSTRAINT_RADIUS:
aResult = createConstraintRadius(GCS_SCALAR_WRAPPER(theValue),
- GCS_ENTITY_WRAPPER(theEntity1));
+ GCS_EDGE_WRAPPER(theEntity1));
break;
case CONSTRAINT_ANGLE:
aResult = createConstraintAngle(theConstraint,
GCS_SCALAR_WRAPPER(theValue),
- GCS_ENTITY_WRAPPER(theEntity1), GCS_ENTITY_WRAPPER(theEntity2));
+ GCS_EDGE_WRAPPER(theEntity1), GCS_EDGE_WRAPPER(theEntity2));
break;
case CONSTRAINT_FIXED:
break;
case CONSTRAINT_HORIZONTAL:
case CONSTRAINT_VERTICAL:
- aResult = createConstraintHorizVert(theType, GCS_ENTITY_WRAPPER(theEntity1));
+ aResult = createConstraintHorizVert(theType, GCS_EDGE_WRAPPER(theEntity1));
break;
case CONSTRAINT_PARALLEL:
- aResult = createConstraintParallel(GCS_ENTITY_WRAPPER(theEntity1),
- GCS_ENTITY_WRAPPER(theEntity2));
+ aResult = createConstraintParallel(GCS_EDGE_WRAPPER(theEntity1),
+ GCS_EDGE_WRAPPER(theEntity2));
break;
case CONSTRAINT_PERPENDICULAR:
- aResult = createConstraintPerpendicular(GCS_ENTITY_WRAPPER(theEntity1),
- GCS_ENTITY_WRAPPER(theEntity2));
+ aResult = createConstraintPerpendicular(GCS_EDGE_WRAPPER(theEntity1),
+ GCS_EDGE_WRAPPER(theEntity2));
break;
case CONSTRAINT_EQUAL_LINES:
anIntermediate = GCS_SCALAR_WRAPPER(theValue); // parameter is used to store length of lines
case CONSTRAINT_EQUAL_LINE_ARC:
case CONSTRAINT_EQUAL_RADIUS:
aResult = createConstraintEqual(theType,
- GCS_ENTITY_WRAPPER(theEntity1),
- GCS_ENTITY_WRAPPER(theEntity2),
+ GCS_EDGE_WRAPPER(theEntity1),
+ GCS_EDGE_WRAPPER(theEntity2),
anIntermediate);
break;
- case CONSTRAINT_TANGENT_CIRCLE_LINE:
- case CONSTRAINT_TANGENT_CIRCLE_CIRCLE:
- aResult = createConstraintTangent(theType,
- GCS_ENTITY_WRAPPER(theEntity1),
- GCS_ENTITY_WRAPPER(theEntity2));
- break;
- case CONSTRAINT_MULTI_TRANSLATION:
- case CONSTRAINT_MULTI_ROTATION:
- case CONSTRAINT_SYMMETRIC:
default:
break;
}
if (theEntity->type() != ENTITY_LINE)
return std::shared_ptr<GeomAPI_Lin2d>();
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
- std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+ std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(anEntity->entity());
return std::shared_ptr<GeomAPI_Lin2d>(
new GeomAPI_Lin2d(*(aLine->p1.x), *(aLine->p1.y), *(aLine->p2.x), *(aLine->p2.y)));
ConstraintWrapperPtr createConstraintPointOnEntity(
const SketchSolver_ConstraintType& theType,
std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
{
GCSConstraintPtr aNewConstr;
ConstraintWrapperPtr createConstraintMiddlePoint(
std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
{
GCSPointPtr aPoint = thePoint->point();
std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(theEntity->entity());
ConstraintWrapperPtr createConstraintDistancePointLine(
std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
{
std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(theEntity->entity());
GCSConstraintPtr aNewConstr(new GCS::ConstraintP2LDistance(
ConstraintWrapperPtr createConstraintRadius(
std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
{
std::shared_ptr<GCS::Circle> aCircle =
std::dynamic_pointer_cast<GCS::Circle>(theEntity->entity());
ConstraintWrapperPtr createConstraintAngle(
ConstraintPtr theConstraint,
std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2)
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2)
{
std::shared_ptr<GCS::Line> aLine1 = std::dynamic_pointer_cast<GCS::Line>(theEntity1->entity());
bool isLine1Rev = theConstraint->boolean(
ConstraintWrapperPtr createConstraintHorizVert(
const SketchSolver_ConstraintType& theType,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
{
std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(theEntity->entity());
GCSConstraintPtr aNewConstr;
}
ConstraintWrapperPtr createConstraintParallel(
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2)
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2)
{
std::shared_ptr<GCS::Line> aLine1 = std::dynamic_pointer_cast<GCS::Line>(theEntity1->entity());
std::shared_ptr<GCS::Line> aLine2 = std::dynamic_pointer_cast<GCS::Line>(theEntity2->entity());
}
ConstraintWrapperPtr createConstraintPerpendicular(
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2)
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2)
{
std::shared_ptr<GCS::Line> aLine1 = std::dynamic_pointer_cast<GCS::Line>(theEntity1->entity());
std::shared_ptr<GCS::Line> aLine2 = std::dynamic_pointer_cast<GCS::Line>(theEntity2->entity());
ConstraintWrapperPtr createConstraintEqual(
const SketchSolver_ConstraintType& theType,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2,
std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theIntermed)
{
if (theType == CONSTRAINT_EQUAL_LINE_ARC)
aResult->setValueParameter(theIntermed);
return aResult;
}
-
-ConstraintWrapperPtr createConstraintTangent(
- const SketchSolver_ConstraintType& theType,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2)
-{
- GCSConstraintPtr aNewConstr;
- if (theType == CONSTRAINT_TANGENT_CIRCLE_LINE) {
- GCSCurvePtr anEntCirc, anEntLine;
- if (theEntity1->type() == ENTITY_LINE) {
- anEntLine = theEntity1->entity();
- anEntCirc = theEntity2->entity();
- } else {
- anEntLine = theEntity2->entity();
- anEntCirc = theEntity1->entity();
- }
-
- std::shared_ptr<GCS::Circle> aCirc =
- std::dynamic_pointer_cast<GCS::Circle>(anEntCirc);
- std::shared_ptr<GCS::Line> aLine =
- std::dynamic_pointer_cast<GCS::Line>(anEntLine);
-
- aNewConstr =
- GCSConstraintPtr(new GCS::ConstraintP2LDistance(aCirc->center, *aLine, aCirc->rad));
- } else {
- std::shared_ptr<GCS::Circle> aCirc1 =
- std::dynamic_pointer_cast<GCS::Circle>(theEntity1->entity());
- std::shared_ptr<GCS::Circle> aCirc2 =
- std::dynamic_pointer_cast<GCS::Circle>(theEntity2->entity());
-
- double aDX = *(aCirc1->center.x) - *(aCirc2->center.x);
- double aDY = *(aCirc1->center.y) - *(aCirc2->center.y);
- double aDist = sqrt(aDX * aDX + aDY * aDY);
- aNewConstr = GCSConstraintPtr(new GCS::ConstraintTangentCircumf(aCirc1->center, aCirc2->center,
- aCirc1->rad, aCirc2->rad, (aDist < *(aCirc1->rad) || aDist < *(aCirc2->rad))));
- }
-
- return ConstraintWrapperPtr(new PlaneGCSSolver_ConstraintWrapper(aNewConstr, theType));
-}
-
-bool PlaneGCSSolver_Tools::isArcArcTangencyInternal(
- EntityWrapperPtr theArc1, EntityWrapperPtr theArc2)
-{
- std::shared_ptr<GCS::Circle> aCirc1 = std::dynamic_pointer_cast<GCS::Circle>(
- GCS_ENTITY_WRAPPER(theArc1)->entity());
- std::shared_ptr<GCS::Circle> aCirc2 = std::dynamic_pointer_cast<GCS::Circle>(
- GCS_ENTITY_WRAPPER(theArc2)->entity());
-
- if (!aCirc1 || !aCirc2)
- return false;
-
- double aDX = *(aCirc1->center.x) - *(aCirc2->center.x);
- double aDY = *(aCirc1->center.y) - *(aCirc2->center.y);
- double aDist = sqrt(aDX * aDX + aDY * aDY);
-
- return (aDist < *(aCirc1->rad) || aDist < *(aCirc2->rad));
-}
/// \brief Convert entity to line
/// \return empty pointer if the entity is not a line
std::shared_ptr<GeomAPI_Lin2d> line(FeaturePtr theFeature);
-
- /// \brief Check if two connected arcs have centers
- /// in same direction relatively to connection point
- bool isArcArcTangencyInternal(EntityWrapperPtr theArc1,
- EntityWrapperPtr theArc2);
};
#endif
// Author: Artem ZHIDKOV
#include <PlaneGCSSolver_UpdateCoincidence.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
#include <PlaneGCSSolver_PointWrapper.h>
#include <SketchSolver_Constraint.h>
if (theEntity->type() == ENTITY_LINE) {
std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(
- std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity)->entity());
+ std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity)->entity());
return anIt->isExist(aLine->p1) || anIt->isExist(aLine->p2);
}
return false;
#define PlaneGCSSolver_UpdateCoincidence_H_
#include <PlaneGCSSolver_Update.h>
-#include <SketchSolver_IEntityWrapper.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
#include <GCS.h>
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-#ifndef SKETCHSOLVER_H
-#define SKETCHSOLVER_H
-
-#include <stdlib.h>
-
-/// Tolerance for value of parameters
-const double tolerance = 1.e-10;
-
-#define PI 3.1415926535897932
-
-// Types for data entities enumeration
-typedef int ConstraintID;
-
-// Predefined values for identifiers
-const ConstraintID CID_UNKNOWN = 0;
-const ConstraintID CID_MOVEMENT = -1;
-
-#endif
#ifndef SketchSolver_Constraint_H_
#define SketchSolver_Constraint_H_
-#include "SketchSolver.h"
#include <SketchSolver_Storage.h>
#include <PlaneGCSSolver_Update.h>
#ifndef SketchSolver_ConstraintCoincidence_H_
#define SketchSolver_ConstraintCoincidence_H_
-#include "SketchSolver.h"
#include <SketchSolver_Constraint.h>
/** \class SketchSolver_ConstraintCoincidence
#include <SketchSolver_Error.h>
#include <PlaneGCSSolver_ConstraintWrapper.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
#include <PlaneGCSSolver_PointWrapper.h>
#include <PlaneGCSSolver_UpdateCoincidence.h>
static ConstraintWrapperPtr createPointsOnLine(
std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint1,
std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint2,
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> theLine)
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theLine)
{
std::shared_ptr<GCS::Line> aGCSLine = std::dynamic_pointer_cast<GCS::Line>(theLine->entity());
bool aConstraintToApply[4] = {false, false, false, false};
ConstraintWrapperPtr aNewConstraint;
std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoints[2];
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> aLine;
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> aLine;
if (isPointOnOppositeLine[0] || isPointOnOppositeLine[1]) {
// one of points of first line is already on the second line,
aPoints[i] = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(myPoints[i]);
aConstraintToApply[i] = true;
}
- aLine = std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(myAttributes.back());
+ aLine = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(myAttributes.back());
} else {
// verify second line and add necessary constraints
for (int i = 0; i < 2; ++i) {
aPoints[i] = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(myPoints[i + 2]);
aConstraintToApply[i+2] = true;
}
- aLine = std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(myAttributes.front());
+ aLine = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(myAttributes.front());
}
bool isNew = false;
#ifndef SketchSolver_ConstraintDistance_H_
#define SketchSolver_ConstraintDistance_H_
-#include "SketchSolver.h"
#include <SketchSolver_Constraint.h>
/** \class SketchSolver_ConstraintDistance
#ifndef SketchSolver_ConstraintEqual_H_
#define SketchSolver_ConstraintEqual_H_
-#include "SketchSolver.h"
#include <SketchSolver_Constraint.h>
/** \class SketchSolver_ConstraintEqual
#include <SketchSolver_Error.h>
#include <PlaneGCSSolver_ConstraintWrapper.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
#include <PlaneGCSSolver_PointWrapper.h>
+#include <GeomDataAPI_Point2D.h>
+
+#include <cmath>
+
+// Find parameters of the feature that have been updated during the movement
+static EntityWrapperPtr getChangedEntity(const FeaturePtr& theFeature,
+ const StoragePtr& theStorage);
+
SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(ConstraintPtr theConstraint)
: SketchSolver_Constraint(theConstraint)
{
myType = CONSTRAINT_FIXED;
-//// AttributeRefAttrPtr anAttribute =
-//// theConstraint->refattr(SketchPlugin_ConstraintRigid::ENTITY_A());
-//// if (anAttribute->isObject())
-//// myFixedFeature = ModelAPI_Feature::feature(anAttribute->object());
-//// else
-//// myFixedAttribute = anAttribute->attr();
}
SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(FeaturePtr theFeature)
myBaseFeature(theFeature)
{
myType = CONSTRAINT_FIXED;
-//// process();
}
void SketchSolver_ConstraintFixed::blockEvents(bool isBlocked)
void SketchSolver_ConstraintFixed::fixFeature(EntityWrapperPtr theFeature)
{
- std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
- std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theFeature);
+ std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+ std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theFeature);
GCS::VEC_pD aParameters; // parameters of entity to be fixed
{
if (myBaseFeature) {
// The feature is fixed.
+ EntityWrapperPtr aSolverEntity = getChangedEntity(myBaseFeature, myStorage);
myStorage->update(myBaseFeature);
- EntityWrapperPtr aSolverEntity = myStorage->entity(myBaseFeature);
if (aSolverEntity)
theAttributes.push_back(aSolverEntity);
} else if (myBaseConstraint) {
} else
myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();
}
+
+
+
+
+// ==================== Auxiliary functions ===============================
+static bool isSameCoordinates(const AttributePoint2DPtr& thePointAttr,
+ const PointWrapperPtr& thePointWrapper)
+{
+ GCSPointPtr aGCSPoint = thePointWrapper->point();
+ return fabs(*aGCSPoint->x - thePointAttr->x()) < tolerance &&
+ fabs(*aGCSPoint->y - thePointAttr->y()) < tolerance;
+}
+
+EntityWrapperPtr getChangedEntity(const FeaturePtr& theFeature,
+ const StoragePtr& theStorage)
+{
+ std::list<AttributePtr> aPoints = theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
+ std::list<EntityWrapperPtr> aChangedPoints;
+
+ std::list<AttributePtr>::const_iterator aPIt = aPoints.begin();
+ for (; aPIt != aPoints.end(); ++aPIt) {
+ AttributePoint2DPtr aPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*aPIt);
+ EntityWrapperPtr anEnt = theStorage->entity(*aPIt);
+ if (!anEnt)
+ continue;
+ PointWrapperPtr aPW = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anEnt);
+ if (!isSameCoordinates(aPnt, aPW))
+ aChangedPoints.push_back(anEnt);
+ }
+
+ EntityWrapperPtr aChanged;
+ if (aChangedPoints.size() == 1)
+ aChanged = aChangedPoints.front();
+ else if (!aChangedPoints.empty()) // update whole feature
+ aChanged = theStorage->entity(theFeature);
+ return aChanged;
+}
#ifndef SketchSolver_ConstraintFixed_H_
#define SketchSolver_ConstraintFixed_H_
-#include "SketchSolver.h"
#include <SketchSolver_Constraint.h>
/** \class SketchSolver_ConstraintFixed
#ifndef SketchSolver_ConstraintLength_H_
#define SketchSolver_ConstraintLength_H_
-#include "SketchSolver.h"
#include <SketchSolver_Constraint.h>
/** \class SketchSolver_ConstraintLength
#ifndef SketchSolver_ConstraintMirror_H_
#define SketchSolver_ConstraintMirror_H_
-#include "SketchSolver.h"
#include <SketchSolver_Constraint.h>
/** \class SketchSolver_ConstraintMirror
#ifndef SketchSolver_ConstraintMulti_H_
#define SketchSolver_ConstraintMulti_H_
-#include "SketchSolver.h"
#include <SketchSolver_Constraint.h>
#include <vector>
#ifndef SketchSolver_ConstraintMultiRotation_H_
#define SketchSolver_ConstraintMultiRotation_H_
-#include "SketchSolver.h"
#include <SketchSolver_ConstraintMulti.h>
#include "GeomDataAPI_Point2D.h"
#ifndef SketchSolver_ConstraintMultiTranslation_H_
#define SketchSolver_ConstraintMultiTranslation_H_
-#include "SketchSolver.h"
#include <SketchSolver_ConstraintMulti.h>
#include "GeomDataAPI_Point2D.h"
#include <SketchSolver_ConstraintTangent.h>
#include <SketchSolver_Error.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
+#include <PlaneGCSSolver_PointWrapper.h>
#include <PlaneGCSSolver_Tools.h>
+#include <PlaneGCSSolver_UpdateCoincidence.h>
#include <GeomAPI_Pnt2d.h>
#include <SketchPlugin_Circle.h>
#include <cmath>
+#define GCS_EDGE_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(x)
-/// \brief Check whether the entities has only one shared point or less
-static bool hasSingleCoincidence(FeaturePtr theFeature1, FeaturePtr theFeature2)
-{
- const std::set<AttributePtr>& aRefs1 = theFeature1->data()->refsToMe();
- const std::set<AttributePtr>& aRefs2 = theFeature2->data()->refsToMe();
+/// \brief Obtain tangent features from the constraint
+static void getTangentFeatures(const ConstraintPtr& theConstraint,
+ FeaturePtr& theFeature1,
+ FeaturePtr& theFeature2);
- // collect all shared coincidendes
- std::set<FeaturePtr> aCoincidences;
- std::set<AttributePtr>::const_iterator anIt;
- for (anIt = aRefs1.begin(); anIt != aRefs1.end(); ++anIt) {
- FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
- if (aRef && aRef->getKind() == SketchPlugin_ConstraintCoincidence::ID())
- aCoincidences.insert(aRef);
- }
- int aNbCoinCidentPoints = 0;
- for (anIt = aRefs2.begin(); anIt != aRefs2.end(); ++anIt) {
- FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
- if (aCoincidences.find(aRef) != aCoincidences.end())
- ++aNbCoinCidentPoints;
- }
+/// \brief Obtain all coincident constraints between features
+static std::set<FeaturePtr> collectCoincidences(FeaturePtr theFeature1, FeaturePtr theFeature2);
- return aNbCoinCidentPoints <= 1;
-}
+/// \brief Check whether the entities has only one shared point or less.
+/// Return list of coincident points.
+static std::list<AttributePtr> coincidentPoints(FeaturePtr theFeature1, FeaturePtr theFeature2);
+
+/// \brief Check if two connected arcs have centers
+/// in same direction relatively to connection point
+static bool isArcArcTangencyInternal(EntityWrapperPtr theArc1,
+ EntityWrapperPtr theArc2);
+
+static ConstraintWrapperPtr
+ createArcLineTangency(EntityWrapperPtr theEntity1,
+ EntityWrapperPtr theEntity2,
+ EntityWrapperPtr theShapedPoint = EntityWrapperPtr(),
+ double* theAngle = 0);
+
+static ConstraintWrapperPtr
+ createArcArcTangency(EntityWrapperPtr theEntity1,
+ EntityWrapperPtr theEntity2,
+ bool theInternalTangency,
+ EntityWrapperPtr theSharedPoint = EntityWrapperPtr(),
+ double* theAngle = 0);
-void SketchSolver_ConstraintTangent::getAttributes(
- EntityWrapperPtr& theValue,
- std::vector<EntityWrapperPtr>& theAttributes)
+
+void SketchSolver_ConstraintTangent::process()
{
- SketchSolver_Constraint::getAttributes(theValue, theAttributes);
- if (!myErrorMsg.empty() || !theAttributes[2] || !theAttributes[3]) {
- theAttributes.clear();
+ cleanErrorMsg();
+ if (!myBaseConstraint || !myStorage) {
+ // Not enough parameters are assigned
return;
}
+ EntityWrapperPtr aValue;
+ std::vector<EntityWrapperPtr> anAttributes;
+ SketchSolver_Constraint::getAttributes(aValue, anAttributes);
+ if (!myErrorMsg.empty())
+ return;
+
+ rebuild();
+ if (!myErrorMsg.empty())
+ return;
+
+ myStorage->subscribeUpdates(this, PlaneGCSSolver_UpdateCoincidence::GROUP());
+}
+
+void SketchSolver_ConstraintTangent::rebuild()
+{
+ if (mySolverConstraint)
+ myStorage->removeConstraint(myBaseConstraint);
+
+ mySolverConstraint = ConstraintWrapperPtr();
+ mySharedPoint = AttributePtr();
+
// Check the quantity of entities of each type and their order (arcs first)
int aNbLines = 0;
int aNbCircles = 0;
- std::vector<EntityWrapperPtr>::iterator anEntIt = theAttributes.begin() + 2;
- for (; anEntIt != theAttributes.end(); ++anEntIt) {
+ std::list<EntityWrapperPtr>::iterator anEntIt = myAttributes.begin();
+ for (; anEntIt != myAttributes.end(); ++anEntIt) {
+ if (!(*anEntIt).get())
+ continue;
if ((*anEntIt)->type() == ENTITY_LINE)
++aNbLines;
else if ((*anEntIt)->type() == ENTITY_ARC || (*anEntIt)->type() == ENTITY_CIRCLE)
}
else if (aNbCircles == 2) {
myType = CONSTRAINT_TANGENT_CIRCLE_CIRCLE;
- isArcArcInternal =
- PlaneGCSSolver_Tools::isArcArcTangencyInternal(theAttributes[2], theAttributes[3]);
+ isArcArcInternal = isArcArcTangencyInternal(myAttributes.front(), myAttributes.back());
}
else {
myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
return;
}
- if (myType == CONSTRAINT_TANGENT_CIRCLE_LINE) {
- AttributeRefAttrPtr aRefAttr = myBaseConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
- FeaturePtr aFeature1 = ModelAPI_Feature::feature(aRefAttr->object());
- aRefAttr = myBaseConstraint->refattr(SketchPlugin_Constraint::ENTITY_B());
- FeaturePtr aFeature2 = ModelAPI_Feature::feature(aRefAttr->object());
+ FeaturePtr aFeature1, aFeature2;
+ getTangentFeatures(myBaseConstraint, aFeature1, aFeature2);
- if (!hasSingleCoincidence(aFeature1, aFeature2))
- myErrorMsg = SketchSolver_Error::TANGENCY_FAILED();
+ // check number of coincident points
+ std::list<AttributePtr> aCoincidentPoints = coincidentPoints(aFeature1, aFeature2);
+ if (myType == CONSTRAINT_TANGENT_CIRCLE_LINE && aCoincidentPoints.size() > 1) {
+ myErrorMsg = SketchSolver_Error::TANGENCY_FAILED();
+ return;
}
+
+ EntityWrapperPtr aSharedPointEntity;
+ if (!aCoincidentPoints.empty()) {
+ mySharedPoint = aCoincidentPoints.front();
+ aSharedPointEntity = myStorage->entity(mySharedPoint);
+ }
+
+ if (myType == CONSTRAINT_TANGENT_CIRCLE_LINE) {
+ mySolverConstraint = createArcLineTangency(myAttributes.front(), myAttributes.back(),
+ aSharedPointEntity, &myCurveCurveAngle);
+ } else {
+ mySolverConstraint = createArcArcTangency(myAttributes.front(), myAttributes.back(),
+ isArcArcInternal, aSharedPointEntity, &myCurveCurveAngle);
+ }
+
+ myStorage->addConstraint(myBaseConstraint, mySolverConstraint);
}
void SketchSolver_ConstraintTangent::adjustConstraint()
EntityWrapperPtr anEntity2 =
myStorage->entity(myBaseConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
- if (isArcArcInternal != PlaneGCSSolver_Tools::isArcArcTangencyInternal(anEntity1, anEntity2)) {
- // fully rebuld constraint, because it is unable to access attributes of PlaneGCS constraint
- remove();
- process();
+ if (isArcArcInternal != isArcArcTangencyInternal(anEntity1, anEntity2))
+ rebuild();
+ }
+}
+
+void SketchSolver_ConstraintTangent::notify(const FeaturePtr& theFeature,
+ PlaneGCSSolver_Update* theUpdater)
+{
+ if (theFeature->getKind() != SketchPlugin_ConstraintCoincidence::ID())
+ return;
+
+ // base constraint may become invalid (for example, during undo)
+ if (!myBaseConstraint->data() || !myBaseConstraint->data()->isValid())
+ return;
+
+ FeaturePtr aTgFeat1, aTgFeat2;
+ getTangentFeatures(myBaseConstraint, aTgFeat1, aTgFeat2);
+
+ bool isRebuild = false;
+ if (theFeature->data() && theFeature->data()->isValid()) {
+ // the constraint has been created
+ if (!mySharedPoint) {
+ // features has no shared point, check whether coincidence constraint binds these features)
+ int aNbCoincidentFeatures = 0;
+ for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
+ AttributeRefAttrPtr aRefAttr = theFeature->refattr(SketchPlugin_Constraint::ATTRIBUTE(i));
+ if (!aRefAttr)
+ continue;
+
+ ObjectPtr anObj;
+ if (aRefAttr->isObject())
+ anObj = aRefAttr->object();
+ else
+ anObj = aRefAttr->attr()->owner();
+
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObj);
+ if (aFeature == aTgFeat1 || aFeature == aTgFeat2)
+ ++aNbCoincidentFeatures;
+ }
+
+ if (aNbCoincidentFeatures == 2)
+ isRebuild = true;
+ }
+ } else if (mySharedPoint) {
+ // The features are tangent in the shared point, but the coincidence has been removed.
+ // Check if the coincidence is the same.
+ std::list<AttributePtr> aCoincidentPoints = coincidentPoints(aTgFeat1, aTgFeat2);
+ isRebuild = true;
+ std::list<AttributePtr>::iterator anIt = aCoincidentPoints.begin();
+ for (; anIt != aCoincidentPoints.end() && isRebuild; ++anIt)
+ if (*anIt == mySharedPoint)
+ isRebuild = false; // the coincidence is still exists => nothing to change
+ }
+
+ if (isRebuild)
+ rebuild();
+}
+
+
+
+
+// ================== Auxiliary functions =================================
+void getTangentFeatures(const ConstraintPtr& theConstraint,
+ FeaturePtr& theFeature1,
+ FeaturePtr& theFeature2)
+{
+ AttributeRefAttrPtr aRefAttr = theConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
+ theFeature1 = ModelAPI_Feature::feature(aRefAttr->object());
+ aRefAttr = theConstraint->refattr(SketchPlugin_Constraint::ENTITY_B());
+ theFeature2 = ModelAPI_Feature::feature(aRefAttr->object());
+}
+
+std::set<FeaturePtr> collectCoincidences(FeaturePtr theFeature1, FeaturePtr theFeature2)
+{
+ const std::set<AttributePtr>& aRefs1 = theFeature1->data()->refsToMe();
+ const std::set<AttributePtr>& aRefs2 = theFeature2->data()->refsToMe();
+
+ std::set<FeaturePtr> aCoincidences;
+ std::set<AttributePtr>::const_iterator anIt;
+
+ // collect coincidences referred to the first feature
+ for (anIt = aRefs1.begin(); anIt != aRefs1.end(); ++anIt) {
+ FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
+ if (aRef && aRef->getKind() == SketchPlugin_ConstraintCoincidence::ID())
+ aCoincidences.insert(aRef);
+ }
+
+ // leave only coincidences referred to the second feature
+ std::set<FeaturePtr> aCoincidencesBetweenFeatures;
+ for (anIt = aRefs2.begin(); anIt != aRefs2.end(); ++anIt) {
+ FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
+ if (aCoincidences.find(aRef) != aCoincidences.end())
+ aCoincidencesBetweenFeatures.insert(aRef);
+ }
+
+ return aCoincidencesBetweenFeatures;
+}
+
+std::list<AttributePtr> coincidentPoints(FeaturePtr theFeature1, FeaturePtr theFeature2)
+{
+ std::set<FeaturePtr> aCoincidences = collectCoincidences(theFeature1, theFeature2);
+ // collect points only
+ std::list<AttributePtr> aCoincidentPoints;
+ std::set<FeaturePtr>::const_iterator aCIt = aCoincidences.begin();
+ for (; aCIt != aCoincidences.end(); ++ aCIt) {
+ for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
+ AttributeRefAttrPtr aRefAttr = (*aCIt)->refattr(SketchPlugin_Constraint::ENTITY_A());
+ if (aRefAttr && !aRefAttr->isObject()) {
+ aCoincidentPoints.push_back(aRefAttr->attr());
+ break;
+ }
}
}
+ return aCoincidentPoints;
+}
+
+bool isArcArcTangencyInternal(EntityWrapperPtr theArc1, EntityWrapperPtr theArc2)
+{
+ std::shared_ptr<GCS::Circle> aCirc1 = std::dynamic_pointer_cast<GCS::Circle>(
+ GCS_EDGE_WRAPPER(theArc1)->entity());
+ std::shared_ptr<GCS::Circle> aCirc2 = std::dynamic_pointer_cast<GCS::Circle>(
+ GCS_EDGE_WRAPPER(theArc2)->entity());
+
+ if (!aCirc1 || !aCirc2)
+ return false;
+
+ double aDX = *(aCirc1->center.x) - *(aCirc2->center.x);
+ double aDY = *(aCirc1->center.y) - *(aCirc2->center.y);
+ double aDist = sqrt(aDX * aDX + aDY * aDY);
+
+ return (aDist < *(aCirc1->rad) || aDist < *(aCirc2->rad));
+}
+
+// sets angle to 0 or 180 degrees
+static void adjustAngleBetweenCurves(const GCSCurvePtr& theCurve1,
+ const GCSCurvePtr& theCurve2,
+ const GCSPointPtr& thePoint,
+ double* theAngle)
+{
+ double anAngle = GCS::System().calculateAngleViaPoint(*theCurve1, *theCurve2, *thePoint);
+ // bring angle to [-pi..pi]
+ if (anAngle > PI) anAngle -= 2.0 * PI;
+ if (anAngle < -PI) anAngle += 2.0 * PI;
+ // set angle value according to the current angle between curves
+ if (fabs(anAngle) <= PI / 2.)
+ *theAngle = 0.0;
+ else
+ *theAngle = PI;
+}
+
+
+ConstraintWrapperPtr createArcLineTangency(EntityWrapperPtr theEntity1,
+ EntityWrapperPtr theEntity2,
+ EntityWrapperPtr theSharedPoint,
+ double* theAngle)
+{
+ EdgeWrapperPtr anEntLine, anEntCirc;
+ if (theEntity1->type() == ENTITY_LINE) {
+ anEntLine = GCS_EDGE_WRAPPER(theEntity1);
+ anEntCirc = GCS_EDGE_WRAPPER(theEntity2);
+ } else {
+ anEntLine = GCS_EDGE_WRAPPER(theEntity2);
+ anEntCirc = GCS_EDGE_WRAPPER(theEntity1);
+ }
+
+ std::shared_ptr<GCS::Circle> aCirc =
+ std::dynamic_pointer_cast<GCS::Circle>(anEntCirc->entity());
+ std::shared_ptr<GCS::Line> aLine =
+ std::dynamic_pointer_cast<GCS::Line>(anEntLine->entity());
+
+ GCSConstraintPtr aNewConstr;
+ if (theSharedPoint) {
+ std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(aCirc);
+ GCSPointPtr aPoint =
+ std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theSharedPoint)->point();
+
+ adjustAngleBetweenCurves(anArc, aLine, aPoint, theAngle);
+ aNewConstr =
+ GCSConstraintPtr(new GCS::ConstraintAngleViaPoint(*anArc, *aLine, *aPoint, theAngle));
+ } else {
+ aNewConstr =
+ GCSConstraintPtr(new GCS::ConstraintP2LDistance(aCirc->center, *aLine, aCirc->rad));
+ }
+
+ return ConstraintWrapperPtr(
+ new PlaneGCSSolver_ConstraintWrapper(aNewConstr, CONSTRAINT_TANGENT_CIRCLE_LINE));
+}
+
+ConstraintWrapperPtr createArcArcTangency(EntityWrapperPtr theEntity1,
+ EntityWrapperPtr theEntity2,
+ bool theInternalTangency,
+ EntityWrapperPtr theSharedPoint,
+ double* theAngle)
+{
+ std::shared_ptr<GCS::Circle> aCirc1 =
+ std::dynamic_pointer_cast<GCS::Circle>(GCS_EDGE_WRAPPER(theEntity1)->entity());
+ std::shared_ptr<GCS::Circle> aCirc2 =
+ std::dynamic_pointer_cast<GCS::Circle>(GCS_EDGE_WRAPPER(theEntity2)->entity());
+
+ GCSConstraintPtr aNewConstr;
+ if (theSharedPoint) {
+ std::shared_ptr<GCS::Arc> anArc1 = std::dynamic_pointer_cast<GCS::Arc>(aCirc1);
+ std::shared_ptr<GCS::Arc> anArc2 = std::dynamic_pointer_cast<GCS::Arc>(aCirc2);
+ GCSPointPtr aPoint =
+ std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theSharedPoint)->point();
+
+ adjustAngleBetweenCurves(anArc1, anArc2, aPoint, theAngle);
+ aNewConstr =
+ GCSConstraintPtr(new GCS::ConstraintAngleViaPoint(*anArc1, *anArc2, *aPoint, theAngle));
+ } else {
+ aNewConstr = GCSConstraintPtr(new GCS::ConstraintTangentCircumf(aCirc1->center, aCirc2->center,
+ aCirc1->rad, aCirc2->rad, theInternalTangency));
+ }
+
+ return ConstraintWrapperPtr(
+ new PlaneGCSSolver_ConstraintWrapper(aNewConstr, CONSTRAINT_TANGENT_CIRCLE_CIRCLE));
}
#ifndef SketchSolver_ConstraintTangent_H_
#define SketchSolver_ConstraintTangent_H_
-#include "SketchSolver.h"
#include <SketchSolver_Constraint.h>
/** \class SketchSolver_ConstraintTangent
/// Constructor based on SketchPlugin constraint
SketchSolver_ConstraintTangent(ConstraintPtr theConstraint) :
SketchSolver_Constraint(theConstraint),
- isArcArcInternal(false)
+ isArcArcInternal(false),
+ myCurveCurveAngle(0.0)
{}
+ /// \brief Notify this object about the feature is changed somewhere
+ virtual void notify(const FeaturePtr& theFeature,
+ PlaneGCSSolver_Update* theUpdater);
+
protected:
- /// \brief Generate list of attributes of constraint in order useful for constraints
- /// \param[out] theValue numerical characteristic of constraint (e.g. distance)
- /// \param[out] theAttributes list of attributes to be filled
- virtual void getAttributes(EntityWrapperPtr& theValue,
- std::vector<EntityWrapperPtr>& theAttributes);
+ /// \brief Converts SketchPlugin constraint to a list of solver constraints
+ virtual void process();
+
+ /// \brief Remove current constraint from the storage and build is again
+ void rebuild();
/// \brief This method is used in derived objects to check consistency of constraint.
/// E.g. the distance between line and point may be signed.
private:
bool isArcArcInternal;
+ double myCurveCurveAngle;
+ AttributePtr mySharedPoint;
};
#endif
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: SketchSolver_IConstraintWrapper.h
-// Created: 30 Nov 2015
-// Author: Artem ZHIDKOV
-
-#ifndef SketchSolver_IConstraintWrapper_H_
-#define SketchSolver_IConstraintWrapper_H_
-
-#include <SketchSolver_IEntityWrapper.h>
-
-#include <SketchPlugin_Constraint.h>
-
-#include <list>
-#include <memory>
-
-/// Types of constraints
-enum SketchSolver_ConstraintType {
- CONSTRAINT_UNKNOWN = 0,
- CONSTRAINT_COINCIDENCE, // base coincidence if we don't know exact type yet
- CONSTRAINT_PT_PT_COINCIDENT,
- CONSTRAINT_PT_ON_LINE,
- CONSTRAINT_PT_ON_CIRCLE,
- CONSTRAINT_MIDDLE_POINT,
- CONSTRAINT_DISTANCE, // base distance if we don't know the measured objects yet
- CONSTRAINT_PT_PT_DISTANCE,
- CONSTRAINT_PT_LINE_DISTANCE,
- CONSTRAINT_RADIUS,
- CONSTRAINT_ANGLE,
- CONSTRAINT_FIXED,
- CONSTRAINT_HORIZONTAL,
- CONSTRAINT_VERTICAL,
- CONSTRAINT_PARALLEL,
- CONSTRAINT_PERPENDICULAR,
- CONSTRAINT_SYMMETRIC,
- CONSTRAINT_EQUAL, // base equality if we don't know the measured objects yet
- CONSTRAINT_EQUAL_LINES,
- CONSTRAINT_EQUAL_LINE_ARC,
- CONSTRAINT_EQUAL_RADIUS,
- CONSTRAINT_TANGENT, // base tangency if we don't know the measured objects yet
- CONSTRAINT_TANGENT_CIRCLE_LINE,
- CONSTRAINT_TANGENT_CIRCLE_CIRCLE,
- CONSTRAINT_COLLINEAR,
- CONSTRAINT_MULTI_TRANSLATION,
- CONSTRAINT_MULTI_ROTATION
-};
-
-/**
- * Wrapper providing operations with constraints regardless the solver.
- */
-class SketchSolver_IConstraintWrapper
-{
-public:
- virtual ~SketchSolver_IConstraintWrapper() {}
-
- /// \brief Return ID of current constraint
- const ConstraintID& id() const
- { return myID; }
- /// \brief Change constraint ID
- virtual void setId( const ConstraintID& theID) = 0;
-
- /// \brief Return type of current entity
- virtual SketchSolver_ConstraintType type() const = 0;
-
- /// \brief Assign numeric parameter of constraint
- virtual void setValue(const double& theValue) = 0;
- /// \brief Return numeric parameter of constraint
- virtual double value() const = 0;
-
-protected:
- ConstraintID myID;
-};
-
-typedef std::shared_ptr<SketchSolver_IConstraintWrapper> ConstraintWrapperPtr;
-
-#endif
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: SketchSolver_IEntityWrapper.h
-// Created: 30 Nov 2015
-// Author: Artem ZHIDKOV
-
-#ifndef SketchSolver_IEntityWrapper_H_
-#define SketchSolver_IEntityWrapper_H_
-
-#include <SketchSolver.h>
-
-#include <ModelAPI_Attribute.h>
-#include <ModelAPI_Feature.h>
-
-#include <list>
-#include <memory>
-
-/// Types of entities
-enum SketchSolver_EntityType {
- ENTITY_UNKNOWN = 0,
- ENTITY_SCALAR,
- ENTITY_ANGLE,
- ENTITY_POINT,
- ENTITY_LINE,
- ENTITY_CIRCLE,
- ENTITY_ARC
-};
-
-/**
- * Wrapper providing operations with entities regardless the solver.
- */
-class SketchSolver_IEntityWrapper
-{
-public:
- SketchSolver_IEntityWrapper() : myExternal(false) {}
- virtual ~SketchSolver_IEntityWrapper() {}
-
- /// \brief Return type of current entity
- virtual SketchSolver_EntityType type() const = 0;
-
- /// \brief Change flag indicating the entity cannot be changed in the solver
- void setExternal(bool theExternal) { myExternal = theExternal; }
- /// \brief Return the External flag
- bool isExternal() const { return myExternal; }
-
-private:
- bool myExternal;
-};
-
-typedef std::shared_ptr<SketchSolver_IEntityWrapper> EntityWrapperPtr;
-
-#endif
#ifndef SketchSolver_Manager_H_
#define SketchSolver_Manager_H_
-#include "SketchSolver.h"
#include <SketchSolver_Group.h>
#include <Events_Listener.h>
#ifndef SketchSolver_Storage_H_
#define SketchSolver_Storage_H_
-#include <SketchSolver.h>
-#include <SketchSolver_IConstraintWrapper.h>
-#include <SketchSolver_IEntityWrapper.h>
+#include <PlaneGCSSolver_ConstraintWrapper.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
#include <PlaneGCSSolver_Solver.h>
#include <PlaneGCSSolver_UpdateFeature.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Session.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultConstruction.h>
#include <AIS_InteractiveContext.hxx>
#endif
aParameters.Append(MyVCallBack);
+ MyTCommunicator->registerPlugin("SMBrowser"); // custom plugin to view ModelAPI
+
MyTCommunicator->init(aParameters);
+ MyTCommunicator->Activate("SMBrowser"); // to have button in TInspector
MyTCommunicator->Activate("TKVInspector"); // to have filled callback by model
MyTCommunicator->Activate("TKDFBrowser");
}
model.testNbSubResults(Boolean_7, [0])
model.testNbSubShapes(Boolean_7, GeomAPI_Shape.SOLID, [1])
model.testNbSubShapes(Boolean_7, GeomAPI_Shape.FACE, [49])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.EDGE, [271])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.VERTEX, [542])
-model.testResultsVolumes(Boolean_7, [157000.318686960934428498148918152])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.EDGE, [263])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.VERTEX, [526])
+model.testResultsVolumes(Boolean_7, [157000.328896829247241839766502380])
assert(model.checkPythonDump)
model.addParameter(Part_1_doc, "Width", "25", "Width of body arms")
Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
SketchLine_1 = Sketch_1.addLine(50, 14.61148285474187, 50, 0)
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 14.61148285474187)
SketchLine_2 = Sketch_1.addLine(50, 0, 6, 0)
SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
SketchLine_3 = Sketch_1.addLine(7, 25, 16.13599978860571, 25)
SketchConstraintCoincidence_60.setName("SketchConstraintCoincidence_48")
SketchConstraintCoincidence_61 = Sketch_4.setCoincident(SketchArc_13.endPoint(), SketchArc_12.endPoint())
SketchConstraintCoincidence_61.setName("SketchConstraintCoincidence_49")
-SketchConstraintCoincidence_62 = Sketch_4.setCoincident(SketchArc_13.center(), SketchLine_32.result())
-SketchConstraintCoincidence_62.setName("SketchConstraintCoincidence_50")
SketchConstraintMirror_1 = Sketch_4.addMirror(SketchLine_40.result(), [SketchArc_13.results()[1], SketchArc_12.results()[1]])
[SketchArc_14, SketchArc_15] = SketchConstraintMirror_1.mirrored()
SketchArc_15.setName("SketchArc_6")
SketchArc_22.setName("SketchArc_4")
SketchArc_22.result().setName("SketchArc_4")
SketchArc_22.results()[1].setName("SketchArc_4_2")
-SketchConstraintCoincidence_117 = Sketch_6.setCoincident(SketchArc_22.startPoint(), SketchLine_56.startPoint())
-SketchConstraintCoincidence_117.setName("SketchConstraintCoincidence_48")
-SketchConstraintCoincidence_118 = Sketch_6.setCoincident(SketchArc_22.endPoint(), SketchArc_21.endPoint())
-SketchConstraintCoincidence_118.setName("SketchConstraintCoincidence_49")
-SketchConstraintCoincidence_119 = Sketch_6.setCoincident(SketchArc_22.center(), SketchLine_53.result())
-SketchConstraintCoincidence_119.setName("SketchConstraintCoincidence_50")
+SketchConstraintCoincidence_127 = Sketch_6.setCoincident(SketchArc_22.startPoint(), SketchLine_56.startPoint())
+SketchConstraintCoincidence_127.setName("SketchConstraintCoincidence_48")
+SketchConstraintCoincidence_128 = Sketch_6.setCoincident(SketchArc_22.endPoint(), SketchArc_21.endPoint())
+SketchConstraintCoincidence_128.setName("SketchConstraintCoincidence_49")
SketchConstraintMirror_3 = Sketch_6.addMirror(SketchLine_61.result(), [SketchArc_22.results()[1], SketchArc_21.results()[1]])
[SketchArc_23, SketchArc_24] = SketchConstraintMirror_3.mirrored()
SketchArc_24.setName("SketchArc_6")
SketchConstraintCoincidence_194.setName("SketchConstraintCoincidence_48")
SketchConstraintCoincidence_195 = Sketch_8.setCoincident(SketchArc_31.endPoint(), SketchArc_30.endPoint())
SketchConstraintCoincidence_195.setName("SketchConstraintCoincidence_49")
-SketchConstraintCoincidence_196 = Sketch_8.setCoincident(SketchArc_31.center(), SketchLine_74.result())
-SketchConstraintCoincidence_196.setName("SketchConstraintCoincidence_50")
SketchConstraintMirror_5 = Sketch_8.addMirror(SketchLine_82.result(), [SketchArc_31.results()[1], SketchArc_30.results()[1]])
[SketchArc_32, SketchArc_33] = SketchConstraintMirror_5.mirrored()
SketchArc_33.setName("SketchArc_6")
model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [52])
model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [338])
model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [676])
-model.testResultsVolumes(Part_1, [48835.415011945384321734309196472])
+model.testResultsVolumes(Part_1, [48835.437112214101944118738174438])
model.testNbResults(Translation_4, 3)
model.testNbSubResults(Translation_4, [0, 0, 0])
SketchConstraintRadius_6.setName("SketchConstraintRadius_7")
SketchConstraintDistance_14 = Sketch_5.setDistance(SketchLine_33.endPoint(), SketchLine_30.result(), 20)
SketchConstraintDistance_14.setName("SketchConstraintDistance_17")
-SketchConstraintCoincidence_58 = Sketch_5.setCoincident(SketchLine_34.endPoint(), SketchLine_34.result())
-SketchConstraintCoincidence_58.setName("SketchConstraintCoincidence_65")
SketchConstraintCoincidence_59 = Sketch_5.setCoincident(SketchLine_34.endPoint(), SketchLine_37.startPoint())
SketchConstraintCoincidence_59.setName("SketchConstraintCoincidence_66")
SketchConstraintDistance_15 = Sketch_5.setDistance(SketchLine_37.startPoint(), SketchLine_30.result(), "DBody")
SketchConstraintCoincidence_81.setName("SketchConstraintCoincidence_153")
SketchConstraintCoincidence_82 = Sketch_6.setCoincident(SketchLine_40.endPoint(), SketchLine_39.startPoint())
SketchConstraintCoincidence_82.setName("SketchConstraintCoincidence_154")
-SketchConstraintCoincidence_83 = Sketch_6.setCoincident(SketchLine_41.startPoint(), SketchLine_41.result())
-SketchConstraintCoincidence_83.setName("SketchConstraintCoincidence_155")
SketchConstraintCoincidence_84 = Sketch_6.setCoincident(SketchLine_41.startPoint(), SketchLine_39.endPoint())
SketchConstraintCoincidence_84.setName("SketchConstraintCoincidence_156")
model.do()
SketchLine_54.setAuxiliary(True)
SketchConstraintCoincidence_86 = Sketch_7.setCoincident(SketchLine_52.endPoint(), SketchLine_54.startPoint())
SketchConstraintCoincidence_86.setName("SketchConstraintCoincidence_96")
-SketchLine_55 = Sketch_7.addLine(model.selection("EDGE", "RevolutionFuse_3_1/Modfied_17&RevolutionFuse_3_1/Modfied_10"))
+SketchLine_55 = Sketch_7.addLine(model.selection("EDGE", "RevolutionFuse_3_1/Modfied_13&RevolutionFuse_3_1/Modfied_10"))
SketchLine_55.setName("SketchLine_56")
SketchLine_55.result().setName("SketchLine_56")
SketchConstraintCoincidence_87 = Sketch_7.setCoincident(SketchLine_54.endPoint(), SketchLine_55.result())
SketchLine_77 = Sketch_10.addLine(64, 20, 89, 20)
SketchLine_77.setName("SketchLine_76")
SketchLine_77.result().setName("SketchLine_76")
-SketchPoint_4 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_2_1/Modfied_11&RevolutionFuse_2_1/Modfied_13&RevolutionFuse_3_1/Modfied_13&RevolutionFuse_3_1/Modfied_2"))
+SketchPoint_4 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_2_1/Modfied_11&RevolutionFuse_2_1/Modfied_13&RevolutionFuse_3_1/Modfied_15&RevolutionFuse_3_1/Modfied_4"))
SketchConstraintCoincidence_122 = Sketch_10.setCoincident(SketchLine_77.startPoint(), SketchPoint_4.result())
SketchConstraintCoincidence_122.setName("SketchConstraintCoincidence_120")
SketchPoint_5 = Sketch_10.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_8e-SketchLine_4e"))
SketchLine_78 = Sketch_10.addLine(64, -20, 89, -20)
SketchLine_78.setName("SketchLine_77")
SketchLine_78.result().setName("SketchLine_77")
-SketchPoint_6 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_1_1/Modfied_4&RevolutionFuse_1_1/Modfied_9&RevolutionFuse_3_1/Modfied_15&RevolutionFuse_3_1/Modfied_6"))
+SketchPoint_6 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_1_1/Modfied_4&RevolutionFuse_1_1/Modfied_9&RevolutionFuse_3_1/Modfied_17&RevolutionFuse_3_1/Modfied_8"))
SketchConstraintCoincidence_124 = Sketch_10.setCoincident(SketchLine_78.startPoint(), SketchPoint_6.result())
SketchConstraintCoincidence_124.setName("SketchConstraintCoincidence_122")
-SketchPoint_7 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionFuse_2_1/Modfied_2&RevolutionFuse_1_1/Modfied_4&ExtrusionFuse_2_1/Modfied_1&RevolutionFuse_3_1/Modfied_15"))
+SketchPoint_7 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionFuse_2_1/Modfied_2&RevolutionFuse_1_1/Modfied_4&ExtrusionFuse_2_1/Modfied_1&RevolutionFuse_3_1/Modfied_17"))
SketchConstraintCoincidence_125 = Sketch_10.setCoincident(SketchLine_78.endPoint(), SketchPoint_7.result())
SketchConstraintCoincidence_125.setName("SketchConstraintCoincidence_123")
SketchArc_10 = Sketch_10.addArc(89.00000104846708, 1.669244441022778e-015, 89, -20, 89, 20, False)
SketchConstraintCoincidence_129.setName("SketchConstraintCoincidence_127")
SketchConstraintTangent_19 = Sketch_10.setTangent(SketchArc_11.results()[1], SketchLine_78.result())
SketchConstraintTangent_19.setName("SketchConstraintTangent_24")
-SketchPoint_8 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_5&RevolutionFuse_3_1/Modfied_7&RevolutionFuse_3_1/Modfied_6&RevolutionFuse_3_1/Modfied_24&RevolutionFuse_3_1/Modfied_5"))
+SketchPoint_8 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_9&RevolutionFuse_3_1/Modfied_7&RevolutionFuse_3_1/Modfied_8&RevolutionFuse_3_1/Modfied_24&RevolutionFuse_3_1/Modfied_9"))
SketchConstraintCoincidence_130 = Sketch_10.setCoincident(SketchArc_11.endPoint(), SketchPoint_8.result())
SketchConstraintCoincidence_130.setName("SketchConstraintCoincidence_128")
SketchArc_12 = Sketch_10.addArc(64.00001789135865, 23.01137360115889, 64, 20, 61.15622559702543, 22.02080994708722, True)
SketchConstraintCoincidence_131.setName("SketchConstraintCoincidence_129")
SketchConstraintTangent_20 = Sketch_10.setTangent(SketchArc_12.results()[1], SketchLine_77.result())
SketchConstraintTangent_20.setName("SketchConstraintTangent_25")
-SketchPoint_9 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_5&RevolutionFuse_3_1/Modfied_3&RevolutionFuse_3_1/Modfied_2&RevolutionFuse_3_1/Modfied_24&RevolutionFuse_3_1/Modfied_1"))
+SketchPoint_9 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_9&RevolutionFuse_3_1/Modfied_3&RevolutionFuse_3_1/Modfied_4&RevolutionFuse_3_1/Modfied_24&RevolutionFuse_3_1/Modfied_5"))
SketchConstraintCoincidence_132 = Sketch_10.setCoincident(SketchArc_12.endPoint(), SketchPoint_9.result())
SketchConstraintCoincidence_132.setName("SketchConstraintCoincidence_130")
SketchLine_79 = Sketch_10.addLine(61.15622559702543, 22.02080994708722, 59.81204392543111, 22.0208099470871)
model.testNbSubResults(ExtrusionCut_4, [0])
model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.SOLID, [1])
model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.FACE, [81])
-model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.EDGE, [418])
-model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.VERTEX, [836])
-model.testResultsVolumes(ExtrusionCut_4, [502902.415176195616368204355239868])
+model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.EDGE, [406])
+model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.VERTEX, [812])
+model.testResultsVolumes(ExtrusionCut_4, [502902.431481667619664222002029419])
assert(model.checkPythonDump())
Part_1_doc = Part_1.document()
Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
SketchLine_1 = Sketch_1.addLine(55.1, 10.3, 55.1, 0.3)
-SketchLine_2 = Sketch_1.addLine(55.1, 0.3, 2.300000098190561, 0.3)
+SketchLine_2 = Sketch_1.addLine(55.1, 0.3, 2.3, 0.3)
SketchLine_2.setName("SketchLine_10")
SketchLine_2.result().setName("SketchLine_10")
SketchLine_3 = Sketch_1.addLine(55.1, 0.3, 0.3, 0.3)
SketchLine_3.result().setName("SketchLine_2")
SketchLine_3.setAuxiliary(True)
SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
-SketchLine_4 = Sketch_1.addLine(0.3, 2.299999958617008, 0.3, 10.3)
+SketchLine_4 = Sketch_1.addLine(0.3, 2.3, 0.3, 10.3)
SketchLine_4.setName("SketchLine_11")
SketchLine_4.result().setName("SketchLine_11")
-SketchLine_5 = Sketch_1.addLine(2.299981065494142, -1.390467145968888e-034, 55.4, -3.349267313974575e-033)
+SketchLine_5 = Sketch_1.addLine(2.3, 0, 55.4, 0)
SketchLine_5.setName("SketchLine_12")
SketchLine_5.result().setName("SketchLine_12")
SketchLine_6 = Sketch_1.addLine(0.3, 0.3, 0.3, 10.3)
SketchLine_6.result().setName("SketchLine_3")
SketchLine_6.setAuxiliary(True)
SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_6.startPoint())
-SketchLine_7 = Sketch_1.addLine(0, 10.3, 0, 2.300013086422291)
+SketchLine_7 = Sketch_1.addLine(0, 10.3, 0, 2.3)
SketchLine_7.setName("SketchLine_13")
SketchLine_7.result().setName("SketchLine_13")
SketchLine_8 = Sketch_1.addLine(0.3, 10.3, 0, 10.3)
SketchLine_9.setName("SketchLine_5")
SketchLine_9.result().setName("SketchLine_5")
SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.result())
-SketchLine_10 = Sketch_1.addLine(0, 10.3, 0, -3.349267313974575e-033)
+SketchLine_10 = Sketch_1.addLine(0, 10.3, 0, 0)
SketchLine_10.setName("SketchLine_6")
SketchLine_10.result().setName("SketchLine_6")
SketchLine_10.setAuxiliary(True)
SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_10.startPoint())
-SketchLine_11 = Sketch_1.addLine(0, -3.349267313974575e-033, 55.4, -3.349267313974575e-033)
+SketchLine_11 = Sketch_1.addLine(0, 0, 55.4, 0)
SketchLine_11.setName("SketchLine_7")
SketchLine_11.result().setName("SketchLine_7")
SketchLine_11.setAuxiliary(True)
SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
-SketchLine_12 = Sketch_1.addLine(55.4, -3.349267313974575e-033, 55.4, 10.3)
+SketchLine_12 = Sketch_1.addLine(55.4, 0, 55.4, 10.3)
SketchLine_12.setName("SketchLine_8")
SketchLine_12.result().setName("SketchLine_8")
SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
SketchConstraintLength_3.setName("SketchConstraintLength_5")
SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 0.3)
-SketchArc_1 = Sketch_1.addArc(2.3, 2.3, 0.3, 2.299999958617008, 2.300000098190561, 0.3, False)
+SketchArc_1 = Sketch_1.addArc(2.3, 2.3, 0.3, 2.3, 2.3, 0.3, False)
SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_4.startPoint())
SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_2.endPoint())
SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result())
SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_4.endPoint())
SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.result())
SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_4.startPoint(), SketchLine_6.result())
-SketchArc_2 = Sketch_1.addArc(2.3, 2.3, 0, 2.300013086422291, 2.299981065494142, -1.390467145968888e-034, False)
+SketchArc_2 = Sketch_1.addArc(2.3, 2.3, 0, 2.3, 2.3, 0, False)
SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_7.endPoint())
SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_5.startPoint())
SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_5.result())
Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_10f-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchLine_4f-SketchLine_8f-SketchLine_9f-SketchArc_1_2r-SketchArc_2_2f")], model.selection(), "307/2.", "307/2.")
Extrusion_1.setName("Profil")
Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_7"))
-SketchLine_14 = Sketch_2.addLine(149.5, -2.299981065494, 153.5, -2.299981065494142)
+SketchLine_14 = Sketch_2.addLine(149.5, -2.3, 153.5, -2.3)
SketchPoint_1 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/Generated_Face_6&Extrusion_1_1/To_Face_1"))
SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchPoint_1.result())
-SketchLine_15 = Sketch_2.addLine(153.5, -2.299981065494142, 153.5, 7.700018934505839)
-SketchLine_16 = Sketch_2.addLine(153.5, 7.700018934505839, 149.5, 7.700018934505839)
-SketchLine_17 = Sketch_2.addLine(149.5, 7.700018934505839, 149.5, -2.299981065494)
+SketchLine_15 = Sketch_2.addLine(153.5, -2.3, 153.5, 7.7)
+SketchLine_16 = Sketch_2.addLine(153.5, 7.7, 149.5, 7.7)
+SketchLine_17 = Sketch_2.addLine(149.5, 7.7, 149.5, -2.3)
SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchLine_14.startPoint())
SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_15.result())
SketchConstraintHorizontal_6 = Sketch_2.setHorizontal(SketchLine_16.result())
SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_17.result())
-SketchLine_18 = Sketch_2.addLine(-149.5, -2.299981065494142, -153.5, -2.299981065494142)
-SketchLine_19 = Sketch_2.addLine(-153.5, -2.299981065494142, -153.5, 7.700018934505858)
-SketchLine_20 = Sketch_2.addLine(-153.5, 7.700018934505858, -149.5, 7.700018934505858)
-SketchLine_21 = Sketch_2.addLine(-149.5, 7.700018934505858, -149.5, -2.299981065494142)
+SketchLine_18 = Sketch_2.addLine(-149.5, -2.3142, -153.5, -2.3142)
+SketchLine_19 = Sketch_2.addLine(-153.5, -2.3142, -153.5, 7.7)
+SketchLine_20 = Sketch_2.addLine(-153.5, 7.7, -149.5, 7.7)
+SketchLine_21 = Sketch_2.addLine(-149.5, 7.7, -149.5, -2.3142)
SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchLine_21.endPoint(), SketchLine_18.startPoint())
SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint())
SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchLine_19.endPoint(), SketchLine_20.startPoint())
ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")])
ExtrusionCut_1.setName("Decoupe_Angle")
Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_8"))
-SketchLine_22 = Sketch_3.addLine(153.5, -10.3, 153.5, -8.300000000000011)
+SketchLine_22 = Sketch_3.addLine(153.5, -10.3, 153.5, -8.3)
SketchLine_22.setName("SketchLine_29")
SketchLine_22.result().setName("SketchLine_29")
SketchPoint_3 = Sketch_3.addPoint(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_9&ExtrusionCut_1_1/Modfied_1&Extrusion_1_1/Generated_Face_8"))
SketchLine_23.result().setName("SketchLine_30")
SketchConstraintCoincidence_36 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.result())
SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_41")
-SketchLine_24 = Sketch_3.addLine(153.5, -8.300000000000011, 151.5, -10.3)
+SketchLine_24 = Sketch_3.addLine(153.5, -8.3, 151.5, -10.3)
SketchLine_24.setName("SketchLine_31")
SketchLine_24.result().setName("SketchLine_31")
SketchConstraintCoincidence_37 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_24.startPoint())
Sketch_3.result().setName("Sketch_4")
ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_1_1")])
ExtrusionCut_2.setName("Chamfrein_1")
-Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_6"))
-SketchLine_30 = Sketch_4.addLine(-149.5, 10.3, -149.5, 8.300000000000003)
+Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_7"))
+SketchLine_30 = Sketch_4.addLine(-149.5, 10.3, -149.5, 8.3)
SketchLine_30.setName("SketchLine_35")
SketchLine_30.result().setName("SketchLine_35")
-SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_10&ExtrusionCut_1_1/Modfied_6&ExtrusionCut_1_1/Modfied_5"))
+SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_11&ExtrusionCut_1_1/Modfied_7&ExtrusionCut_1_1/Modfied_6"))
SketchPoint_4.setName("SketchPoint_6")
SketchPoint_4.result().setName("SketchPoint_6")
SketchConstraintCoincidence_42 = Sketch_4.setCoincident(SketchLine_30.startPoint(), SketchPoint_4.result())
SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_43")
-SketchLine_31 = Sketch_4.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_10&ExtrusionCut_1_1/Modfied_6"))
+SketchLine_31 = Sketch_4.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_11&ExtrusionCut_1_1/Modfied_7"))
SketchLine_31.setName("SketchLine_36")
SketchLine_31.result().setName("SketchLine_36")
SketchConstraintCoincidence_43 = Sketch_4.setCoincident(SketchLine_30.endPoint(), SketchLine_31.result())
SketchConstraintCoincidence_43.setName("SketchConstraintCoincidence_48")
-SketchLine_32 = Sketch_4.addLine(-149.5, 8.300000000000003, -147.5, 10.3)
+SketchLine_32 = Sketch_4.addLine(-149.5, 8.3, -147.5, 10.3)
SketchLine_32.setName("SketchLine_37")
SketchLine_32.result().setName("SketchLine_37")
SketchConstraintCoincidence_44 = Sketch_4.setCoincident(SketchLine_30.endPoint(), SketchLine_32.startPoint())
model.do()
Sketch_4.setName("Sketch_5")
Sketch_4.result().setName("Sketch_5")
-ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_5")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_4"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")])
-Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_8"))
+ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_5")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_5"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")])
+Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_9"))
SketchLine_40 = Sketch_5.addLine(152.2999838762584, -21.04999053274691, 153.5, -21.04999053274714)
SketchLine_40.setName("SketchLine_58")
SketchLine_40.result().setName("SketchLine_58")
SketchLine_41 = Sketch_5.addLine(152.2999838292651, -45.04999053274704, 153.5, -45.04999053274702)
SketchLine_41.setName("SketchLine_57")
SketchLine_41.result().setName("SketchLine_57")
-SketchLine_42 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"))
+SketchLine_42 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_1_1/Modfied_9"))
SketchLine_42.setName("SketchLine_46")
SketchLine_42.result().setName("SketchLine_46")
SketchLine_43 = Sketch_5.addLine(150.8, -45.04999053274702, 153.5, -45.04999053274702)
SketchLine_44 = Sketch_5.addLine(153.5, -45.04999053274702, 153.5, -37.04999053274702)
SketchLine_44.setName("SketchLine_47")
SketchLine_44.result().setName("SketchLine_47")
-SketchLine_45 = Sketch_5.addLine(150.8000000000001, -14.54997391609652, 150.8000000000001, -19.54999029833178)
+SketchLine_45 = Sketch_5.addLine(150.8, -14.54997391609652, 150.8, -19.54999029833178)
SketchLine_45.setName("SketchLine_61")
SketchLine_45.result().setName("SketchLine_61")
SketchLine_46 = Sketch_5.addLine(153.5, -13.04999053274714, 152.2999838654776, -13.04999053274697)
SketchLine_49 = Sketch_5.addLine(153.5, -37.04999053274702, 152.2999989299055, -37.04999053274738)
SketchLine_49.setName("SketchLine_62")
SketchLine_49.result().setName("SketchLine_62")
-SketchLine_50 = Sketch_5.addLine(150.8, -38.54997391988981, 150.8000000000001, -43.54998998548124)
+SketchLine_50 = Sketch_5.addLine(150.8, -38.54997391988981, 150.8, -43.54998998548124)
SketchLine_50.setName("SketchLine_63")
SketchLine_50.result().setName("SketchLine_63")
-SketchLine_51 = Sketch_5.addLine(150.7999999999999, -21.04999053274714, 153.5, -21.04999053274714)
+SketchLine_51 = Sketch_5.addLine(150.8, -21.04999053274714, 153.5, -21.04999053274714)
SketchLine_51.setName("SketchLine_50")
SketchLine_51.result().setName("SketchLine_50")
SketchLine_51.setAuxiliary(True)
SketchLine_52 = Sketch_5.addLine(153.5, -21.04999053274714, 153.5, -13.04999053274714)
SketchLine_52.setName("SketchLine_51")
SketchLine_52.result().setName("SketchLine_51")
-SketchLine_53 = Sketch_5.addLine(150.7999999999999, -13.04999053274714, 150.7999999999999, -21.04999053274714)
+SketchLine_53 = Sketch_5.addLine(150.8, -13.04999053274714, 150.8, -21.04999053274714)
SketchLine_53.setAuxiliary(True)
SketchConstraintCoincidence_61 = Sketch_5.setCoincident(SketchLine_53.endPoint(), SketchLine_51.startPoint())
SketchConstraintCoincidence_61.setName("SketchConstraintCoincidence_66")
SketchConstraintCoincidence_62 = Sketch_5.setCoincident(SketchLine_51.endPoint(), SketchLine_52.startPoint())
SketchConstraintCoincidence_62.setName("SketchConstraintCoincidence_67")
-SketchLine_54 = Sketch_5.addLine(153.5, -13.04999053274714, 150.7999999999999, -13.04999053274714)
+SketchLine_54 = Sketch_5.addLine(153.5, -13.04999053274714, 150.8, -13.04999053274714)
SketchLine_54.setName("SketchLine_52")
SketchLine_54.result().setName("SketchLine_52")
SketchLine_54.setAuxiliary(True)
SketchLine_55.setAuxiliary(True)
SketchConstraintCoincidence_66 = Sketch_5.setCoincident(SketchPoint_5.coordinates(), SketchLine_55.startPoint())
SketchConstraintCoincidence_66.setName("SketchConstraintCoincidence_71")
-SketchLine_56 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_1_1/Modfied_8"))
+SketchLine_56 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_1_1/Modfied_9"))
SketchLine_56.setName("SketchLine_55")
SketchLine_56.result().setName("SketchLine_55")
SketchConstraintCoincidence_67 = Sketch_5.setCoincident(SketchLine_55.endPoint(), SketchLine_56.result())
SketchConstraintCoincidence_67.setName("SketchConstraintCoincidence_72")
SketchConstraintHorizontal_15 = Sketch_5.setHorizontal(SketchLine_55.result())
-SketchConstraintDistance_8 = Sketch_5.setDistance(SketchLine_48.result(), SketchPoint_5.coordinates(), 8.199999999999999)
+SketchConstraintDistance_8 = Sketch_5.setDistance(SketchLine_48.result(), SketchPoint_5.coordinates(), 8.2)
SketchConstraintDistance_9 = Sketch_5.setDistance(SketchLine_51.result(), SketchPoint_5.coordinates(), 7.8)
-SketchArc_3 = Sketch_5.addArc(152.3, -43.54999053274682, 150.8000000000001, -43.54998998548124, 152.2999838292651, -45.04999053274704, False)
-SketchLine_57 = Sketch_5.addLine(150.8, -37.04999053274702, 150.8000000000001, -43.54998998548124)
+SketchArc_3 = Sketch_5.addArc(152.3, -43.54999053274682, 150.8, -43.54998998548124, 152.2999838292651, -45.04999053274704, False)
+SketchLine_57 = Sketch_5.addLine(150.8, -37.04999053274702, 150.8, -43.54998998548124)
SketchLine_57.setName("SketchLine_56")
SketchLine_57.result().setName("SketchLine_56")
SketchLine_57.setAuxiliary(True)
SketchConstraintCoincidence_72.setName("SketchConstraintCoincidence_77")
SketchConstraintCoincidence_73 = Sketch_5.setCoincident(SketchLine_41.startPoint(), SketchLine_43.result())
SketchConstraintCoincidence_73.setName("SketchConstraintCoincidence_78")
-SketchArc_4 = Sketch_5.addArc(152.3, -19.54999053274696, 150.8000000000001, -19.54999029833178, 152.2999838762584, -21.04999053274691, False)
-SketchLine_58 = Sketch_5.addLine(150.7999999999999, -13.04999053274714, 150.8000000000001, -19.54999029833178)
+SketchArc_4 = Sketch_5.addArc(152.3, -19.54999053274696, 150.8, -19.54999029833178, 152.2999838762584, -21.04999053274691, False)
+SketchLine_58 = Sketch_5.addLine(150.8, -13.04999053274714, 150.8, -19.54999029833178)
SketchLine_58.setName("SketchLine_59")
SketchLine_58.result().setName("SketchLine_59")
SketchLine_58.setAuxiliary(True)
SketchConstraintCoincidence_78.setName("SketchConstraintCoincidence_83")
SketchConstraintCoincidence_79 = Sketch_5.setCoincident(SketchLine_58.endPoint(), SketchLine_53.result())
SketchConstraintCoincidence_79.setName("SketchConstraintCoincidence_84")
-SketchArc_5 = Sketch_5.addArc(152.2999999999999, -14.54999053274707, 152.2999838654776, -13.04999053274697, 150.8000000000001, -14.54997391609652, False)
+SketchArc_5 = Sketch_5.addArc(152.3, -14.54999053274707, 152.2999838654776, -13.04999053274697, 150.8, -14.54997391609652, False)
SketchConstraintCoincidence_80 = Sketch_5.setCoincident(SketchArc_5.startPoint(), SketchLine_46.endPoint())
SketchConstraintCoincidence_80.setName("SketchConstraintCoincidence_85")
SketchConstraintCoincidence_81 = Sketch_5.setCoincident(SketchArc_5.endPoint(), SketchLine_45.startPoint())
model.do()
Sketch_5.setName("Sketch_6")
Sketch_5.result().setName("Sketch_6")
-ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchArc_9_2f-SketchArc_10_2f-SketchLine_73r-SketchLine_74r-SketchLine_75r-SketchLine_76r"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_58f-SketchLine_61f-SketchLine_60f-SketchLine_51f-SketchArc_4_2f-SketchArc_5_2f"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_57f-SketchLine_47f-SketchLine_62f-SketchLine_63f-SketchArc_3_2f-SketchArc_6_2f")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_3_1")])
+ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_6/Wire-SketchArc_9_2f-SketchArc_10_2f-SketchLine_73r-SketchLine_74r-SketchLine_75r-SketchLine_76r"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_58f-SketchLine_61f-SketchLine_60f-SketchLine_51f-SketchArc_4_2f-SketchArc_5_2f"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_57f-SketchLine_47f-SketchLine_62f-SketchLine_63f-SketchArc_3_2f-SketchArc_6_2f")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_3_1")])
Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_4_1/Modfied_1"))
-SketchArc_11 = Sketch_6.addArc(44.88999999999999, -23.54999053274703, 43.88999999999999, -23.54999053274703, 44.88999999999999, -22.54999053274703, False)
-SketchArc_12 = Sketch_6.addArc(44.88999999999999, -13.54999053274703, 44.88999999999999, -14.54999053274703, 43.88999999999999, -13.54999053274703, False)
+SketchArc_11 = Sketch_6.addArc(44.89, -23.54999053274703, 43.89, -23.54999053274703, 44.89, -22.54999053274703, False)
+SketchArc_12 = Sketch_6.addArc(44.89, -13.54999053274703, 44.89, -14.54999053274703, 43.89, -13.54999053274703, False)
SketchArc_13 = Sketch_6.addArc(5.89, -13.54999053274703, 6.89, -13.54999053274703, 5.89, -14.54999053274703, False)
SketchArc_13.setName("SketchArc_14")
SketchArc_13.result().setName("SketchArc_14")
SketchArc_13.results()[1].setName("SketchArc_14_2")
-SketchLine_76 = Sketch_6.addLine(6.890000000000002, -23.54999053274703, 43.88999999999999, -23.54999053274703)
+SketchLine_76 = Sketch_6.addLine(6.89, -23.54999053274703, 43.89, -23.54999053274703)
SketchLine_76.setName("SketchLine_81")
SketchLine_76.result().setName("SketchLine_81")
SketchConstraintCoincidence_92 = Sketch_6.setCoincident(SketchArc_11.startPoint(), SketchLine_76.endPoint())
SketchConstraintCoincidence_92.setName("SketchConstraintCoincidence_98")
-SketchLine_77 = Sketch_6.addLine(6.89, -13.54999053274703, 43.88999999999999, -13.54999053274703)
+SketchLine_77 = Sketch_6.addLine(6.89, -13.54999053274703, 43.89, -13.54999053274703)
SketchLine_77.setName("SketchLine_82")
SketchLine_77.result().setName("SketchLine_82")
SketchConstraintCoincidence_93 = Sketch_6.setCoincident(SketchArc_13.startPoint(), SketchLine_77.startPoint())
SketchConstraintCoincidence_93.setName("SketchConstraintCoincidence_99")
-SketchLine_78 = Sketch_6.addLine(44.88999999999999, -22.54999053274703, 44.88999999999999, -14.54999053274703)
+SketchLine_78 = Sketch_6.addLine(44.89, -22.54999053274703, 44.89, -14.54999053274703)
SketchLine_78.setName("SketchLine_83")
SketchLine_78.result().setName("SketchLine_83")
SketchConstraintCoincidence_94 = Sketch_6.setCoincident(SketchArc_12.startPoint(), SketchLine_78.endPoint())
SketchLine_81.setName("SketchLine_86")
SketchLine_81.result().setName("SketchLine_86")
SketchConstraintDistance_13 = Sketch_6.setDistance(SketchLine_76.endPoint(), SketchLine_81.result(), 5.3)
-SketchArc_14 = Sketch_6.addArc(5.890000000000002, -23.54999053274703, 5.89, -22.54999053274703, 6.890000000000002, -23.54999053274703, False)
+SketchArc_14 = Sketch_6.addArc(5.89, -23.54999053274703, 5.89, -22.54999053274703, 6.89, -23.54999053274703, False)
SketchArc_14.setName("SketchArc_15")
SketchArc_14.result().setName("SketchArc_15")
SketchArc_14.results()[1].setName("SketchArc_15_2")
SketchArc_23.setName("SketchArc_24")
SketchArc_23.result().setName("SketchArc_24")
SketchArc_23.results()[1].setName("SketchArc_24_2")
-SketchPoint_9 = Sketch_6.addPoint(1.460819920296274e-014, -49.84999053274704)
+SketchPoint_9 = Sketch_6.addPoint(0, -49.84999053274704)
SketchPoint_9.setName("SketchPoint_11")
SketchPoint_9.result().setName("SketchPoint_11")
SketchConstraintCoincidence_112 = Sketch_6.setCoincident(SketchPoint_9.coordinates(), SketchLine_80.result())
model.do()
Sketch_6.setName("Sketch_7")
Sketch_6.result().setName("Sketch_7")
-ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchArc_20_2f-SketchArc_21_2f-SketchArc_22_2f-SketchArc_23_2f-SketchLine_91r-SketchLine_92f-SketchLine_93r-SketchLine_94f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_52_2f-SketchArc_53_2f-SketchArc_56_2f-SketchArc_57_2f-SketchLine_114r-SketchLine_115f-SketchLine_116r-SketchLine_121f"), model.selection("FACE", "Sketch_7/Face-SketchArc_44_2f-SketchArc_45_2f-SketchArc_48_2f-SketchArc_49_2f-SketchLine_107f-SketchLine_113f-SketchLine_117r-SketchLine_123r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_16_2f-SketchArc_17_2f-SketchArc_18_2f-SketchArc_19_2f-SketchLine_87f-SketchLine_88f-SketchLine_89r-SketchLine_90r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_11_2f-SketchArc_12_2f-SketchArc_14_2f-SketchLine_81f-SketchLine_82r-SketchLine_83f-SketchLine_84r-SketchArc_15_2f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_36_2f-SketchArc_38_2f-SketchArc_40_2f-SketchArc_41_2f-SketchLine_108r-SketchLine_119r-SketchLine_127f-SketchLine_129f"), model.selection("FACE", "Sketch_7/Face-SketchArc_37_2f-SketchArc_39_2f-SketchArc_42_2f-SketchArc_43_2f-SketchLine_118r-SketchLine_120f-SketchLine_122r-SketchLine_130f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_24_2f-SketchArc_25_2f-SketchArc_26_2f-SketchArc_27_2f-SketchLine_98f-SketchLine_100r-SketchLine_101f-SketchLine_103r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_30_2f-SketchArc_31_2f-SketchArc_34_2f-SketchArc_35_2f-SketchLine_95f-SketchLine_96r-SketchLine_97f-SketchLine_105r"), model.selection("FACE", "Sketch_7/Face-SketchArc_46_2f-SketchArc_47_2f-SketchArc_50_2f-SketchArc_51_2f-SketchLine_124f-SketchLine_125r-SketchLine_126f-SketchLine_128r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_54_2f-SketchArc_55_2f-SketchArc_58_2f-SketchArc_59_2f-SketchLine_109f-SketchLine_110r-SketchLine_111r-SketchLine_112f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_28_2f-SketchArc_29_2f-SketchArc_32_2f-SketchArc_33_2f-SketchLine_99r-SketchLine_102f-SketchLine_104f-SketchLine_106r")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_4_1")])
+ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchArc_20_2f-SketchArc_21_2f-SketchArc_22_2f-SketchArc_23_2f-SketchLine_91r-SketchLine_92f-SketchLine_93r-SketchLine_94f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_52_2f-SketchArc_53_2f-SketchArc_56_2f-SketchArc_57_2f-SketchLine_114r-SketchLine_115f-SketchLine_116r-SketchLine_121f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_44_2f-SketchArc_45_2f-SketchArc_48_2f-SketchArc_49_2f-SketchLine_107f-SketchLine_113f-SketchLine_117r-SketchLine_123r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_16_2f-SketchArc_17_2f-SketchArc_18_2f-SketchArc_19_2f-SketchLine_87f-SketchLine_88f-SketchLine_89r-SketchLine_90r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_11_2f-SketchArc_12_2f-SketchArc_14_2f-SketchLine_81f-SketchLine_82r-SketchLine_83f-SketchLine_84r-SketchArc_15_2f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_36_2f-SketchArc_38_2f-SketchArc_40_2f-SketchArc_41_2f-SketchLine_108r-SketchLine_119r-SketchLine_127f-SketchLine_129f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_37_2f-SketchArc_39_2f-SketchArc_42_2f-SketchArc_43_2f-SketchLine_118r-SketchLine_120f-SketchLine_122r-SketchLine_130f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_24_2f-SketchArc_25_2f-SketchArc_26_2f-SketchArc_27_2f-SketchLine_98f-SketchLine_100r-SketchLine_101f-SketchLine_103r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_30_2f-SketchArc_31_2f-SketchArc_34_2f-SketchArc_35_2f-SketchLine_95f-SketchLine_96r-SketchLine_97f-SketchLine_105r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_46_2f-SketchArc_47_2f-SketchArc_50_2f-SketchArc_51_2f-SketchLine_124f-SketchLine_125r-SketchLine_126f-SketchLine_128r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_54_2f-SketchArc_55_2f-SketchArc_58_2f-SketchArc_59_2f-SketchLine_109f-SketchLine_110r-SketchLine_111r-SketchLine_112f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_28_2f-SketchArc_29_2f-SketchArc_32_2f-SketchArc_33_2f-SketchLine_99r-SketchLine_102f-SketchLine_104f-SketchLine_106r")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_4_1")])
Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_5_1/Modfied_1"))
SketchLine_126 = Sketch_7.addLine(-153.5, -37.049990532747, -152.3000099350335, -37.0499905327475)
SketchLine_126.setName("SketchLine_135")
SketchLine_126.result().setName("SketchLine_135")
-SketchLine_127 = Sketch_7.addLine(-150.7999999999999, -38.54999290880026, -150.8, -43.54999111476925)
+SketchLine_127 = Sketch_7.addLine(-150.8, -38.54999290880026, -150.8, -43.54999111476925)
SketchLine_127.setName("SketchLine_138")
SketchLine_127.result().setName("SketchLine_138")
SketchPoint_10 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_6/Vertex-SketchLine_67s-SketchLine_68e-SketchLine_69e"))
SketchPoint_11.result().setName("SketchPoint_13")
SketchConstraintCoincidence_118 = Sketch_7.setCoincident(SketchLine_132.endPoint(), SketchPoint_11.result())
SketchConstraintCoincidence_118.setName("SketchConstraintCoincidence_125")
-SketchArc_59 = Sketch_7.addArc(-152.3, -38.54999053274712, -150.7999999999999, -38.54999290880026, -152.3000099350335, -37.0499905327475, False)
+SketchArc_59 = Sketch_7.addArc(-152.3, -38.54999053274712, -150.8, -38.54999290880026, -152.3000099350335, -37.0499905327475, False)
SketchArc_59.setName("SketchArc_60")
SketchArc_59.result().setName("SketchArc_60")
SketchArc_59.results()[1].setName("SketchArc_60_2")
-SketchLine_133 = Sketch_7.addLine(-150.7999999999999, -38.54999290880026, -150.8, -45.049990532747)
+SketchLine_133 = Sketch_7.addLine(-150.8, -38.54999290880026, -150.8, -45.049990532747)
SketchLine_133.setName("SketchLine_136")
SketchLine_133.result().setName("SketchLine_136")
SketchLine_133.setAuxiliary(True)
Sketch_7.result().setName("Sketch_8")
ExtrusionCut_6 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_8")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_5_1")])
Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_6_1/Modfied_2"))
-SketchLine_134 = Sketch_8.addLine(0.8499999999999983, 50.75, -0.8500000000000015, 50.75)
+SketchLine_134 = Sketch_8.addLine(0.85, 50.75, -0.85, 50.75)
SketchLine_134.setName("SketchLine_139")
SketchLine_134.result().setName("SketchLine_139")
-SketchLine_135 = Sketch_8.addLine(-0.8500000000000015, 47.45, 0.8499999999999983, 47.45)
+SketchLine_135 = Sketch_8.addLine(-0.85, 47.45, 0.85, 47.45)
SketchLine_135.setName("SketchLine_141")
SketchLine_135.result().setName("SketchLine_141")
SketchConstraintHorizontal_20 = Sketch_8.setHorizontal(SketchLine_134.result())
SketchConstraintHorizontal_21 = Sketch_8.setHorizontal(SketchLine_135.result())
-SketchArc_61 = Sketch_8.addArc(0.8499999999999999, 49.1, 0.8499999999999983, 47.45, 0.8499999999999983, 50.75, False)
+SketchArc_61 = Sketch_8.addArc(0.85, 49.1, 0.85, 47.45, 0.85, 50.75, False)
SketchArc_61.setName("SketchArc_63")
SketchArc_61.result().setName("SketchArc_63")
SketchArc_61.results()[1].setName("SketchArc_63_2")
SketchConstraintCoincidence_132 = Sketch_8.setCoincident(SketchArc_61.startPoint(), SketchLine_135.endPoint())
SketchConstraintCoincidence_132.setName("SketchConstraintCoincidence_148")
SketchConstraintDistance_17 = Sketch_8.setDistance(SketchLine_134.result(), SketchLine_135.endPoint(), 3.3)
-SketchLine_136 = Sketch_8.addLine(0.8499999999999983, 50.75, 0.8499999999999983, 47.45)
+SketchLine_136 = Sketch_8.addLine(0.85, 50.75, 0.85, 47.45)
SketchLine_136.setName("SketchLine_140")
SketchLine_136.result().setName("SketchLine_140")
SketchLine_136.setAuxiliary(True)
SketchConstraintCoincidence_135.setName("SketchConstraintCoincidence_140")
SketchConstraintCoincidence_136 = Sketch_8.setCoincident(SketchArc_61.startPoint(), SketchLine_136.endPoint())
SketchConstraintCoincidence_136.setName("SketchConstraintCoincidence_141")
-SketchLine_137 = Sketch_8.addLine(-0.8500000000000015, 50.75, -0.8500000000000015, 47.45)
+SketchLine_137 = Sketch_8.addLine(-0.85, 50.75, -0.85, 47.45)
SketchLine_137.setName("SketchLine_142")
SketchLine_137.result().setName("SketchLine_142")
SketchLine_137.setAuxiliary(True)
SketchConstraintLength_10.setName("SketchConstraintLength_11")
SketchConstraintVertical_17 = Sketch_8.setVertical(SketchLine_137.result())
SketchConstraintVertical_18 = Sketch_8.setVertical(SketchLine_136.result())
-SketchLine_138 = Sketch_8.addLine(0.8499999999999983, 50.75, -0.8500000000000015, 47.45)
+SketchLine_138 = Sketch_8.addLine(0.85, 50.75, -0.85, 47.45)
SketchLine_138.setName("SketchLine_143")
SketchLine_138.result().setName("SketchLine_143")
SketchLine_138.setAuxiliary(True)
SketchLine_139.result().setName("SketchLine_144")
SketchConstraintCoincidence_145 = Sketch_8.setCoincident(SketchPoint_12.coordinates(), SketchLine_139.result())
SketchConstraintCoincidence_145.setName("SketchConstraintCoincidence_157")
-SketchArc_62 = Sketch_8.addArc(-0.8500000000000004, 49.1, -0.8500000000000015, 50.75, -0.8500000000000015, 47.45, False)
+SketchArc_62 = Sketch_8.addArc(-0.85, 49.1, -0.85, 50.75, -0.85, 47.45, False)
SketchConstraintCoincidence_146 = Sketch_8.setCoincident(SketchLine_135.startPoint(), SketchArc_62.endPoint())
SketchConstraintCoincidence_146.setName("SketchConstraintCoincidence_149")
SketchConstraintCoincidence_147 = Sketch_8.setCoincident(SketchLine_137.endPoint(), SketchArc_62.endPoint())
model.testNbSubResults(ExtrusionCut_7, [0])
model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.SOLID, [1])
model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.FACE, [156])
-model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.EDGE, [920])
-model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.VERTEX, [1840])
-model.testResultsVolumes(ExtrusionCut_7, [5345.689532925511230132542550564])
+model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.EDGE, [916])
+model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.VERTEX, [1832])
+model.testResultsVolumes(ExtrusionCut_7, [5345.689484659372283203992992640])
assert(model.checkPythonDump)
SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_20")
SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchArc_3.results()[1])
SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchArc_2.results()[1])
+model.do()
+
+# check overconstraint message appears
+assert Sketch_1.solverError().value() != "", "FAILED: Sketch should report over-constrained situation"
+# remove duplicated Tangent constraint
+Part_1_doc.removeFeature(SketchConstraintTangent_3.feature())
+model.do()
+assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
+
+# continue creating model
SketchLine_8 = Sketch_1.addLine(16.63997893808557, 190, 16.63997893808557, 184)
SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_8.startPoint())
SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_21")
model.testNbSubShapes(Boolean_1, GeomAPI_Shape.FACE, [35])
model.testNbSubShapes(Boolean_1, GeomAPI_Shape.EDGE, [162])
model.testNbSubShapes(Boolean_1, GeomAPI_Shape.VERTEX, [324])
-model.testResultsVolumes(Boolean_1, [2053931.831648423336446285247802734])
+model.testResultsVolumes(Boolean_1, [2053931.555419394280761480331420898])
assert(model.checkPythonDump())