ADD_SUBDIRECTORY (src/ConstructionPlugin)
ADD_SUBDIRECTORY (src/FeaturesPlugin)
ADD_SUBDIRECTORY (src/SketcherPrs)
+ADD_SUBDIRECTORY (src/PythonFeaturesPlugin)
ADD_SUBDIRECTORY (src/SketchPlugin)
ADD_SUBDIRECTORY (src/SketchSolver)
ADD_SUBDIRECTORY (src/ModuleBase)
FIND_PROGRAM(DOXYGEN_EXECUTABLE doxygen)
ENDIF(WIN32)
+IF(HAVE_SALOME)
+ SET(EXCLUDE_DOC_DIR "*/AppElements/*")
+ELSE(HAVE_SALOME)
+ SET(EXCLUDE_DOC_DIR "*/NewGeom/*")
+ENDIF(HAVE_SALOME)
+
CONFIGURE_FILE(doxyfile.in
"${CMAKE_CURRENT_BINARY_DIR}/doxyfile"
IMMEDIATE @ONLY)
# against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/*
-EXCLUDE_PATTERNS = */Test/*.py
-# (Python unit tests excluded)
+# Python unit tests excluded
+EXCLUDE_PATTERNS = */Test/*.py \
+ @EXCLUDE_DOC_DIR@
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
\code
void ConstructionPlugin_Point::initAttributes()
{
- data()->addAttribute("DoubleCounterData", ModelAPI_AttributeDouble::type());
+ data()->addAttribute("DoubleCounterData", ModelAPI_AttributeDouble::typeId());
}
\endcode
Python:
\code
def initAttributes(self):
- self.data().addAttribute("DoubleCounterData", ModelAPI.ModelAPI_AttributeDouble.type())
+ self.data().addAttribute("DoubleCounterData", ModelAPI.ModelAPI_AttributeDouble.typeId())
\endcode
As you may notice, this method defines that feature has a widget with "DoubleCounterData" id, which has Double type. Therefore, if your feature uses, in example, three widgets, the `initAttributes()` method should 'init' three attributes.
\n
Config_PropManager.h
Config_AttributeMessage.h
Config_SelectionFilterMessage.h
+ Config_ValidatorReader.h
)
SET(PROJECT_SOURCES
Config_PropManager.cpp
Config_AttributeMessage.cpp
Config_SelectionFilterMessage.cpp
+ Config_ValidatorReader.cpp
)
SET(XML_RESOURCES
storeAttribute(theNode, _ID); // save case:caseId (or box:boxId)
}
}
- //Process SOURCE, VALIDATOR nodes.
+ //Process SOURCE nodes.
Config_XMLReader::processNode(theNode);
}
}
outFeatureMessage->setDocumentKind(aDocKind);
}
-
-void Config_FeatureReader::storeAttribute(xmlNodePtr theNode,
- const char* theNodeAttribute)
-{
- std::string aKey = getNodeName(theNode) + ":" + std::string(theNodeAttribute);
- std::string aValue = getProperty(theNode, theNodeAttribute);
- if(!aValue.empty()) {
- myParentAttributes[aKey] = aValue;
- }
-}
-
-std::string Config_FeatureReader::restoreAttribute(xmlNodePtr theNode,
- const char* theNodeAttribute)
-{
- return restoreAttribute(getNodeName(theNode).c_str(), theNodeAttribute);
-}
-std::string Config_FeatureReader::restoreAttribute(const char* theNodeName,
- const char* theNodeAttribute)
-{
- std::string aKey = std::string(theNodeName) + ":" + std::string(theNodeAttribute);
- std::string result = "";
- if(myParentAttributes.find(aKey) != myParentAttributes.end()) {
- result = myParentAttributes[aKey];
- }
- return result;
-}
-
-bool Config_FeatureReader::cleanupAttribute(xmlNodePtr theNode,
- const char* theNodeAttribute)
-{
- return cleanupAttribute(getNodeName(theNode).c_str(), theNodeAttribute);
-}
-
-bool Config_FeatureReader::cleanupAttribute(const char* theNodeName,
- const char* theNodeAttribute)
-{
- std::string aKey = std::string(theNodeName) + ":" + std::string(theNodeAttribute);
- bool result = false;
- std::map<std::string, std::string>::iterator anEntry = myParentAttributes.find(aKey);
- if( anEntry != myParentAttributes.end()) {
- myParentAttributes.erase(anEntry);
- result = true;
- }
- return result;
-}
-
#include <string>
#include <list>
-#include <map>
class Config_FeatureMessage;
void fillFeature(xmlNodePtr theRoot,
const std::shared_ptr<Config_FeatureMessage>& outFeatureMessage);
- /// Stores an attribute in internal map for later use.
- /// Key is "Node_Name:Node_Attribute" and value is getProperty(theNodeAttribute)
- void storeAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
- /// Restores an attribute from internal map.
- std::string restoreAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
- /// Restores an attribute from internal map.
- std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
-
- bool cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
- bool cleanupAttribute(const char* theNodeName, const char* theNodeAttribute);
-
private:
- /// A map to store all parent's attributes.
- /// The key has from "Node_Name:Node_Attribute"
- std::map<std::string, std::string> myParentAttributes;
std::string myLibraryName;
std::list<std::string> myFeatures;
return myFeaturesInFiles;
}
+const std::set<std::string>& Config_ModuleReader::modulePluginFiles() const
+{
+ return myPluginFiles;
+}
+
/*!
* Get module name from plugins.xml
* (property "module")
if (!hasRequiredModules(theNode))
return;
std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG);
+ if (!aPluginConf.empty()) myPluginFiles.insert(aPluginConf);
std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY);
std::string aPluginScript = getProperty(theNode, PLUGIN_SCRIPT);
std::string aPluginName = addPlugin(aPluginLibrary, aPluginScript, aPluginConf);
CONFIG_EXPORT virtual ~Config_ModuleReader();
/// Returns map that describes which file contains a feature (the feature is key, the file is value)
CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
+ /// Returns list of module's xml files
+ CONFIG_EXPORT const std::set<std::string>& modulePluginFiles() const;
/// Returns module name: an xml attribute from the root of the plugins.xml:
/// e.g \code <plugins module="PartSet"> \endcode
CONFIG_EXPORT std::string getModuleName();
private:
std::map<std::string, std::string> myFeaturesInFiles; ///< a feature name is key, a file is value
+ std::set<std::string> myPluginFiles; ///< a feature name is key, a file is value
static std::map<std::string, PluginType> myPluginTypes; ///< a plugin name is key, a plugin type is value
static std::set<std::string> myDependencyModules; ///< set of loaded modules
const char* myEventGenerated; ///< gives ability to send Feature_Messages to various listeners
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * Config_ValidatorReader.cpp
+ *
+ * Created on: Mar 20, 2015
+ * Author: sbh
+ */
+
+#include <Config_ValidatorReader.h>
+#include <Config_Keywords.h>
+#include <Config_Common.h>
+#include <Config_ValidatorMessage.h>
+#include <Config_SelectionFilterMessage.h>
+#include <Config_PropManager.h>
+
+#include <Events_Loop.h>
+#include <Events_Error.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#include <fstream>
+
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
+Config_ValidatorReader::Config_ValidatorReader(const std::string& theXmlFileName)
+: Config_XMLReader(theXmlFileName)
+{
+}
+
+Config_ValidatorReader::~Config_ValidatorReader()
+{
+}
+
+void Config_ValidatorReader::processNode(xmlNodePtr theNode)
+{
+ if (isNode(theNode, NODE_VALIDATOR, NULL)) {
+ processValidator(theNode);
+ } else if (isNode(theNode, NODE_SELFILTER, NULL)) {
+ processSelectionFilter(theNode);
+ } else if (isNode(theNode, NODE_FEATURE, NULL)) {
+ storeAttribute(theNode, _ID);
+ }
+ //Process SOURCE nodes.
+ Config_XMLReader::processNode(theNode);
+}
+
+bool Config_ValidatorReader::processChildren(xmlNodePtr aNode)
+{
+ return true;
+}
+
+void Config_ValidatorReader::processValidator(xmlNodePtr theNode)
+{
+ Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED);
+ Events_Loop* aEvLoop = Events_Loop::loop();
+ std::shared_ptr<Config_ValidatorMessage>
+ aMessage(new Config_ValidatorMessage(aValidatoEvent, this));
+ std::string aValidatorId;
+ std::list<std::string> aParameters;
+ getParametersInfo(theNode, aValidatorId, aParameters);
+ aMessage->setValidatorId(aValidatorId);
+ aMessage->setValidatorParameters(aParameters);
+ //TODO(sbh): update feature/attribute id restoring
+ // when "cleanup" technique will be available (v. >= 1.1.0)
+ xmlNodePtr aFeatureOrWdgNode = theNode->parent;
+ if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
+ aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
+ } else {
+ aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
+ aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID));
+ }
+ aEvLoop->send(aMessage);
+}
+
+void Config_ValidatorReader::processSelectionFilter(xmlNodePtr theNode)
+{
+ Events_ID aFilterEvent = Events_Loop::eventByName(EVENT_SELFILTER_LOADED);
+ Events_Loop* aEvLoop = Events_Loop::loop();
+ std::shared_ptr<Config_SelectionFilterMessage> aMessage =
+ std::make_shared<Config_SelectionFilterMessage>(aFilterEvent, this);
+ std::string aSelectionFilterId;
+ std::list<std::string> aParameters;
+ getParametersInfo(theNode, aSelectionFilterId, aParameters);
+ aMessage->setSelectionFilterId(aSelectionFilterId);
+ aMessage->setFilterParameters(aParameters);
+
+ xmlNodePtr aFeatureOrWdgNode = theNode->parent;
+ if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
+ aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
+ } else {
+ aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
+ aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID));
+ }
+ aEvLoop->send(aMessage);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * Config_ValidatorReader.h
+ *
+ * Created on: Mar 20, 2015
+ * Author: sbh
+ */
+
+#ifndef CONFIG_VALIDATORREADER_H_
+#define CONFIG_VALIDATORREADER_H_
+
+#include <Config_def.h>
+#include <Config_XMLReader.h>
+
+#include <cstdarg>
+#include <string>
+
+/*!
+ * \class Config_ValidatorReader
+ * \ingroup Config
+ * \brief Base class for all libxml readers. Provides high-level API
+ * for all xml operations.
+*/
+class Config_ValidatorReader : public Config_XMLReader
+{
+ public:
+ /*!
+ * Constructor
+ * \param theXmlFile - full path to the xml file which will be processed by the reader
+ */
+ CONFIG_EXPORT Config_ValidatorReader(const std::string& theXmlFile);
+ CONFIG_EXPORT virtual ~Config_ValidatorReader();
+
+ protected:
+ /*!
+ * \brief Allows to customize reader's behavior for a node. Virtual.
+ * The default implementation process "source", "validator" and
+ * "selection_filter" nodes.
+ */
+ virtual void processNode(xmlNodePtr aNode);
+ /*!
+ * \brief Defines which nodes should be processed recursively. Virtual.
+ * The default impl is to read all nodes.
+ */
+ virtual bool processChildren(xmlNodePtr aNode);
+
+ /*!
+ * \brief Retrieves all the necessary info from the validator node.
+ * Sends ValidatorLoaded event
+ */
+ void processValidator(xmlNodePtr theNode);
+ /*!
+ * \brief Retrieves all the necessary info from the SelectionFilter node.
+ * Sends SelectionFilterLoaded event
+ */
+ void processSelectionFilter(xmlNodePtr theNode);
+};
+
+#endif /* CONFIG_VALIDATORREADER_H_ */
void Config_WidgetReader::processNode(xmlNodePtr theNode)
{
if (isNode(theNode, NODE_FEATURE, NULL)) {
- myCurrentFeature = getProperty(theNode, _ID);
- myWidgetCache[myCurrentFeature] = dumpNode(theNode);
- myDescriptionCache[myCurrentFeature] = getProperty(theNode, FEATURE_TEXT);
+ std::string aFeature = getProperty(theNode, _ID);
+ myWidgetCache[aFeature] = dumpNode(theNode);
+ myDescriptionCache[aFeature] = getProperty(theNode, FEATURE_TEXT);
}
//Process SOURCE nodes.
Config_XMLReader::processNode(theNode);
#include <Config_XMLReader.h>
#include <Config_Keywords.h>
#include <Config_Common.h>
-#include <Config_ValidatorMessage.h>
-#include <Config_SelectionFilterMessage.h>
#include <Config_PropManager.h>
#include <Events_Loop.h>
Config_XMLReader aSourceReader = Config_XMLReader(aSourceFile);
readRecursively(aSourceReader.findRoot());
#ifdef _DEBUG
- std::cout << "Config_XMLReader::sourced node: " << aSourceFile << std::endl;
+ //std::cout << "Config_XMLReader::sourced node: " << aSourceFile << std::endl;
#endif
- } else if (isNode(theNode, NODE_VALIDATOR, NULL)) {
- processValidator(theNode);
- } else if (isNode(theNode, NODE_SELFILTER, NULL)) {
- processSelectionFilter(theNode);
}
}
return result;
}
-void Config_XMLReader::processValidator(xmlNodePtr theNode)
+void Config_XMLReader::storeAttribute(xmlNodePtr theNode, const char* theAttribute)
{
- Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED);
- Events_Loop* aEvLoop = Events_Loop::loop();
- std::shared_ptr<Config_ValidatorMessage>
- aMessage(new Config_ValidatorMessage(aValidatoEvent, this));
- std::string aValidatorId;
- std::list<std::string> aParameters;
- getParametersInfo(theNode, aValidatorId, aParameters);
- aMessage->setValidatorId(aValidatorId);
- aMessage->setValidatorParameters(aParameters);
- xmlNodePtr aFeatureOrWdgNode = theNode->parent;
- if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
- aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
- } else {
- aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
- aMessage->setFeatureId(myCurrentFeature);
+ std::string aKey = getNodeName(theNode) + ":" + std::string(theAttribute);
+ std::string aValue = getProperty(theNode, theAttribute);
+ if(!aValue.empty()) {
+ myCachedAttributes[aKey] = aValue;
}
- aEvLoop->send(aMessage);
}
-void Config_XMLReader::processSelectionFilter(xmlNodePtr theNode)
+std::string Config_XMLReader::restoreAttribute(xmlNodePtr theNode, const char* theAttribute)
{
- Events_ID aFilterEvent = Events_Loop::eventByName(EVENT_SELFILTER_LOADED);
- Events_Loop* aEvLoop = Events_Loop::loop();
- std::shared_ptr<Config_SelectionFilterMessage> aMessage =
- std::make_shared<Config_SelectionFilterMessage>(aFilterEvent, this);
- std::string aSelectionFilterId;
- std::list<std::string> aParameters;
- getParametersInfo(theNode, aSelectionFilterId, aParameters);
- aMessage->setSelectionFilterId(aSelectionFilterId);
- aMessage->setFilterParameters(aParameters);
-
- xmlNodePtr aFeatureOrWdgNode = theNode->parent;
- if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
- aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
- } else {
- aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
- aMessage->setFeatureId(myCurrentFeature);
+ return restoreAttribute(getNodeName(theNode).c_str(), theAttribute);
+}
+
+std::string Config_XMLReader::restoreAttribute(const char* theNodeName, const char* theAttribute)
+{
+ std::string aKey = std::string(theNodeName) + ":" + std::string(theAttribute);
+ std::string result = "";
+ if(myCachedAttributes.find(aKey) != myCachedAttributes.end()) {
+ result = myCachedAttributes[aKey];
}
- aEvLoop->send(aMessage);
+ return result;
+}
+
+bool Config_XMLReader::cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute)
+{
+ return cleanupAttribute(getNodeName(theNode).c_str(), theNodeAttribute);
+}
+
+bool Config_XMLReader::cleanupAttribute(const char* theNodeName, const char* theNodeAttribute)
+{
+ std::string aKey = std::string(theNodeName) + ":" + std::string(theNodeAttribute);
+ bool result = false;
+ std::map<std::string, std::string>::iterator anEntry = myCachedAttributes.find(aKey);
+ if( anEntry != myCachedAttributes.end()) {
+ myCachedAttributes.erase(anEntry);
+ result = true;
+ }
+ return result;
}
#include <cstdarg>
#include <string>
+#include <map>
//>> Forward declaration of xmlNodePtr.
typedef struct _xmlNode xmlNode;
xmlNodePtr node(void* theNode);
/// Gets xml node name
std::string getNodeName(xmlNodePtr theNode);
- /*!
- * \brief Retrieves all the necessary info from the validator node.
- * Sends ValidatorLoaded event
- */
- void processValidator(xmlNodePtr theNode);
- /*!
- * \brief Retrieves all the necessary info from the SelectionFilter node.
- * Sends SelectionFilterLoaded event
- */
- void processSelectionFilter(xmlNodePtr theNode);
+ /// Stores an attribute in internal map for later use.
+ /// Key is "Node_Name:Node_Attribute" and value is getProperty(theNodeAttribute)
+ void storeAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+ /// Restores an attribute from internal map.
+ std::string restoreAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+ /// Restores an attribute from internal map.
+ std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
+ bool cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+ bool cleanupAttribute(const char* theNodeName, const char* theNodeAttribute);
protected:
- std::string myCurrentFeature; ///< Name of currently processed feature
std::string myDocumentPath; ///< Path to the xml document
xmlDocPtr myXmlDoc; ///< Root of the xml document
+ /// A map to store all parent's attributes.
+ /// The key has from "Node_Name:Node_Attribute"
+ std::map<std::string, std::string> myCachedAttributes;
};
#endif /* CONFIG_XMLREADER_H_ */
<plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
<plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
+ <plugin script="PythonFeaturesPlugin" configuration="plugin-PythonFeatures.xml"/>
<plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="Geometry"/>
<plugin library="ParametersPlugin" configuration="plugin-Parameters.xml"/>
<plugin library="SketchSolver"/>
void ConstructionPlugin_Axis::initAttributes()
{
data()->addAttribute(ConstructionPlugin_Axis::METHOD(),
- ModelAPI_AttributeString::type());
+ ModelAPI_AttributeString::typeId());
data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(),
- ModelAPI_AttributeSelection::type());
+ ModelAPI_AttributeSelection::typeId());
data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(),
- ModelAPI_AttributeSelection::type());
+ ModelAPI_AttributeSelection::typeId());
data()->addAttribute(ConstructionPlugin_Axis::CYLINDRICAL_FACE(),
- ModelAPI_AttributeSelection::type());
+ ModelAPI_AttributeSelection::typeId());
}
void ConstructionPlugin_Axis::createAxisByTwoPoints()
void ConstructionPlugin_Plane::initAttributes()
{
- data()->addAttribute(ConstructionPlugin_Plane::METHOD(), ModelAPI_AttributeString::type());
+ data()->addAttribute(ConstructionPlugin_Plane::METHOD(), ModelAPI_AttributeString::typeId());
// Face & Distance
- data()->addAttribute(ConstructionPlugin_Plane::FACE(), ModelAPI_AttributeSelection::type());
- data()->addAttribute(ConstructionPlugin_Plane::DISTANCE(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Plane::FACE(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(ConstructionPlugin_Plane::DISTANCE(), ModelAPI_AttributeDouble::typeId());
// General equation
- data()->addAttribute(ConstructionPlugin_Plane::A(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(ConstructionPlugin_Plane::B(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(ConstructionPlugin_Plane::C(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(ConstructionPlugin_Plane::D(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Plane::A(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(ConstructionPlugin_Plane::B(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(ConstructionPlugin_Plane::C(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(ConstructionPlugin_Plane::D(), ModelAPI_AttributeDouble::typeId());
}
void ConstructionPlugin_Plane::execute()
void ConstructionPlugin_Point::initAttributes()
{
- data()->addAttribute(ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble::typeId());
}
void ConstructionPlugin_Point::execute()
*/
void ExchangePlugin_ImportFeature::initAttributes()
{
- data()->addAttribute(ExchangePlugin_ImportFeature::FILE_PATH_ID(), ModelAPI_AttributeString::type());
+ data()->addAttribute(ExchangePlugin_ImportFeature::FILE_PATH_ID(), ModelAPI_AttributeString::typeId());
}
/*
void FeaturesPlugin_Boolean::initAttributes()
{
- data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::type());
- data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::type());
- data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::type());
+ data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId());
+ data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::typeId());
+ data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::typeId());
}
std::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Boolean::getShape(const std::string& theAttrName)
{
AttributeSelectionListPtr aSelection =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
- FeaturesPlugin_Extrusion::LIST_ID(), ModelAPI_AttributeSelectionList::type()));
+ FeaturesPlugin_Extrusion::LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
// extrusion works with faces always
aSelection->setSelectionType("FACE");
- data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
+ data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::typeId());
}
void FeaturesPlugin_Extrusion::execute()
std::shared_ptr<GeomAPI_Shape> anEmptyShape(new GeomAPI_Shape);
aResultBody->store(anEmptyShape);
setResult(aResultBody);
-}
\ No newline at end of file
+}
void FeaturesPlugin_Group::initAttributes()
{
- //data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::type());
- data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::type());
+ //data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::typeId());
+ data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
}
void FeaturesPlugin_Group::execute()
void FeaturesPlugin_Placement::initAttributes()
{
- data()->addAttribute(FeaturesPlugin_Placement::BASE_OBJECT_ID(), ModelAPI_AttributeSelection::type());
- data()->addAttribute(FeaturesPlugin_Placement::ATTRACT_OBJECT_ID(), ModelAPI_AttributeSelection::type());
- data()->addAttribute(FeaturesPlugin_Placement::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
- data()->addAttribute(FeaturesPlugin_Placement::CENTERING_ID(), ModelAPI_AttributeBoolean::type());
+ data()->addAttribute(FeaturesPlugin_Placement::BASE_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(FeaturesPlugin_Placement::ATTRACT_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(FeaturesPlugin_Placement::REVERSE_ID(), ModelAPI_AttributeBoolean::typeId());
+ data()->addAttribute(FeaturesPlugin_Placement::CENTERING_ID(), ModelAPI_AttributeBoolean::typeId());
}
void FeaturesPlugin_Placement::execute()
static const std::string MY_TOOL_ID("tool_object");
static const std::string MY_TYPE_ID("bool_type");
- data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::type());
- data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::type());
- data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::type());
+ data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::typeId());
+ data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::typeId());
+ data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId());
"""
#=========================================================================
# Initialization of the test
# Create a sketch with circle to extrude
#=========================================================================
aSession.startOperation()
-aCircleSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX"))
# Create a sketch with triangle to extrude
#=========================================================================
aSession.startOperation()
-aTriangleSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
static const std::string MY_SIZE_ID("extrusion_size");
static const std::string MY_REVERSE_ID("extrusion_reverse");
- data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::type());
- data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
+ data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::typeId());
"""
#=========================================================================
# Initialization of the test
# Create a sketch circle to extrude
#=========================================================================
aSession.startOperation()
-aSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
static const std::string MY_GROUP_ID("Group");
static const std::string MY_GROUP_LIST_ID("group_list");
- data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::type());
+ data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
"""
#=========================================================================
# Initialization of the test
# Create a sketch with triangle and extrude it
#=========================================================================
aSession.startOperation()
-aTriangleSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
static const std::string MY_SIZE_ID("size");
static const std::string MY_REVERSE_ID("reverse");
- data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::type());
- data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
+ data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::typeId());
"""
# Number rows and columns of cylinders that cuts the big box. Number of Boolena operations is N*N
#=========================================================================
# Initialization of the test
#=========================================================================
-from ModelAPI import *
-from GeomDataAPI import *
-from GeomAlgoAPI import *
from GeomAPI import *
+from GeomAlgoAPI import *
+from GeomDataAPI import *
+from ModelAPI import *
-__updated__ = "2015-02-25"
+
+__updated__ = "2015-03-26"
aSession = ModelAPI_Session.get()
aDocument = aSession.moduleDocument()
aSession.startOperation()
aSketchFeatures = []
for i in xrange(0, N):
- for j in xrange(0, N):
- # Create circle
- aSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
- origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
- origin.setValue(0, 0, 0)
- dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
- dirx.setValue(1, 0, 0)
- diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
- diry.setValue(0, 1, 0)
- norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
- norm.setValue(0, 0, 1)
- aSketchCircle = aSketchFeature.addFeature("SketchCircle")
- anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
- aCircleRadius = aSketchCircle.real("CircleRadius")
- anCircleCentr.setValue(0.5 + step * (0.5 + i), 0.5 + step * (0.5 + j))
- aCircleRadius.setValue(radius)
- aSketchFeatures.append(aSketchFeature)
+ for j in xrange(0, N):
+ # Create circle
+ aSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+ origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+ origin.setValue(0, 0, 0)
+ dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+ dirx.setValue(1, 0, 0)
+ diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
+ diry.setValue(0, 1, 0)
+ norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+ norm.setValue(0, 0, 1)
+ aSketchCircle = aSketchFeature.addFeature("SketchCircle")
+ anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+ aCircleRadius = aSketchCircle.real("CircleRadius")
+ anCircleCentr.setValue(0.5 + step * (0.5 + i), 0.5 + step * (0.5 + j))
+ aCircleRadius.setValue(radius)
+ aSketchFeatures.append(aSketchFeature)
aSession.finishOperation()
anExtrusions = []
for i in xrange(0, N * N):
- aSketchResult = aSketchFeatures[i].firstResult()
- aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
- origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt()
- dirX = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirX")).dir()
- dirY = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirY")).dir()
- norm = geomDataAPI_Dir(aSketchFeatures[i].attribute("Norm")).dir()
- aSketchFaces = ShapeList()
- GeomAlgoAPI_SketchBuilder.createFaces(
- origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
-
- anExtrusionFt = aPart.addFeature("Extrusion")
- assert (anExtrusionFt.getKind() == "Extrusion")
-
- anExtrusionFt.selectionList("base").append(
- aSketchResult, aSketchFaces[0])
- anExtrusionFt.real("size").setValue(10)
- anExtrusionFt.boolean("reverse").setValue(False)
- anExtrusions.append(anExtrusionFt)
+ aSketchResult = aSketchFeatures[i].firstResult()
+ aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
+ origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt()
+ dirX = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirX")).dir()
+ dirY = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirY")).dir()
+ norm = geomDataAPI_Dir(aSketchFeatures[i].attribute("Norm")).dir()
+ aSketchFaces = ShapeList()
+ GeomAlgoAPI_SketchBuilder.createFaces(
+ origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+
+ anExtrusionFt = aPart.addFeature("Extrusion")
+ assert (anExtrusionFt.getKind() == "Extrusion")
+
+ anExtrusionFt.selectionList("base").append(
+ aSketchResult, aSketchFaces[0])
+ anExtrusionFt.real("size").setValue(10)
+ anExtrusionFt.boolean("reverse").setValue(False)
+ # v1.0.2 from master
+ # anExtrusionFt.selection("extrusion_face").setValue(
+ # aSketchResult, aSketchFaces[0])
+ # anExtrusionFt.real("extrusion_size").setValue(10)
+ # anExtrusionFt.boolean("extrusion_reverse").setValue(False)
+ anExtrusions.append(anExtrusionFt)
aSession.finishOperation()
aSketchResult, aSketchFaces[0])
aBox.real("size").setValue(10)
aBox.boolean("reverse").setValue(False)
+# v 1.0.2 from master
+# aBox.selection("extrusion_face").setValue(
+# aSketchResult, aSketchFaces[0])
+# aBox.real("extrusion_size").setValue(10)
+# aBox.boolean("extrusion_reverse").setValue(False)
+
aSession.finishOperation()
#=========================================================================
-# Create a boolean cut of cylinders from the box:
+# Create a boolean cut of cylinders from the box:
# result of Boolean is the first argument of the next Boolean
#=========================================================================
aCurrentResult = aBox.firstResult()
aSession.startOperation()
for i in xrange(0, N * N):
- aBooleanFt = aPart.addFeature("Boolean")
- aBooleanFt.reference("main_object").setValue(modelAPI_ResultBody(aCurrentResult))
- aBooleanFt.reference("tool_object").setValue(modelAPI_ResultBody(anExtrusions[i].firstResult()))
- kBooleanTypeCut = 0
- aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut)
- aBooleanFt.execute()
- aCurrentResult = aBooleanFt.firstResult()
+ aBooleanFt = aPart.addFeature("Boolean")
+ aBooleanFt.reference("main_object").setValue(modelAPI_ResultBody(aCurrentResult))
+ aBooleanFt.reference("tool_object").setValue(modelAPI_ResultBody(anExtrusions[i].firstResult()))
+ kBooleanTypeCut = 0
+ aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut)
+ aBooleanFt.execute()
+ aCurrentResult = aBooleanFt.firstResult()
aSession.finishOperation()
#=========================================================================
#include "GeomAPI_Pnt.h"
#include "GeomAPI_XY.h"
#include "GeomAPI_XYZ.h"
+
+ #include <memory>
+ #include <string>
%}
// to avoid error on this
#include "GeomAlgoAPI_MakeShape.h"
#include "GeomAlgoAPI_PointBuilder.h"
#include "GeomAlgoAPI_SketchBuilder.h"
+
+ #include <memory>
+ #include <string>
+ #include <list>
%}
// to avoid error on this
#define GeomAlgoAPI_Boolean_H_
#include <GeomAlgoAPI.h>
-#include <GeomAPI_Shape.h>
#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_Interface.h>
#include <GeomAPI_DataMapOfShapeShape.h>
+
#include <memory>
/**\class GeomAlgoAPI_Boolean
)
SET(PROJECT_LIBRARIES
+ GeomDataAPI
ModelAPI
GeomAPI
Events
GeomDataAPI_Point2D.h
)
-SET(CMAKE_SWIG_FLAGS "-Wall")
+SET(PROJECT_SOURCES
+ GeomDataAPI_Point.cpp
+ GeomDataAPI_Dir.cpp
+ GeomDataAPI_Point2D.cpp
+)
-SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+SET(PROJECT_LIBRARIES
+ ModelAPI
+)
-INCLUDE_DIRECTORIES(
+INCLUDE_DIRECTORIES(
../ModelAPI
)
+ADD_DEFINITIONS(-DGEOMDATAAPI_EXPORTS)
+ADD_LIBRARY(GeomDataAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+SET_TARGET_PROPERTIES(GeomDataAPI PROPERTIES LINKER_LANGUAGE CXX)
+TARGET_LINK_LIBRARIES(GeomDataAPI ${PROJECT_LIBRARIES})
+
+SET(CMAKE_SWIG_FLAGS "-Wall")
+
+SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
SET(SWIG_SCRIPTS
${CMAKE_CURRENT_BINARY_DIR}/GeomDataAPI.py
)
SET(SWIG_LINK_LIBRARIES
- ModelAPI
+ GeomDataAPI
${PYTHON_LIBRARIES}
)
SET_TARGET_PROPERTIES(_GeomDataAPI PROPERTIES DEBUG_OUTPUT_NAME _GeomDataAPI_d)
ENDIF(WIN32)
+INSTALL(TARGETS GeomDataAPI DESTINATION bin)
INSTALL(TARGETS _GeomDataAPI DESTINATION swig)
INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION swig)
#include "GeomDataAPI_Point.h"
#include "GeomDataAPI_Dir.h"
#include "GeomDataAPI_Point2D.h"
+
+ #include <memory>
+ #include <string>
+ #include <list>
template<class T> std::shared_ptr<T> castTo(std::shared_ptr<ModelAPI_Attribute> theObject)
{
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomDataAPI_Dir.cpp
+// Created: 24 Apr 2014
+// Author: Mikhail PONIKAROV
+
+
+#include <GeomDataAPI_Dir.h>
+
+std::string GeomDataAPI_Dir::attributeType()
+{
+ return typeId();
+}
+
+GeomDataAPI_Dir::GeomDataAPI_Dir()
+{
+}
+
+GeomDataAPI_Dir::~GeomDataAPI_Dir()
+{
+
+}
virtual std::shared_ptr<GeomAPI_XYZ> xyz() = 0;
/// Returns the type of this class of attributes
- static inline std::string type()
+ static std::string typeId()
{
return std::string("Dir");
}
/// Returns the type of this class of attributes, not static method
- virtual std::string attributeType()
- {
- return type();
- }
+ GEOMDATAAPI_EXPORT virtual std::string attributeType();
protected:
/// Objects are created for features automatically
- GeomDataAPI_Dir()
- {
- }
+ GEOMDATAAPI_EXPORT GeomDataAPI_Dir();
+ GEOMDATAAPI_EXPORT virtual ~GeomDataAPI_Dir();
};
#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomDataAPI_Point.cpp
+// Created: 24 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#include <GeomDataAPI_Point.h>
+
+std::string GeomDataAPI_Point::attributeType()
+{
+ return typeId();
+}
+
+GeomDataAPI_Point::GeomDataAPI_Point()
+{
+}
+
+GeomDataAPI_Point::~GeomDataAPI_Point()
+{
+}
virtual std::shared_ptr<GeomAPI_Pnt> pnt() = 0;
/// Returns the type of this class of attributes
- static inline std::string type()
+ static std::string typeId()
{
return std::string("Point");
}
/// Returns the type of this class of attributes, not static method
- virtual std::string attributeType()
- {
- return type();
- }
+ GEOMDATAAPI_EXPORT virtual std::string attributeType();
protected:
/// Objects are created for features automatically
- GeomDataAPI_Point()
- {
- }
+ GEOMDATAAPI_EXPORT GeomDataAPI_Point();
+ GEOMDATAAPI_EXPORT virtual ~GeomDataAPI_Point();
};
#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomDataAPI_Point2D.cpp
+// Created: 24 Apr 2014
+// Author: Mikhail PONIKAROV
+
+
+#include <GeomDataAPI_Point2D.h>
+
+void GeomDataAPI_Point2D::move(const double theDeltaX, const double theDeltaY)
+{
+ setValue(x() + theDeltaX, y() + theDeltaY);
+}
+
+std::string GeomDataAPI_Point2D::attributeType()
+{
+ return typeId();
+}
+
+GeomDataAPI_Point2D::GeomDataAPI_Point2D()
+{
+}
+
+GeomDataAPI_Point2D::~GeomDataAPI_Point2D()
+{
+}
#ifndef GeomDataAPI_Point2D_H_
#define GeomDataAPI_Point2D_H_
-#include "GeomDataAPI.h"
+#include <GeomDataAPI.h>
#include <ModelAPI_Attribute.h>
class GeomAPI_Pnt2d;
virtual std::shared_ptr<GeomAPI_Pnt2d> pnt() = 0;
/// Appends the delta values to point
- void move(const double theDeltaX, const double theDeltaY)
- {
- setValue(x() + theDeltaX, y() + theDeltaY);
- }
-
+ GEOMDATAAPI_EXPORT void move(const double theDeltaX, const double theDeltaY);
/// Returns the type of this class of attributes
- static inline std::string type()
+ static std::string typeId()
{
return std::string("Point2D");
}
/// Returns the type of this class of attributes, not static method
- virtual std::string attributeType()
- {
- return type();
- }
+ GEOMDATAAPI_EXPORT virtual std::string attributeType();
protected:
/// Objects are created for features automatically
- GeomDataAPI_Point2D()
- {
- }
+ GEOMDATAAPI_EXPORT GeomDataAPI_Point2D();
+ GEOMDATAAPI_EXPORT virtual ~GeomDataAPI_Point2D();
};
#endif
# Test GeomDataAPI static methods
#===============================================================================
from GeomDataAPI import *
-assert (GeomDataAPI_Point.type() == "Point")
-assert (GeomDataAPI_Dir.type() == "Dir")
-assert (GeomDataAPI_Point2D.type() == "Point2D")
\ No newline at end of file
+assert (GeomDataAPI_Point.typeId() == "Point")
+assert (GeomDataAPI_Dir.typeId() == "Dir")
+assert (GeomDataAPI_Point2D.typeId() == "Point2D")
\ No newline at end of file
AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
if (anAttr.get() != NULL) {
AttributePtr aRefAttr = anAttr->attr();
- aValid = aRefAttr.get() != NULL && aRefAttr->attributeType() == GeomDataAPI_Point2D::type();
+ aValid = aRefAttr.get() != NULL && aRefAttr->attributeType() == GeomDataAPI_Point2D::typeId();
}
}
}
{
ObjectPtr anObject;
std::string anAttrType = theAttribute->attributeType();
- if (anAttrType == ModelAPI_AttributeRefAttr::type()) {
+ if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
if (anAttr != NULL && anAttr->isObject())
anObject = anAttr->object();
}
- if (anAttrType == ModelAPI_AttributeSelection::type()) {
+ if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
if (anAttr != NULL && anAttr->isInitialized())
anObject = anAttr->context();
}
- if (anAttrType == ModelAPI_AttributeReference::type()) {
+ if (anAttrType == ModelAPI_AttributeReference::typeId()) {
AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
if (anAttr.get() != NULL && anAttr->isInitialized())
anObject = anAttr->value();
#include <TDataStd_Name.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Iterator.hxx>
+#include <TNaming_Iterator.hxx>
using namespace std;
//#define DEB_NAMING 1
#ifdef DEB_NAMING
std::string aSelName = namingName();
if(!aSelName.empty())
- TDataStd_Name::Set(selectionLabel(), aSelName.c_str()); //set name
+ TDataStd_Name::Set(selectionLabel(), aSelName.c_str()); //set name
#ifdef DDDD
//####
//selectSubShape("FACE", "Extrusion_1/LateralFace_3");
// if aSubIds take any, the first appropriate
int aFeatureID = aComposite->subFeatureId(a);
if (aSubIds->IsEmpty() || aSubIds->Contains(aFeatureID) ||
- aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA) ||
- aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) {
- // searching for deltas
- int aVertexNum = 0;
- if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA)) aVertexNum = 1;
- else if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) aVertexNum = 2;
- // found the feature with appropriate edge
- FeaturePtr aFeature = aComposite->subFeature(a);
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
- aFeature->results().cbegin();
- for(;aResIter != aFeature->results().cend(); aResIter++) {
- ResultConstructionPtr aRes =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aResIter);
- if (aRes && aRes->shape()) {
- if (aRes->shape()->isVertex() && aVertexNum == 0) { // found!
- selectConstruction(aContext, aRes->shape());
- owner()->data()->sendAttributeUpdated(this);
- return true;
- } else if (aRes->shape()->isEdge() && aVertexNum > 0) {
- const TopoDS_Shape& anEdge = aRes->shape()->impl<TopoDS_Shape>();
- int aVIndex = 1;
- for(TopExp_Explorer aVExp(anEdge, TopAbs_VERTEX); aVExp.More(); aVExp.Next()) {
- if (aVIndex == aVertexNum) { // found!
- std::shared_ptr<GeomAPI_Shape> aVertex(new GeomAPI_Shape);
- aVertex->setImpl(new TopoDS_Shape(aVExp.Current()));
- selectConstruction(aContext, aVertex);
- owner()->data()->sendAttributeUpdated(this);
- return true;
+ aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA) ||
+ aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) {
+ // searching for deltas
+ int aVertexNum = 0;
+ if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA)) aVertexNum = 1;
+ else if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) aVertexNum = 2;
+ // found the feature with appropriate edge
+ FeaturePtr aFeature = aComposite->subFeature(a);
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
+ aFeature->results().cbegin();
+ for(;aResIter != aFeature->results().cend(); aResIter++) {
+ ResultConstructionPtr aRes =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aResIter);
+ if (aRes && aRes->shape()) {
+ if (aRes->shape()->isVertex() && aVertexNum == 0) { // found!
+ selectConstruction(aContext, aRes->shape());
+ owner()->data()->sendAttributeUpdated(this);
+ return true;
+ } else if (aRes->shape()->isEdge() && aVertexNum > 0) {
+ const TopoDS_Shape& anEdge = aRes->shape()->impl<TopoDS_Shape>();
+ int aVIndex = 1;
+ for(TopExp_Explorer aVExp(anEdge, TopAbs_VERTEX); aVExp.More(); aVExp.Next()) {
+ if (aVIndex == aVertexNum) { // found!
+ std::shared_ptr<GeomAPI_Shape> aVertex(new GeomAPI_Shape);
+ aVertex->setImpl(new TopoDS_Shape(aVExp.Current()));
+ selectConstruction(aContext, aVertex);
+ owner()->data()->sendAttributeUpdated(this);
+ return true;
+ }
+ aVIndex++;
}
- aVIndex++;
}
}
}
- }
}
}
}
void Model_AttributeSelection::selectBody(
- const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
+ const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
{
// perform the selection
TNaming_Selector aSel(selectionLabel());
TopoDS_Shape aContext;
ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myRef.value());
- if (aBody)
+ if (aBody) {
aContext = aBody->shape()->impl<TopoDS_Shape>();
- else {
- ResultConstructionPtr aConstr = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myRef.value());
+ } else {
+ ResultConstructionPtr aConstr =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myRef.value());
if (aConstr) {
aContext = aConstr->shape()->impl<TopoDS_Shape>();
} else {
return;
}
}
- //BRepTools::Write(aNewShape, "Selection0.brep");
+ /// fix for issue 411: result modified shapes must not participate in this selection mechanism
+ FeaturePtr aFeatureOwner = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ if (aFeatureOwner.get())
+ aFeatureOwner->eraseResults();
+
aSel.Select(aNewShape, aContext);
}
}
void Model_AttributeSelection::selectConstruction(
- const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
+ const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
{
std::shared_ptr<Model_Document> aMyDoc =
std::dynamic_pointer_cast<Model_Document>(owner()->document());
#define FIX_BUG1 1
std::string GetShapeName(std::shared_ptr<Model_Document> theDoc, const TopoDS_Shape& theShape,
- const TDF_Label& theLabel)
+ const TDF_Label& theLabel)
{
std::string aName;
// check if the subShape is already in DF
Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(theShape, theLabel);
Handle(TDataStd_Name) anAttr;
if(!aNS.IsNull() && !aNS->IsEmpty()) { // in the document
- if(aNS->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
- aName = TCollection_AsciiString(anAttr->Get()).ToCString();
- if(!aName.empty()) {
- const TDF_Label& aLabel = theDoc->findNamingName(aName);
- /* MPV: the same shape with the same name may be duplicated on different labels (selection of the same construction object)
- if(!aLabel.IsEqual(aNS->Label())) {
- //aName.erase(); //something is wrong, to be checked!!!
- aName += "_SomethingWrong";
- return aName;
- }*/
- const TopoDS_Shape& aShape = aNS->Get();
- if(aShape.ShapeType() == TopAbs_COMPOUND) {
- std::string aPostFix("_");
- TopoDS_Iterator it(aShape);
- for (int i = 1;it.More();it.Next(), i++) {
- if(it.Value() == theShape) {
- aPostFix += TCollection_AsciiString (i).ToCString();
- aName += aPostFix;
- break;
- }
- else continue;
- }
- }
- }
- }
+ if(aNS->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
+ aName = TCollection_AsciiString(anAttr->Get()).ToCString();
+ if(!aName.empty()) {
+ const TDF_Label& aLabel = theDoc->findNamingName(aName);
+ /* MPV: the same shape with the same name may be duplicated on different labels (selection of the same construction object)
+ if(!aLabel.IsEqual(aNS->Label())) {
+ //aName.erase(); //something is wrong, to be checked!!!
+ aName += "_SomethingWrong";
+ return aName;
+ }*/
+
+ static const std::string aPostFix("_");
+ TNaming_Iterator anItL(aNS);
+ for(int i = 1; anItL.More(); anItL.Next(), i++) {
+ if(anItL.NewShape() == theShape) {
+ aName += aPostFix;
+ aName += TCollection_AsciiString (i).ToCString();
+ break;
+ }
+ }
+ /* MPV: the code below does not work because of TNaming_Tool.cxx line 145: aNS->Get() uses maps
+ const TopoDS_Shape& aShape = aNS->Get();
+ if(aShape.ShapeType() == TopAbs_COMPOUND) {
+ std::string aPostFix("_");
+ TopoDS_Iterator it(aShape);
+ for (int i = 1;it.More();it.Next(), i++) {
+ if(it.Value() == theShape) {
+ aPostFix += TCollection_AsciiString (i).ToCString();
+ aName += aPostFix;
+ break;
+ }
+ else continue;
+ }
+ }
+ */
+ }
+ }
}
return aName;
}
bool isTrivial (const TopTools_ListOfShape& theAncestors, TopTools_IndexedMapOfShape& theSMap)
{
-// a trivial case: F1 & F2, aNumber = 1, i.e. intersection gives 1 edge.
+ // a trivial case: F1 & F2, aNumber = 1, i.e. intersection gives 1 edge.
TopoDS_Compound aCmp;
BRep_Builder BB;
BB.MakeCompound(aCmp);
TopTools_ListIteratorOfListOfShape it(theAncestors);
for(;it.More();it.Next()) {
- BB.Add(aCmp, it.Value());
- theSMap.Add(it.Value());
+ BB.Add(aCmp, it.Value());
+ theSMap.Add(it.Value());
}
int aNumber(0);
TopTools_IndexedDataMapOfShapeListOfShape aMap2;
TopExp::MapShapesAndAncestors(aCmp, TopAbs_EDGE, TopAbs_FACE, aMap2);
for (int i = 1; i <= aMap2.Extent(); i++) {
- const TopoDS_Shape& aKey = aMap2.FindKey(i);
- const TopTools_ListOfShape& anAncestors = aMap2.FindFromIndex(i);
- if(anAncestors.Extent() > 1) aNumber++;
+ const TopoDS_Shape& aKey = aMap2.FindKey(i);
+ const TopTools_ListOfShape& anAncestors = aMap2.FindFromIndex(i);
+ if(anAncestors.Extent() > 1) aNumber++;
}
if(aNumber > 1) return false;
return true;
if(!this->isInitialized()) return aName;
Handle(TDataStd_Name) anAtt;
if(selectionLabel().FindAttribute(TDataStd_Name::GetID(), anAtt)) {
- aName = TCollection_AsciiString(anAtt->Get()).ToCString();
- return aName;
+ aName = TCollection_AsciiString(anAtt->Get()).ToCString();
+ return aName;
}
std::shared_ptr<GeomAPI_Shape> aSubSh = value();
aName = GetShapeName(aDoc, aSubShape, selectionLabel());
if(aName.empty() ) { // not in the document!
TopAbs_ShapeEnum aType = aSubShape.ShapeType();
- switch (aType) {
- case TopAbs_FACE:
+ switch (aType) {
+ case TopAbs_FACE:
// the Face should be in DF. If it is not the case, it is an error ==> to be debugged
break;
case TopAbs_EDGE:
}
break;
- case TopAbs_VERTEX:
- // name structure (Monifold Topology):
- // 1) F1 | F2 | F3 - intersection of 3 faces defines a vertex - trivial case.
- // 2) F1 | F2 | F3 [|F4 [|Fn]] - redundant definition, but it should be kept as is to obtain safe recomputation
- // 2) F1 | F2 - intersection of 2 faces definses a vertex - applicable for case
- // when 1 faces is cylindrical, conical, spherical or revolution and etc.
- // 3) E1 | E2 | E3 - intersection of 3 edges defines a vertex - when we have case of a shell
- // or compound of 2 open faces.
- // 4) E1 | E2 - intesection of 2 edges defines a vertex - when we have a case of
- // two independent edges (wire or compound)
- // implemented 2 first cases
- {
- TopTools_IndexedDataMapOfShapeListOfShape aMap;
- TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_FACE, aMap);
- const TopTools_ListOfShape& aList2 = aMap.FindFromKey(aSubShape);
- TopTools_ListOfShape aList;
- TopTools_MapOfShape aFMap;
+ case TopAbs_VERTEX:
+ // name structure (Monifold Topology):
+ // 1) F1 | F2 | F3 - intersection of 3 faces defines a vertex - trivial case.
+ // 2) F1 | F2 | F3 [|F4 [|Fn]] - redundant definition, but it should be kept as is to obtain safe recomputation
+ // 2) F1 | F2 - intersection of 2 faces definses a vertex - applicable for case
+ // when 1 faces is cylindrical, conical, spherical or revolution and etc.
+ // 3) E1 | E2 | E3 - intersection of 3 edges defines a vertex - when we have case of a shell
+ // or compound of 2 open faces.
+ // 4) E1 | E2 - intesection of 2 edges defines a vertex - when we have a case of
+ // two independent edges (wire or compound)
+ // implemented 2 first cases
+ {
+ TopTools_IndexedDataMapOfShapeListOfShape aMap;
+ TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_FACE, aMap);
+ const TopTools_ListOfShape& aList2 = aMap.FindFromKey(aSubShape);
+ TopTools_ListOfShape aList;
+ TopTools_MapOfShape aFMap;
#ifdef FIX_BUG1
- //int n = aList2.Extent(); //bug! duplication
- // fix is below
- TopTools_ListIteratorOfListOfShape itl2(aList2);
- for (int i = 1;itl2.More();itl2.Next(),i++) {
- if(aFMap.Add(itl2.Value()))
- aList.Append(itl2.Value());
- }
- //n = aList.Extent();
+ //int n = aList2.Extent(); //bug! duplication
+ // fix is below
+ TopTools_ListIteratorOfListOfShape itl2(aList2);
+ for (int i = 1;itl2.More();itl2.Next(),i++) {
+ if(aFMap.Add(itl2.Value()))
+ aList.Append(itl2.Value());
+ }
+ //n = aList.Extent();
#endif
- int n = aList.Extent();
- if(n < 3) { // open topology case or Compound case => via edges
- TopTools_IndexedDataMapOfShapeListOfShape aMap;
- TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap);
- const TopTools_ListOfShape& aList22 = aMap.FindFromKey(aSubShape);
- if(aList22.Extent() >= 2) { // regular solution
+ int n = aList.Extent();
+ if(n < 3) { // open topology case or Compound case => via edges
+ TopTools_IndexedDataMapOfShapeListOfShape aMap;
+ TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap);
+ const TopTools_ListOfShape& aList22 = aMap.FindFromKey(aSubShape);
+ if(aList22.Extent() >= 2) { // regular solution
#ifdef FIX_BUG1
-
- // bug! duplication; fix is below
- aFMap.Clear();
- TopTools_ListOfShape aListE;
- TopTools_ListIteratorOfListOfShape itl2(aList22);
- for (int i = 1;itl2.More();itl2.Next(),i++) {
- if(aFMap.Add(itl2.Value()))
- aListE.Append(itl2.Value());
- }
- n = aListE.Extent();
+
+ // bug! duplication; fix is below
+ aFMap.Clear();
+ TopTools_ListOfShape aListE;
+ TopTools_ListIteratorOfListOfShape itl2(aList22);
+ for (int i = 1;itl2.More();itl2.Next(),i++) {
+ if(aFMap.Add(itl2.Value()))
+ aListE.Append(itl2.Value());
+ }
+ n = aListE.Extent();
#endif
- TopTools_ListIteratorOfListOfShape itl(aListE);
- for (int i = 1;itl.More();itl.Next(),i++) {
- const TopoDS_Shape& anEdge = itl.Value();
- std::string anEdgeName = GetShapeName(aDoc, anEdge, selectionLabel());
- if(i == 1)
- aName = anEdgeName;
- else
- aName += "|" + anEdgeName;
- }
- }//reg
- else { // dangle vertex: if(aList22.Extent() == 1)
- //it should be already in DF
- }
- }
- else {
- TopTools_ListIteratorOfListOfShape itl(aList);
- for (int i = 1;itl.More();itl.Next(),i++) {
- const TopoDS_Shape& aFace = itl.Value();
- std::string aFaceName = GetShapeName(aDoc, aFace, selectionLabel());
- if(i == 1)
- aName = aFaceName;
- else
- aName += "|" + aFaceName;
- }
- }
- }
- break;
- }
+ TopTools_ListIteratorOfListOfShape itl(aListE);
+ for (int i = 1;itl.More();itl.Next(),i++) {
+ const TopoDS_Shape& anEdge = itl.Value();
+ std::string anEdgeName = GetShapeName(aDoc, anEdge, selectionLabel());
+ if(i == 1)
+ aName = anEdgeName;
+ else
+ aName += "|" + anEdgeName;
+ }
+ }//reg
+ else { // dangle vertex: if(aList22.Extent() == 1)
+ //it should be already in DF
+ }
+ }
+ else {
+ TopTools_ListIteratorOfListOfShape itl(aList);
+ for (int i = 1;itl.More();itl.Next(),i++) {
+ const TopoDS_Shape& aFace = itl.Value();
+ std::string aFaceName = GetShapeName(aDoc, aFace, selectionLabel());
+ if(i == 1)
+ aName = aFaceName;
+ else
+ aName += "|" + aFaceName;
+ }
+ }
+ }
+ break;
+ }
// register name
// aDoc->addNamingName(selectionLabel(), aName);
- // the selected sub-shape will not be shared and as result it will not require registration
+ // the selected sub-shape will not be shared and as result it will not require registration
}
return aName;
}
return TopAbs_SHAPE;
}
-const TopoDS_Shape getShapeFromCompound(const std::string& theSubShapeName, const TopoDS_Shape& theCompound)
+const TopoDS_Shape getShapeFromNS(
+ const std::string& theSubShapeName, Handle(TNaming_NamedShape) theNS)
{
TopoDS_Shape aSelection;
std::string::size_type n = theSubShapeName.rfind('/');
if (n == std::string::npos) n = 0;
- std::string aSubString = theSubShapeName.substr(n + 1);
- n = aSubString.rfind('_');
- if (n == std::string::npos) return aSelection;
- aSubString = aSubString.substr(n+1);
- int indx = atoi(aSubString.c_str());
- TopoDS_Iterator it(theCompound);
- for (int i = 1;it.More();it.Next(), i++) {
- if(i == indx) {
- aSelection = it.Value();
- break;
- }
- else continue;
- }
+ std::string aSubString = theSubShapeName.substr(n + 1);
+ n = aSubString.rfind('_');
+ if (n == std::string::npos) return aSelection;
+ aSubString = aSubString.substr(n+1);
+ int indx = atoi(aSubString.c_str());
+
+ TNaming_Iterator anItL(theNS);
+ for(int i = 1; anItL.More(); anItL.Next(), i++) {
+ if (i == indx) {
+ return anItL.NewShape();
+ }
+ }
return aSelection;
}
-const TopoDS_Shape findFaceByName(const std::string& theSubShapeName, std::shared_ptr<Model_Document> theDoc)
+const TopoDS_Shape findFaceByName(
+ const std::string& theSubShapeName, std::shared_ptr<Model_Document> theDoc)
{
TopoDS_Shape aFace;
std::string::size_type n, nb = theSubShapeName.rfind('/');
std::string aSubString = theSubShapeName.substr(nb + 1);
n = aSubString.rfind('_');
if (n != std::string::npos) {
- std::string aSubStr2 = aSubString.substr(0, n);
- aSubString = theSubShapeName.substr(0, nb + 1);
- aSubString = aSubString + aSubStr2;
+ std::string aSubStr2 = aSubString.substr(0, n);
+ aSubString = theSubShapeName.substr(0, nb + 1);
+ aSubString = aSubString + aSubStr2;
} else
- aSubString = theSubShapeName;
-
+ aSubString = theSubShapeName;
+
const TDF_Label& aLabel = theDoc->findNamingName(aSubString);
if(aLabel.IsNull()) return aFace;
Handle(TNaming_NamedShape) aNS;
if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
- const TopoDS_Shape& aShape = aNS->Get();
- if(!aShape.IsNull()) {
- if(aShape.ShapeType() == TopAbs_COMPOUND)
- aFace = getShapeFromCompound(theSubShapeName, aShape);
- else
- aFace = aShape;
- }
+ aFace = getShapeFromNS(theSubShapeName, aNS);
}
return aFace;
}
int n1(0), n2(0); // n1 - start position, n2 - position of the delimiter
while ((n2 = aName.find('|', n1)) != std::string::npos) {
const std::string aName1 = aName.substr(n1, n2 - n1); //name of face
- theList.push_back(aName1);
- n1 = n2 + 1;
- aLastName = aName.substr(n1);
+ theList.push_back(aName1);
+ n1 = n2 + 1;
+ aLastName = aName.substr(n1);
}
if(!aLastName.empty())
- theList.push_back(aLastName);
+ theList.push_back(aLastName);
return theList.size();
}
-const TopoDS_Shape findCommonShape(const TopAbs_ShapeEnum theType, const TopTools_ListOfShape& theList)
+const TopoDS_Shape findCommonShape(
+ const TopAbs_ShapeEnum theType, const TopTools_ListOfShape& theList)
{
TopoDS_Shape aShape;
std::vector<TopTools_MapOfShape> aVec;
TopTools_MapOfShape aMap1, aMap2, aMap3, aMap4;
if(theList.Extent() > 1) {
- aVec.push_back(aMap1);
- aVec.push_back(aMap2);
+ aVec.push_back(aMap1);
+ aVec.push_back(aMap2);
}
if(theList.Extent() > 2)
aVec.push_back(aMap3);
//fill maps
TopTools_ListIteratorOfListOfShape it(theList);
for(int i = 0;it.More();it.Next(),i++) {
- const TopoDS_Shape& aFace = it.Value();
- if(i < 2) {
- TopExp_Explorer anExp (aFace, theType);
- for(;anExp.More();anExp.Next()) {
- const TopoDS_Shape& anEdge = anExp.Current();
- if (!anEdge.IsNull())
- aVec[i].Add(anExp.Current());
- }
- } else {
- TopExp_Explorer anExp (aFace, TopAbs_VERTEX);
- for(;anExp.More();anExp.Next()) {
- const TopoDS_Shape& aVertex = anExp.Current();
- if (!aVertex.IsNull())
- aVec[i].Add(anExp.Current());
- }
- }
+ const TopoDS_Shape& aFace = it.Value();
+ if(i < 2) {
+ TopExp_Explorer anExp (aFace, theType);
+ for(;anExp.More();anExp.Next()) {
+ const TopoDS_Shape& anEdge = anExp.Current();
+ if (!anEdge.IsNull())
+ aVec[i].Add(anExp.Current());
+ }
+ } else {
+ TopExp_Explorer anExp (aFace, TopAbs_VERTEX);
+ for(;anExp.More();anExp.Next()) {
+ const TopoDS_Shape& aVertex = anExp.Current();
+ if (!aVertex.IsNull())
+ aVec[i].Add(anExp.Current());
+ }
+ }
}
//trivial case: 2 faces
TopTools_ListOfShape aList;
TopTools_MapIteratorOfMapOfShape it2(aVec[0]);
for(;it2.More();it2.Next()) {
- if(aVec[1].Contains(it2.Key())) {
- aShape = it2.Key();
- if(theList.Extent() == 2)
- break;
- else
- aList.Append(it2.Key());
- }
+ if(aVec[1].Contains(it2.Key())) {
+ aShape = it2.Key();
+ if(theList.Extent() == 2)
+ break;
+ else
+ aList.Append(it2.Key());
+ }
}
if(aList.Extent() && aVec.size() > 3) {// list of common edges ==> search ny neighbors
- if(aVec[2].Extent() && aVec[3].Extent()) {
- TopTools_ListIteratorOfListOfShape it(aList);
- for(;it.More();it.Next()) {
- const TopoDS_Shape& aCand = it.Value();
- // not yet completelly implemented, to be rechecked
- TopoDS_Vertex aV1, aV2;
- TopExp::Vertices(TopoDS::Edge(aCand), aV1, aV2);
- int aNum(0);
- if(aVec[2].Contains(aV1)) aNum++;
- else if(aVec[2].Contains(aV2)) aNum++;
- if(aVec[3].Contains(aV1)) aNum++;
- else if(aVec[3].Contains(aV2)) aNum++;
- if(aNum == 2) {
- aShape = aCand;
- break;
- }
- }
- }
+ if(aVec[2].Extent() && aVec[3].Extent()) {
+ TopTools_ListIteratorOfListOfShape it(aList);
+ for(;it.More();it.Next()) {
+ const TopoDS_Shape& aCand = it.Value();
+ // not yet completelly implemented, to be rechecked
+ TopoDS_Vertex aV1, aV2;
+ TopExp::Vertices(TopoDS::Edge(aCand), aV1, aV2);
+ int aNum(0);
+ if(aVec[2].Contains(aV1)) aNum++;
+ else if(aVec[2].Contains(aV2)) aNum++;
+ if(aVec[3].Contains(aV1)) aNum++;
+ else if(aVec[3].Contains(aV2)) aNum++;
+ if(aNum == 2) {
+ aShape = aCand;
+ break;
+ }
+ }
+ }
}
if(aList.Extent() && aVec.size() == 3) {
TopTools_ListIteratorOfListOfShape it(aList);
- for(;it.More();it.Next()) {
- const TopoDS_Shape& aCand = it.Value();
- if(aVec[2].Contains(aCand)) {
- aShape = aCand;
- break;
- }
- }
+ for(;it.More();it.Next()) {
+ const TopoDS_Shape& aCand = it.Value();
+ if(aVec[2].Contains(aCand)) {
+ aShape = aCand;
+ break;
+ }
+ }
}
return aShape;
}
return aName;
}
// type ::= COMP | COMS | SOLD | SHEL | FACE | WIRE | EDGE | VERT
-void Model_AttributeSelection::selectSubShape(const std::string& theType, const std::string& theSubShapeName)
+void Model_AttributeSelection::selectSubShape(
+ const std::string& theType, const std::string& theSubShapeName)
{
if(theSubShapeName.empty() || theType.empty()) return;
TopAbs_ShapeEnum aType = translateType(theType);
- std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(owner()->document());//std::dynamic_pointer_cast<Model_Document>(aCont->document());
+ std::shared_ptr<Model_Document> aDoc =
+ std::dynamic_pointer_cast<Model_Document>(owner()->document());
std::string aContName = getContextName(theSubShapeName);
if(aContName.empty()) return;
//ResultPtr aCont = context();
TopoDS_Shape aContext = aCont->shape()->impl<TopoDS_Shape>();
TopAbs_ShapeEnum aContType = aContext.ShapeType();
if(aType <= aContType) return; // not applicable
-
-
+
+
TopoDS_Shape aSelection;
switch (aType)
{
break;
case TopAbs_FACE:
{
- const TopoDS_Shape aSelection = findFaceByName(theSubShapeName, aDoc);
- if(!aSelection.IsNull()) {// Select it
- std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
+ const TopoDS_Shape aSelection = findFaceByName(theSubShapeName, aDoc);
+ if(!aSelection.IsNull()) {// Select it
+ std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
- setValue(aCont, aShapeToBeSelected);
- }
- }
+ setValue(aCont, aShapeToBeSelected);
+ }
+ }
break;
case TopAbs_WIRE:
- break;
+ break;
case TopAbs_EDGE:
- {
- TopoDS_Shape aSelection;// = findFaceByName(theSubShapeName, aDoc);
- const TDF_Label& aLabel = aDoc->findNamingName(theSubShapeName);
+ {
+ TopoDS_Shape aSelection;// = findFaceByName(theSubShapeName, aDoc);
+ const TDF_Label& aLabel = aDoc->findNamingName(theSubShapeName);
if(!aLabel.IsNull()) {
Handle(TNaming_NamedShape) aNS;
if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
- const TopoDS_Shape& aShape = aNS->Get();
- if(!aShape.IsNull()) {
- if(aShape.ShapeType() == TopAbs_COMPOUND)
- aSelection = getShapeFromCompound(theSubShapeName, aShape);
- else
- aSelection = aShape;
- }
- }
- }
- if(aSelection.IsNull()) {
- std::list<std::string> aListofNames;
- int n = ParseName(theSubShapeName, aListofNames);
- if(n > 1 && n < 5) {
- TopTools_ListOfShape aList;
- for(std::list<std::string>::iterator it =aListofNames.begin();it != aListofNames.end();it++){
- const TopoDS_Shape aFace = findFaceByName(*it, aDoc);
- aList.Append(aFace);
- }
- aSelection = findCommonShape(TopAbs_EDGE, aList);
- }
- }
- if(!aSelection.IsNull()) {// Select it
- std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
+ aSelection = getShapeFromNS(theSubShapeName, aNS);
+ }
+ }
+ if(aSelection.IsNull()) {
+ std::list<std::string> aListofNames;
+ int n = ParseName(theSubShapeName, aListofNames);
+ if(n > 1 && n < 5) {
+ TopTools_ListOfShape aList;
+ std::list<std::string>::iterator it =aListofNames.begin();
+ for(;it != aListofNames.end();it++){
+ const TopoDS_Shape aFace = findFaceByName(*it, aDoc);
+ aList.Append(aFace);
+ }
+ aSelection = findCommonShape(TopAbs_EDGE, aList);
+ }
+ }
+ if(!aSelection.IsNull()) {// Select it
+ std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
- setValue(aCont, aShapeToBeSelected);
- }
- }
+ setValue(aCont, aShapeToBeSelected);
+ }
+ }
break;
case TopAbs_VERTEX:
- {
- TopoDS_Shape aSelection;
- const TDF_Label& aLabel = aDoc->findNamingName(theSubShapeName);
+ {
+ TopoDS_Shape aSelection;
+ const TDF_Label& aLabel = aDoc->findNamingName(theSubShapeName);
if(!aLabel.IsNull()) {
Handle(TNaming_NamedShape) aNS;
if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
- const TopoDS_Shape& aShape = aNS->Get();
- if(!aShape.IsNull()) {
- if(aShape.ShapeType() == TopAbs_COMPOUND)
- aSelection = getShapeFromCompound(theSubShapeName, aShape);
- else
- aSelection = aShape;
- }
- }
- }
- if(aSelection.IsNull()) {
- std::list<std::string> aListofNames;
- int n = ParseName(theSubShapeName, aListofNames);
- if(n > 1 && n < 4) { // 2 || 3
- TopTools_ListOfShape aList;
- for(std::list<std::string>::iterator it =aListofNames.begin();it != aListofNames.end();it++){
- const TopoDS_Shape aFace = findFaceByName(*it, aDoc);
- if(!aFace.IsNull())
- aList.Append(aFace);
- }
- aSelection = findCommonShape(TopAbs_VERTEX, aList);
- }
- }
- if(!aSelection.IsNull()) {// Select it
- std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
+ aSelection = getShapeFromNS(theSubShapeName, aNS);
+ }
+ }
+ if(aSelection.IsNull()) {
+ std::list<std::string> aListofNames;
+ int n = ParseName(theSubShapeName, aListofNames);
+ if(n > 1 && n < 4) { // 2 || 3
+ TopTools_ListOfShape aList;
+ std::list<std::string>::iterator it = aListofNames.begin();
+ for(; it != aListofNames.end(); it++){
+ const TopoDS_Shape aFace = findFaceByName(*it, aDoc);
+ if(!aFace.IsNull())
+ aList.Append(aFace);
+ }
+ aSelection = findCommonShape(TopAbs_VERTEX, aList);
+ }
+ }
+ if(!aSelection.IsNull()) {// Select it
+ std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
- setValue(aCont, aShapeToBeSelected);
- }
- }
- break;
+ setValue(aCont, aShapeToBeSelected);
+ }
+ }
+ break;
default: //TopAbs_SHAPE
- return;
+ return;
}
}
const TopoDS_Shape& aSubShape = aSelection->impl<TopoDS_Shape>();
int anID = 0;
if (aSelection && !aSelection->isNull() &&
- aContext && !aContext->isNull())
+ aContext && !aContext->isNull())
{
TopTools_IndexedMapOfShape aSubShapesMap;
TopExp::MapShapes(aMainShape, aSubShapesMap);
AttributePtr aResult;
TDF_Label anAttrLab = myLab.FindChild(myAttrs.size() + 1);
ModelAPI_Attribute* anAttr = 0;
- if (theAttrType == ModelAPI_AttributeDocRef::type()) {
+ if (theAttrType == ModelAPI_AttributeDocRef::typeId()) {
anAttr = new Model_AttributeDocRef(anAttrLab);
- } else if (theAttrType == Model_AttributeInteger::type()) {
+ } else if (theAttrType == Model_AttributeInteger::typeId()) {
anAttr = new Model_AttributeInteger(anAttrLab);
- } else if (theAttrType == ModelAPI_AttributeDouble::type()) {
+ } else if (theAttrType == ModelAPI_AttributeDouble::typeId()) {
anAttr = new Model_AttributeDouble(anAttrLab);
- } else if (theAttrType == Model_AttributeBoolean::type()) {
+ } else if (theAttrType == Model_AttributeBoolean::typeId()) {
anAttr = new Model_AttributeBoolean(anAttrLab);
- } else if (theAttrType == Model_AttributeString::type()) {
+ } else if (theAttrType == Model_AttributeString::typeId()) {
anAttr = new Model_AttributeString(anAttrLab);
- } else if (theAttrType == ModelAPI_AttributeReference::type()) {
+ } else if (theAttrType == ModelAPI_AttributeReference::typeId()) {
anAttr = new Model_AttributeReference(anAttrLab);
- } else if (theAttrType == ModelAPI_AttributeSelection::type()) {
+ } else if (theAttrType == ModelAPI_AttributeSelection::typeId()) {
anAttr = new Model_AttributeSelection(anAttrLab);
- } else if (theAttrType == ModelAPI_AttributeSelectionList::type()) {
+ } else if (theAttrType == ModelAPI_AttributeSelectionList::typeId()) {
anAttr = new Model_AttributeSelectionList(anAttrLab);
- } else if (theAttrType == ModelAPI_AttributeRefAttr::type()) {
+ } else if (theAttrType == ModelAPI_AttributeRefAttr::typeId()) {
anAttr = new Model_AttributeRefAttr(anAttrLab);
- } else if (theAttrType == ModelAPI_AttributeRefList::type()) {
+ } else if (theAttrType == ModelAPI_AttributeRefList::typeId()) {
anAttr = new Model_AttributeRefList(anAttrLab);
- } else if (theAttrType == ModelAPI_AttributeIntArray::type()) {
+ } else if (theAttrType == ModelAPI_AttributeIntArray::typeId()) {
anAttr = new Model_AttributeIntArray(anAttrLab);
}
// create also GeomData attributes here because only here the OCAF strucure is known
- else if (theAttrType == GeomData_Point::type()) {
+ else if (theAttrType == GeomData_Point::typeId()) {
anAttr = new GeomData_Point(anAttrLab);
- } else if (theAttrType == GeomData_Dir::type()) {
+ } else if (theAttrType == GeomData_Dir::typeId()) {
anAttr = new GeomData_Dir(anAttrLab);
- } else if (theAttrType == GeomData_Point2D::type()) {
+ } else if (theAttrType == GeomData_Point2D::typeId()) {
anAttr = new GeomData_Point2D(anAttrLab);
}
if (anAttr) {
std::list<ObjectPtr> aReferenced; // not inside of cycle to avoid excess memory menagement
for(; anAttr != myAttrs.end(); anAttr++) {
std::string aType = anAttr->second->attributeType();
- if (aType == ModelAPI_AttributeReference::type()) { // reference to object
+ if (aType == ModelAPI_AttributeReference::typeId()) { // reference to object
std::shared_ptr<ModelAPI_AttributeReference> aRef = std::dynamic_pointer_cast<
ModelAPI_AttributeReference>(anAttr->second);
aReferenced.push_back(aRef->value());
- } else if (aType == ModelAPI_AttributeRefAttr::type()) { // reference to attribute or object
+ } else if (aType == ModelAPI_AttributeRefAttr::typeId()) { // reference to attribute or object
std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
ModelAPI_AttributeRefAttr>(anAttr->second);
aReferenced.push_back(aRef->isObject() ? aRef->object() : aRef->attr()->owner());
- } else if (aType == ModelAPI_AttributeRefList::type()) { // list of references
+ } else if (aType == ModelAPI_AttributeRefList::typeId()) { // list of references
aReferenced = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttr->second)->list();
- } else if (aType == ModelAPI_AttributeSelection::type()) { // selection attribute
+ } else if (aType == ModelAPI_AttributeSelection::typeId()) { // selection attribute
std::shared_ptr<ModelAPI_AttributeSelection> aRef = std::dynamic_pointer_cast<
ModelAPI_AttributeSelection>(anAttr->second);
aReferenced.push_back(aRef->context());
- } else if (aType == ModelAPI_AttributeSelectionList::type()) { // list of selection attributes
+ } else if (aType == ModelAPI_AttributeSelectionList::typeId()) { // list of selection attributes
std::shared_ptr<ModelAPI_AttributeSelectionList> aRef = std::dynamic_pointer_cast<
ModelAPI_AttributeSelectionList>(anAttr->second);
for(int a = aRef->size() - 1; a >= 0; a--) {
{
// append the color attribute. It is empty, the attribute will be filled by a request
DataPtr aData = data();
- aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+ aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
}
void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName,
{
// append the color attribute. It is empty, the attribute will be filled by a request
DataPtr aData = data();
- aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+ aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
}
void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName,
{
// append the color attribute. It is empty, the attribute will be filled by a request
DataPtr aData = data();
- aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+ aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
}
void Model_ResultGroup::colorConfigInfo(std::string& theSection, std::string& theName,
{
ModelAPI_Result::setData(theData);
if (theData) {
- data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::type());
+ data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::typeId());
}
}
#include <Config_AttributeMessage.h>
#include <Config_ValidatorMessage.h>
#include <Config_ModuleReader.h>
+#include <Config_ValidatorReader.h>
#include <ModelAPI_ResultPart.h>
#include <TDF_CopyTool.hxx>
return;
// Read plugins information from XML files
- Config_ModuleReader aXMLReader(Config_FeatureMessage::MODEL_EVENT());
- aXMLReader.readAll();
+ Config_ModuleReader aModuleReader(Config_FeatureMessage::MODEL_EVENT());
+ aModuleReader.readAll();
+ std::set<std::string> aFiles = aModuleReader.modulePluginFiles();
+ std::set<std::string>::iterator it = aFiles.begin();
+ for ( ; it != aFiles.end(); it++ ) {
+ Config_ValidatorReader aValidatorReader (*it);
+ aValidatorReader.readAll();
+ };
+
}
void Model_Session::registerPlugin(ModelAPI_Plugin* thePlugin)
Config_PropManager::registerProp("Model update", "automatic_rebuild", "Rebuild immediately",
Config_Prop::Bool, "false");
- isAutomatic = Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
+ myIsAutomatic =
+ Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
}
void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessage)
static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
bool isAutomaticChanged = false;
if (theMessage->eventID() == kChangedEvent) { // automatic and manual rebuild flag is changed
- bool aPropVal =
- Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
- if (aPropVal == isAutomatic)
- return;// nothing to
- isAutomatic = aPropVal;
+ bool aPropVal =
+ Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
+ if (aPropVal == myIsAutomatic)
+ return; // nothing is changed, so nithing to do
+ myIsAutomatic = aPropVal;
+ if (!myIsAutomatic)
+ return; // less automatization => nothing to do
} else if (theMessage->eventID() == kRebuildEvent) { // the rebuild command
- if (isAutomatic == false) {
+ if (myIsAutomatic == false) {
isAutomaticChanged = true;
- isAutomatic = true;
+ myIsAutomatic = true;
}
} else if (theMessage->eventID() == kCreatedEvent || theMessage->eventID() == kUpdatedEvent ||
- theMessage->eventID() == kMovedEvent) {
+ theMessage->eventID() == kMovedEvent) {
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
const std::set<ObjectPtr>& anObjs = aMsg->objects();
std::set<ObjectPtr>::const_iterator anObjIter = anObjs.cbegin();
for(; anObjIter != anObjs.cend(); anObjIter++) {
myJustCreatedOrUpdated.insert(*anObjIter);
+ // created objects are always must be up to date (python box feature)
+ // and updated not in internal uptation chain
+ if (!myIsExecuted || theMessage->eventID() == kCreatedEvent)
+ myInitial.insert(*anObjIter);
// TODO(mpv): check the next line. Came into dev 0.6.1 from BR_PYTHON_PLUGIN
// (*anObjIter)->data()->mustBeUpdated(true); // object must be updated because it was changed
}
return; // this event is for solver update, not here
} else if (theMessage->eventID() == kOpStartEvent) {
myJustCreatedOrUpdated.clear();
+ myInitial.clear();
return; // we don't need the update only on operation start (caused problems in PartSet_Listener::processEvent)
} else if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent) {
- if (isAutomatic == false) { // Apply button now works as "Rebuild"
+ if (myIsAutomatic == false) { // Apply button now works as "Rebuild"
isAutomaticChanged = true;
- isAutomatic = true;
+ myIsAutomatic = true;
}
// the hardcode (DBC asked): hide the sketch referenced by extrusion on apply
if (theMessage->eventID() == kOpFinishEvent) {
}
}
- if (isExecuted)
+ if (myIsExecuted)
return; // nothing to do: it is executed now
//Events_LongOp::start(this);
- isExecuted = true;
- std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
- std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
- if (aMsg) myInitial = aMsg->objects();
- else {
- myInitial.clear();
- }
+ myIsExecuted = true;
// iterate all documents: features in Root first, then - subs
updateInDoc(ModelAPI_Session::get()->moduleDocument());
static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
aLoop->flush(EVENT_DISP);
//Events_LongOp::end(this);
- if (isAutomaticChanged) isAutomatic = false;
+ if (isAutomaticChanged) myIsAutomatic = false;
if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent) {
myJustCreatedOrUpdated.clear();
+ myInitial.clear();
}
- isExecuted = false;
+ myIsExecuted = false;
}
void Model_Update::updateInDoc(std::shared_ptr<ModelAPI_Document> theDoc)
if (std::dynamic_pointer_cast<Model_Document>(theFeature->document())->executeFeatures() ||
!theFeature->isPersistentResult()) {
if (aFactory->validate(theFeature)) {
- if (isAutomatic ||
+ if (myIsAutomatic ||
(myJustCreatedOrUpdated.find(theFeature) != myJustCreatedOrUpdated.end()) ||
!theFeature->isPersistentResult() /* execute quick, not persistent results */)
{
//std::cout<<"Execute feature "<<theFeature->getKind()<<std::endl;
// before execution update the selection attributes if any
list<AttributePtr> aRefs =
- theFeature->data()->attributes(ModelAPI_AttributeSelection::type());
+ theFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
list<AttributePtr>::iterator aRefsIter = aRefs.begin();
for (; aRefsIter != aRefs.end(); aRefsIter++) {
std::shared_ptr<ModelAPI_AttributeSelection> aSel =
aState = ModelAPI_StateInvalidArgument;
}
}
- aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::type());
+ aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
*/
class Model_Update : public Events_Listener
{
- /// initial set of updated features that must be processed
+ /// initial set of updated features that must be processed: caused by external changes, not
+ /// by sequence of update of this class
std::set<std::shared_ptr<ModelAPI_Object> > myInitial;
/// already updated and processed features and modificated feature flag
std::map<std::shared_ptr<ModelAPI_Object>, bool> myUpdated;
/// to know that all next updates are caused by this execution
- bool isExecuted;
+ bool myIsExecuted;
/// to know execute or not automatically all update
- bool isAutomatic;
+ bool myIsAutomatic;
/// just created features: they must be updated immideately even in not-automatic mode for
/// preview; cleared on commit operations
std::set<std::shared_ptr<ModelAPI_Object> > myJustCreatedOrUpdated;
}
%{
- #include "GeomAPI_Interface.h"
- #include "GeomAPI_Shape.h"
#include "ModelAPI.h"
#include "ModelAPI_Document.h"
#include "ModelAPI_Session.h"
#include "ModelAPI_ResultParameters.h"
#include "ModelAPI_ResultGroup.h"
#include "ModelAPI_Tools.h"
+
+ #include <memory>
+ #include <string>
template<class T1, class T2>
std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject)
{
return std::dynamic_pointer_cast<T1>(theObject);
}
-
+
%}
// to avoid error on this
#define MODELAPI_EXPORT
-#define GEOMAPI_EXPORT
// standard definitions
+%include "GeomAPI.i"
%include "typemaps.i"
%include "std_string.i"
%include "std_list.i"
%feature("director") ModelAPI_Plugin;
%feature("director") ModelAPI_Object;
%feature("director") ModelAPI_Feature;
+%feature("director") ModelAPI_CompositeFeature;
+%feature("director") ModelAPI_Data;
// shared pointers
// For ModelAPI_ResultConstruction.shape()
-%shared_ptr(GeomAPI_Interface)
-%shared_ptr(GeomAPI_Shape)
%shared_ptr(ModelAPI_Document)
%shared_ptr(ModelAPI_Session)
%shared_ptr(ModelAPI_Plugin)
%shared_ptr(ModelAPI_ResultParameters)
// all supported interfaces
-%include "GeomAPI_Interface.h"
-%include "GeomAPI_Shape.h"
%include "ModelAPI_Document.h"
%include "ModelAPI_Session.h"
%include "ModelAPI_Plugin.h"
// std::dynamic_pointer_cast
template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
-%template(modelAPI_CompositeFeature) shared_ptr_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
-%template(modelAPI_Feature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_Object>;
+%template(featureToCompositeFeature) shared_ptr_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
+%template(objectToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_Object>;
+%template(compositeFeatureToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_CompositeFeature>;
%template(modelAPI_Result) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
%template(modelAPI_ResultConstruction) shared_ptr_cast<ModelAPI_ResultConstruction, ModelAPI_Result>;
std::string ModelAPI_AttributeBoolean::attributeType()
{
- return type();
+ return typeId();
}
/// To virtually destroy the fields of successors
MODELAPI_EXPORT virtual bool value() = 0;
/// Returns the type of this class of attributes
- MODELAPI_EXPORT static std::string type()
+ MODELAPI_EXPORT static std::string typeId()
{
return "Boolean";
}
std::string ModelAPI_AttributeDocRef::attributeType()
{
- return type();
+ return typeId();
}
ModelAPI_AttributeDocRef::~ModelAPI_AttributeDocRef()
MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> value() = 0;
/// Returns the type of this class of attributes
- MODELAPI_EXPORT static std::string type()
+ MODELAPI_EXPORT static std::string typeId()
{
return "DocRef";
}
std::string ModelAPI_AttributeDouble::attributeType()
{
- return type();
+ return typeId();
}
ModelAPI_AttributeDouble::~ModelAPI_AttributeDouble()
MODELAPI_EXPORT virtual double value() = 0;
/// Returns the type of this class of attributes
- MODELAPI_EXPORT static std::string type()
+ MODELAPI_EXPORT static std::string typeId()
{
return "Double";
}
std::string ModelAPI_AttributeIntArray::attributeType()
{
- return type();
+ return typeId();
}
/// To virtually destroy the fields of successors
MODELAPI_EXPORT virtual int value(const int theIndex) = 0;
/// Returns the type of this class of attributes
- MODELAPI_EXPORT static std::string type()
+ MODELAPI_EXPORT static std::string typeId()
{
return "IntArray";
}
std::string ModelAPI_AttributeInteger::attributeType()
{
- return type();
+ return typeId();
}
/// To virtually destroy the fields of successors
MODELAPI_EXPORT virtual int value() = 0;
/// Returns the type of this class of attributes
- MODELAPI_EXPORT static std::string type()
+ MODELAPI_EXPORT static std::string typeId()
{
return "Integer";
}
std::string ModelAPI_AttributeRefAttr::attributeType()
{
- return type();
+ return typeId();
}
ModelAPI_AttributeRefAttr::~ModelAPI_AttributeRefAttr()
MODELAPI_EXPORT virtual ObjectPtr object() = 0;
/// Returns the type of this class of attributes
- MODELAPI_EXPORT static std::string type()
+ MODELAPI_EXPORT static std::string typeId()
{
return "RefAttr";
}
std::string ModelAPI_AttributeRefList::attributeType()
{
- return type();
+ return typeId();
}
ModelAPI_AttributeRefList::~ModelAPI_AttributeRefList()
{
public:
/// Returns the type of this class of attributes
- MODELAPI_EXPORT static std::string type()
+ MODELAPI_EXPORT static std::string typeId()
{
return "RefList";
}
std::string ModelAPI_AttributeReference::attributeType()
{
- return type();
+ return typeId();
}
ModelAPI_AttributeReference::~ModelAPI_AttributeReference()
MODELAPI_EXPORT virtual ObjectPtr value() = 0;
/// Returns the type of this class of attributes
- MODELAPI_EXPORT static std::string type()
+ MODELAPI_EXPORT static std::string typeId()
{
return "Reference";
}
std::string ModelAPI_AttributeSelection::attributeType()
{
- return type();
+ return typeId();
}
ModelAPI_AttributeSelection::~ModelAPI_AttributeSelection()
virtual bool update() = 0;
/// Returns the type of this class of attributes
- static std::string type()
+ static std::string typeId()
{
return "Selection";
}
std::string ModelAPI_AttributeSelectionList::attributeType()
{
- return type();
+ return typeId();
}
ModelAPI_AttributeSelectionList::~ModelAPI_AttributeSelectionList()
virtual void clear() = 0;
/// Returns the type of this class of attributes
- static std::string type()
+ static std::string typeId()
{
return "SelectionList";
}
std::string ModelAPI_AttributeString::attributeType()
{
- return type();
+ return typeId();
}
ModelAPI_AttributeString::~ModelAPI_AttributeString()
MODELAPI_EXPORT virtual std::string value() = 0;
/// Returns the type of this class of attributes
- MODELAPI_EXPORT static std::string type()
+ MODELAPI_EXPORT static std::string typeId()
{
return "String";
}
// flush it to avoid left presentations after input of invalid arguments (radius=0)
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
Events_Loop::loop()->flush(anEvent);
+ Events_Loop::loop()->flush(EVENT_DISP);
}
}
std::string aCurrentAttributeId = theAttribute->id();
// get all feature attributes
std::list<AttributePtr> anAttrs =
- aFeature->data()->attributes(ModelAPI_AttributeSelection::type());
+ aFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
if (anAttrs.size() > 0 && aShape.get() != NULL) {
std::list<AttributePtr>::iterator anAttr = anAttrs.begin();
for(; anAttr != anAttrs.end(); anAttr++) {
#===============================================================================
from ModelAPI import *
assert (ModelAPI_Feature.group() == "Features")
-assert (ModelAPI_AttributeDocRef.type() == "DocRef")
-assert (ModelAPI_AttributeDouble.type() == "Double")
-assert (ModelAPI_AttributeReference.type() == "Reference")
-assert (ModelAPI_AttributeRefAttr.type() == "RefAttr")
-assert (ModelAPI_AttributeRefList.type() == "RefList")
\ No newline at end of file
+assert (ModelAPI_AttributeDocRef.typeId() == "DocRef")
+assert (ModelAPI_AttributeDouble.typeId() == "Double")
+assert (ModelAPI_AttributeReference.typeId() == "Reference")
+assert (ModelAPI_AttributeRefAttr.typeId() == "RefAttr")
+assert (ModelAPI_AttributeRefList.typeId() == "RefList")
\ No newline at end of file
std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
return aComposite && aComposite->numberOfSubs() > 0;
}
+ else
+ return Standard_True;
}
}
return Standard_False;
}
ModelAPI_Session::get()->startOperation(anId.toStdString());
- if (!myIsEditing)
- createFeature();
+ if (!myIsEditing) {
+ FeaturePtr aFeature = createFeature();
+ // if the feature is not created, there is no sense to start the operation
+ if (aFeature.get() == NULL) {
+ // it is necessary to abor the operation in the session and emit the aborted signal
+ // in order to update commands status in the workshop, to be exact the feature action
+ // to be unchecked
+ abort();
+ return;
+ }
+ }
startOperation();
emit started();
std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
if ((*aIt) == aRes)
+// TODO(nds): v1.0.2 (master)
+// // Check the acceptability of the object as attribute
+// aValidator = aValidators.begin();
+// std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
+// for (; aValidator != aValidators.end(); aValidator++, aArgs++) {
+// const ModelAPI_RefAttrValidator* aAttrValidator =
+// dynamic_cast<const ModelAPI_RefAttrValidator*>(*aValidator);
+// if (aAttrValidator) {
+// if (!aAttrValidator->isValid(myFeature, *aArgs, theObj, theShape)) {
return false;
}
}
<!-- Major module parameters -->
<parameter name="name" value="NewGeom"/>
<parameter name="icon" value="newgeom.png"/>
- <parameter name="version" value="1.0.0"/>
+ <parameter name="version" value="1.0.2"/>
<parameter name="documentation" value="newgeom_help"/>
</section>
<section name="newgeom_help" >
<!-- Major module parameters -->
<parameter name="name" value="NewGeom"/>
<parameter name="icon" value="newgeom.png"/>
- <parameter name="version" value="1.0.0"/>
+ <parameter name="version" value="1.0.2"/>
<parameter name="documentation" value="newgeom_help"/>
</section>
<section name="newgeom_help" >
void ParametersPlugin_Parameter::initAttributes()
{
- data()->addAttribute(ParametersPlugin_Parameter::VARIABLE_ID(), ModelAPI_AttributeString::type());
- data()->addAttribute(ParametersPlugin_Parameter::EXPRESSION_ID(), ModelAPI_AttributeString::type());
+ data()->addAttribute(ParametersPlugin_Parameter::VARIABLE_ID(), ModelAPI_AttributeString::typeId());
+ data()->addAttribute(ParametersPlugin_Parameter::EXPRESSION_ID(), ModelAPI_AttributeString::typeId());
}
void ParametersPlugin_Parameter::execute()
Config
GeomAPI
GeomValidators
+ GeomDataAPI
${QT_LIBRARIES}
${CAS_KERNEL}
${CAS_SHAPE}
std::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = std::shared_ptr<GeomAPI_Pnt2d>(
new GeomAPI_Pnt2d(theX, theY));
std::list<std::shared_ptr<ModelAPI_Attribute> > anAttiributes =
- theFeature->data()->attributes(GeomDataAPI_Point2D::type());
+ theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
aLast = anAttiributes.end();
std::shared_ptr<GeomDataAPI_Point2D> aFPoint;
for (int i = 0; i < theSketch->numberOfSubs(); i++) {
FeaturePtr aFeature = theSketch->subFeature(i);
if (!theIgnore.contains(aFeature)) {
- anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+ anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt;
for (anIt = anAttiributes.cbegin(); anIt != anAttiributes.cend(); ++anIt) {
if (theFeature == aFeature)
continue;
// find the given point in the feature attributes
- anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+ anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
aLast = anAttiributes.end();
std::shared_ptr<GeomDataAPI_Point2D> aFPoint;
// find the given point in the feature attributes
std::list<AttributePtr> anAttiributes =
- aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+ aFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<AttributePtr>::const_iterator anIt = anAttiributes.begin(),
aLast = anAttiributes.end();
for (; anIt != aLast && !anAttribute; anIt++) {
if (featureHasReferences(theAttribute)) {
// 3. check whether the attribute value is not among other feature attributes
std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs =
- aFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+ aFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
for(; anAttr != anAttrs.end(); anAttr++) {
if (*anAttr) {
if (!aRef->isObject() && aRef->attr() == theAttribute)
return false;
}
+// TODO(nds) v1.0.2 master
+//bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
+// const std::list<std::string>& theArguments,
+// const ObjectPtr& theObject,
+// const GeomShapePtr& theShape) const
+//{
+// // Check RefAttr attributes
+// std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs =
+// theFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
+// if (anAttrs.size() > 0) {
+// std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+// for(; anAttr != anAttrs.end(); anAttr++) {
+// if (*anAttr) {
+// std::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
+// std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+// // check the object is already presented
+// if (aRef->isObject() && aRef->object() == theObject)
+// return false;
+// }
+// }
+// }
+// // Check selection attributes
+// anAttrs = theFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
+// if (anAttrs.size() > 0) {
+// std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+// for(; anAttr != anAttrs.end(); anAttr++) {
+// if (*anAttr) {
+// std::shared_ptr<ModelAPI_AttributeSelection> aRef =
+// std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*anAttr);
+// // check the object is already presented
+// if (aRef->isInitialized() && aRef->context() == theObject) {
+// if (theShape.get() != NULL) {
+// if (aRef->value()->isEqual(theShape))
+// return false;
+// } else
+// return false;
+// }
+// }
+// }
+// }
+// // Check selection attributes
+// anAttrs = theFeature->data()->attributes(ModelAPI_AttributeReference::typeId());
+// if (anAttrs.size() > 0) {
+// std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+// for(; anAttr != anAttrs.end(); anAttr++) {
+// if (*anAttr) {
+// std::shared_ptr<ModelAPI_AttributeReference> aRef =
+// std::dynamic_pointer_cast<ModelAPI_AttributeReference>(*anAttr);
+// // check the object is already presented
+// if (aRef->isInitialized() && aRef->value() == theObject)
+// return false;
+// ======= end of todo
}
return true;
}
}
bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr& theAttribute) const
+// TODO(nds) v1.0.2 master
+//bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
+// const std::list<std::string>& theArguments,
+// const AttributePtr& theAttribute) const
+//{
+// if (PartSet_DifferentObjectsValidator::isValid(theAttribute, theArguments)) {
+// std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs =
+// theFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
+// std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+// for(; anAttr != anAttrs.end(); anAttr++) {
+// if (*anAttr) {
+// std::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
+// std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+// // check the object is already presented
+// if (!aRef->isObject() && aRef->attr() == theAttribute)
+// return false;
+// }
+// }
+// return true;
+// }
+// return false;
+//}
+//
+//bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute,
+// const std::list<std::string>& theArguments) const
+// ======= end of todo
{
std::list<std::pair<std::string, std::list<ObjectPtr> > > allRefs;
if (theAttribute->owner().get() && theAttribute->owner()->data().get())
}
std::string anAttributeType = theAttribute->attributeType();
- if (anAttributeType == ModelAPI_AttributeSelectionList::type()) {
+ if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
AttributeSelectionListPtr aSelectionListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
// it filters only selection list attributes
isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
}
}
- if (anAttributeType == ModelAPI_AttributeRefAttr::type()) {
+ if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
std::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
isSketchEntities = false;
class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
{
public:
+// TODO(nds) v1.0.2 master
+// /// Returns True if the feature is valid
+// /// \param theFeature a feature to check
+// /// \param theArguments a list of arguments (names of attributes to check)
+// /// \param theObject a selected object
+// /// \param theShape a selected sub-shape
+// virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+// const ObjectPtr& theObject, const GeomShapePtr& theShape) const;
+//
+// //! Returns true if the attribute is good for the feature attribute
+// //! \param theFeature a feature to check
+// //! \param theArguments a list of arguments (names of attributes to check)
+// //! \param theAttribute an attribute
+// virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+// const AttributePtr& theAttribute) const;
+ // ======= end of todo
//! Returns true if the attribute is good for the feature attribute
//! \param theAttribute an attribute
//! \param theArguments a list of arguments (names of attributes to check)
const std::list<std::string>& theArguments) const;
};
-#endif
\ No newline at end of file
+#endif
if (aObj != myExternalObject) {
removeExternal();
myExternalObject = aObj;
+// TODO(nds) v1.0.2 master
+// // Check the acceptability of the object and shape as validator attribute
+// AttributePtr aPntAttr;
+// DataPtr aData = myFeature->data();
+// if (theShape.get() != NULL) {
+// AttributePtr aAttr = aData->attribute(attributeID());
+// AttributeRefAttrPtr aRefAttr =
+// std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aAttr);
+// if (aRefAttr) {
+// TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+// aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theObj, aShape, mySketch);
+// }
+// }
+// // Check the acceptability of the object as attribute
+// aValidator = aValidators.begin();
+// std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
+// for (; aValidator != aValidators.end(); aValidator++, aArgs++) {
+// const ModelAPI_RefAttrValidator* aAttrValidator =
+// dynamic_cast<const ModelAPI_RefAttrValidator*>(*aValidator);
+// if (aAttrValidator) {
+// if (aPntAttr.get() != NULL)
+// {
+// if (!aAttrValidator->isValid(myFeature, *aArgs, aPntAttr)) {
+// return false;
+// }
+// }
+// else
+// {
+// if (!aAttrValidator->isValid(myFeature, *aArgs, theObj, theShape)) {
+// return false;
+// }
+// }
+// }
+// ======= end of todo
}
}
--- /dev/null
+INCLUDE(Common)
+
+SET(PYTHON_FILES
+ PythonFeaturesPlugin_Box.py
+ PythonFeaturesPlugin.py
+ sketch.py
+ extrusion.py
+ examples.py
+ SketchResult.py
+)
+
+SET(XML_RESSOURCES
+ plugin-PythonFeatures.xml
+ box_widget.xml
+)
+
+INSTALL(FILES ${PYTHON_FILES} ${XML_RESSOURCES} DESTINATION plugins)
--- /dev/null
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+
+# NOTE : I think this style should be chosen
+# for function as recommended by Python programming
+# standards
+
+
+def build_face_from_sketch(sketch, edges=None):
+ # If no edges have been selected, get the whole sketch
+ # edges
+ if edges == None:
+ result = sketch.firstResult()
+ edges = modelAPI_ResultConstruction(result).shape()
+
+ # Build the face
+ origin = geomDataAPI_Point(sketch.attribute("Origin")).pnt()
+ dirX = geomDataAPI_Dir(sketch.attribute("DirX")).dir()
+ dirY = geomDataAPI_Dir(sketch.attribute("DirY")).dir()
+ normal = geomDataAPI_Dir(sketch.attribute("Norm")).dir()
+ faces = ShapeList()
+ GeomAlgoAPI_SketchBuilder.createFaces(
+ origin, dirX, dirY, normal, edges, faces)
+ return faces[0]
+
+# NOTE : with an optional argument it is not
+# a so good idea to put part as last argument
+# it would result in a mandatory argument
+# put after an optionnal one
+
+
+def addExtrusion(part, sketch, size, reverse=False, subshapes=None):
+ feature = part.addFeature("Extrusion")
+
+ # Build apropriate face
+ face = build_face_from_sketch(sketch, subshapes)
+ # Get sketch result
+ sketchResult = sketch.firstResult()
+
+ # Set attributes and execute the feature
+ feature.selection("extrusion_face").setValue(sketchResult, face)
+ feature.real("extrusion_size").setValue(size)
+ feature.boolean("extrusion_reverse").setValue(False)
+ feature.execute()
+
+ return feature
--- /dev/null
+"""
+"""
+
+import ModelAPI
+from PythonFeaturesPlugin_Box import PythonFeaturesPlugin_Box
+
+
+class PythonFeaturesPlugin(ModelAPI.ModelAPI_Plugin):
+
+ def __init__(self):
+ ModelAPI.ModelAPI_Plugin.__init__(self)
+ aSession = ModelAPI.ModelAPI_Session.get()
+ aSession.registerPlugin(self)
+ pass
+
+ def createFeature(self, theFeatureID):
+ aFeature = None
+ if theFeatureID == PythonFeaturesPlugin_Box.ID():
+ aCompositeFeature = PythonFeaturesPlugin_Box().__disown__()
+ aFeature = ModelAPI.compositeFeatureToFeature(aCompositeFeature)
+ else:
+ raise StandardError("No such feature %s" % theFeatureID)
+ return aFeature
+
+
+plugin = PythonFeaturesPlugin()
+plugin.__disown__()
--- /dev/null
+import ModelAPI
+
+from SketchResult import SketchResult
+import extrusion
+import sketch
+
+
+class PythonFeaturesPlugin_Box(ModelAPI.ModelAPI_CompositeFeature):
+ """Feature to create a box by drawing a sketch and extruding it
+ """
+
+ def __init__(self):
+ ModelAPI.ModelAPI_CompositeFeature.__init__(self)
+
+ @staticmethod
+ def ID():
+ return "Box"
+
+ @staticmethod
+ def WIDTH_ID():
+ return "box_width"
+
+ @staticmethod
+ def LENGTH_ID():
+ return "box_length"
+
+ @staticmethod
+ def HEIGHT_ID():
+ return "box_height"
+
+ @staticmethod
+ def WIDTH_REF_ID():
+ return "box_ref_width"
+
+ @staticmethod
+ def LENGTH_REF_ID():
+ return "box_ref_length"
+
+ @staticmethod
+ def HEIGHT_REF_ID():
+ return "box_ref_height"
+
+ def getKind(self):
+ return PythonFeaturesPlugin_Box.ID()
+
+ def initAttributes(self):
+ # C++ static methods (in example "type()" of the ModelAPI_AttributeDouble
+ # should be called like this: moduleName.ClassName_staticMethod()
+ self.data().addAttribute(self.WIDTH_ID(), ModelAPI.ModelAPI_AttributeDouble_typeId())
+ self.data().addAttribute(self.LENGTH_ID(), ModelAPI.ModelAPI_AttributeDouble_typeId())
+ self.data().addAttribute(self.HEIGHT_ID(), ModelAPI.ModelAPI_AttributeDouble_typeId())
+ self.data().addAttribute(self.WIDTH_REF_ID(), ModelAPI.ModelAPI_AttributeReference_typeId())
+ self.data().addAttribute(self.LENGTH_REF_ID(), ModelAPI.ModelAPI_AttributeReference_typeId())
+ self.data().addAttribute(self.HEIGHT_REF_ID(), ModelAPI.ModelAPI_AttributeReference_typeId())
+ aSession = ModelAPI.ModelAPI_Session.get()
+ aSession.validators().registerNotObligatory(self.getKind(), self.WIDTH_REF_ID())
+ aSession.validators().registerNotObligatory(self.getKind(), self.LENGTH_REF_ID())
+ aSession.validators().registerNotObligatory(self.getKind(), self.HEIGHT_REF_ID())
+ aSession.validators().registerConcealment(self.getKind(), self.HEIGHT_REF_ID())
+ self.mySketch = None # not yet initialized
+ self.myExtrusion = None # not yet initialized
+
+ def execute(self):
+ aWidth = self.real(self.WIDTH_ID()).value()
+ aLength = self.real(self.LENGTH_ID()).value()
+ aHeight = self.real(self.HEIGHT_ID()).value()
+ aWidthRefValue = self.reference(self.WIDTH_REF_ID()).value()
+ aLengthRefValue = self.reference(self.LENGTH_REF_ID()).value()
+ aHeightRefValue = self.reference(self.HEIGHT_REF_ID()).value()
+ aResult = None
+ if not all((aWidthRefValue, aLengthRefValue, aHeightRefValue)):
+ aResult = extrusion.getBody(self.makeBox(aLength, aWidth, aHeight))
+ else:
+ aHeightProxyResult = ModelAPI.modelAPI_Result(aHeightRefValue)
+ aWidthFeature = ModelAPI.objectToFeature(aWidthRefValue)
+ aLengthFeature = ModelAPI.objectToFeature(aLengthRefValue)
+ aHeightResult = ModelAPI.modelAPI_ResultBody(aHeightProxyResult)
+ aWidthFeature.real("ConstraintValue").setValue(aWidth)
+ aLengthFeature.real("ConstraintValue").setValue(aLength)
+ if aHeightResult is not None:
+ aHeightFeature = aHeightResult.document().feature(aHeightResult)
+ aHeightFeature.real("extrusion_size").setValue(aHeight)
+ aResult = extrusion.getBody(aHeightFeature)
+ # create a new result with copied shape from extrusion
+ aResultBody = self.document().createBody(self.data())
+ if not aResult is None:
+ aResultBody.store(aResult.shape())
+ self.setResult(aResultBody)
+ pass
+
+ def makeBox(self, aWidth, aLength, aHeight):
+ aSession = ModelAPI.ModelAPI_Session.get()
+ aPart = aSession.activeDocument()
+ # Starting the Sketch
+ aSketch = sketch.addTo(aPart)
+ self.mySketch = aSketch
+ sketch.setXOYPlane(aSketch)
+ # Creating the lines
+ l1 = sketch.addLine(10, 10, 10, 60, aSketch)
+ l2 = sketch.addLine(10, 60, 60, 60, aSketch)
+ l3 = sketch.addLine(60, 60, 60, 10, aSketch)
+ l4 = sketch.addLine(60, 10, 10, 10, aSketch)
+ aSketch.execute()
+ # Creating the constraints
+ sketch.makeCoincident(sketch.getEndPoint(l1), sketch.getStartPoint(l2), aSketch)
+ sketch.makeCoincident(sketch.getEndPoint(l2), sketch.getStartPoint(l3), aSketch)
+ sketch.makeCoincident(sketch.getEndPoint(l3), sketch.getStartPoint(l4), aSketch)
+ sketch.makeCoincident(sketch.getEndPoint(l4), sketch.getStartPoint(l1), aSketch)
+ sketch.makeParallel(sketch.getGeometry(l1), sketch.getGeometry(l3), aSketch)
+ sketch.makeParallel(sketch.getGeometry(l2), sketch.getGeometry(l4), aSketch)
+ sketch.makePerpendicular(sketch.getGeometry(l1), sketch.getGeometry(l4), aSketch)
+ # Set to 0X and 0Y lines defined length
+ aWidthFeature = sketch.makeConstantLength(sketch.getGeometry(l4), aWidth, aSketch)
+ aLengthFeature = sketch.makeConstantLength(sketch.getGeometry(l1), aLength, aSketch)
+ # Finalisation of the operation
+ builder = SketchResult(aSketch)
+ # Creating a feature Extrusion
+ aHeightFeature = extrusion.addNew(builder, aHeight, aPart)
+ self.myExtrusion = aHeightFeature
+ # Store features...
+ self.reference(self.WIDTH_REF_ID()).setValue(aWidthFeature)
+ self.reference(self.LENGTH_REF_ID()).setValue(aLengthFeature)
+ self.reference(self.HEIGHT_REF_ID()).setValue(aHeightFeature.firstResult())
+ return aHeightFeature
+
+ def addFeature(self, theID):
+ pass
+
+ def numberOfSubs(self):
+ subsCount = 0
+ if not self.mySketch is None:
+ subsCount += 1
+ if not self.myExtrusion is None:
+ subsCount += 1
+ # extrusion and sketch
+ return subsCount
+
+ def subFeature(self, theIndex):
+ if theIndex == 0: # sketch
+ return ModelAPI.compositeFeatureToFeature(self.mySketch)
+ return self.myExtrusion
+
+ def subFeatureId(self, theIndex):
+ return 0
+
+ def isSub(self, theFeature):
+ return theFeature == self.mySketch or theFeature == self.myExtrusion
+
+ def attributeChanged(self, theAttrID):
+ # on update of attributes values, transfer them to sub-features immideately to see good preview
+ # otherwise these features will be executed before execute of "Box" and with old parameters
+ aWidthRefValue = self.reference(self.WIDTH_REF_ID()).value()
+ aLengthRefValue = self.reference(self.LENGTH_REF_ID()).value()
+ aHeightRefValue = self.reference(self.HEIGHT_REF_ID()).value()
+ if all((aWidthRefValue, aLengthRefValue, aHeightRefValue)):
+ self.execute()
+
+# TEST
+"""
+if __name__=='__main__':
+ session = ModelAPI.ModelAPI_Session.get()
+ part = session.activeDocument()
+ session.startOperation()
+ feature = part.addFeature('Box')
+ feature.real('box_width').setValue(10)
+ feature.real('box_length').setValue(10)
+ feature.real('box_height').setValue(10)
+ feature.execute()
+ session.finishOperation()
+"""
--- /dev/null
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+
+
+class SketchResult:
+
+ def __init__(self, sketch):
+ self.geom = sketch.firstResult()
+ self.faces = ShapeList()
+ self.edges = modelAPI_ResultConstruction(self.geom).shape()
+ self.origin = geomDataAPI_Point(sketch.attribute("Origin")).pnt()
+ self.dirX = geomDataAPI_Dir(sketch.attribute("DirX")).dir()
+ self.dirY = geomDataAPI_Dir(sketch.attribute("DirY")).dir()
+ self.normal = geomDataAPI_Dir(sketch.attribute("Norm")).dir()
+
+ def setEdges(self, edges):
+ self.edges = edges
+
+ def geometry(self):
+ return self.geom
+
+ def face(self):
+ GeomAlgoAPI_SketchBuilder.createFaces(
+ self.origin, self.dirX, self.dirY, self.normal, self.edges, self.faces)
+ return self.faces[0]
--- /dev/null
+<source>
+ <doublevalue id="box_width" label="Width" min="0" step="1.0" default="50" icon=":icons/dimension_v.png" tooltip="Set width of the box">
+ <validator id="GeomValidators_Positive"/>
+ </doublevalue>
+ <doublevalue id="box_length" label="Length" min="0" step="1.0" default="50" icon=":icons/dimension_v.png" tooltip="Set length of the box">
+ <validator id="GeomValidators_Positive"/>
+ </doublevalue>
+ <doublevalue id="box_height" label="Height" min="0" step="1.0" default="50" icon=":icons/dimension_v.png" tooltip="Set height of the box">
+ <validator id="GeomValidators_Positive"/>
+ </doublevalue>
+</source>
--- /dev/null
+from ModelAPI import *
+from SketchResult import *
+import sketch
+import extrusion
+# reload(sketch) # Pour tester plus facilement
+# reload(extrusion) # Pour tester plus facilement
+
+
+def makeBox(aLength, aWidth, aHeight):
+ # Getting the active document
+ session = ModelAPI_Session.get()
+ part = session.activeDocument()
+
+ # Starting the Sketch
+ base = sketch.addTo(part)
+ sketch.setXOYPlane(base)
+
+ # Creating the lines
+ l1 = sketch.addLine(10, 10, 10, 50, base)
+ l2 = sketch.addLine(10, 50, 60, 60, base)
+ l3 = sketch.addLine(60, 60, 50, 10, base)
+ l4 = sketch.addLine(50, 10, 10, 10, base)
+ base.execute()
+
+ # Creating the constraints
+ sketch.makeCoincident(sketch.getEndPoint(l1),
+ sketch.getStartPoint(l2), base)
+ sketch.makeCoincident(sketch.getEndPoint(l2),
+ sketch.getStartPoint(l3), base)
+ sketch.makeCoincident(sketch.getEndPoint(l3),
+ sketch.getStartPoint(l4), base)
+ sketch.makeCoincident(sketch.getEndPoint(l4),
+ sketch.getStartPoint(l1), base)
+
+ sketch.makeParallel(sketch.getGeometry(l1), sketch.getGeometry(l3), base)
+ sketch.makeParallel(sketch.getGeometry(l2), sketch.getGeometry(l4), base)
+
+ sketch.makePerpendicular(sketch.getGeometry(l1),
+ sketch.getGeometry(l4), base)
+ # Set to 0X and 0Y lines defined length
+ sketch.makeConstantLength(sketch.getGeometry(l1), aLength, base)
+ sketch.makeConstantLength(sketch.getGeometry(l4), aWidth, base)
+
+ # Finalisation of the operation
+ builder = SketchResult(base)
+
+ # Creating a feature Extrusion
+ box = extrusion.addNew(builder, aHeight, part)
+
+ # return base.lastResult()
+ return extrusion.getBody(box)
--- /dev/null
+from ModelAPI import *
+
+
+def addNew(builder, length, part, edges=None, reverse=False):
+ feature = part.addFeature("Extrusion")
+ feature.selection("extrusion_face").setValue(builder.geometry(),
+ builder.face())
+ if length < 0.0000001:
+ length = 50
+ feature.real("extrusion_size").setValue(length)
+ feature.boolean("extrusion_reverse").setValue(reverse)
+ feature.execute()
+ return feature
+
+
+def getBody(extrusion):
+ return modelAPI_ResultBody(extrusion.firstResult())
--- /dev/null
+<plugin>
+ <workbench id="Features" document="Part">
+ <group id="Basic">
+ <feature id="Box" title="Box" tooltip="Create a box" icon=":pictures/part_ico.png">
+ <source path="box_widget.xml"/>
+ </feature>
+ </group>
+ </workbench>
+</plugin>
--- /dev/null
+from ModelAPI import *
+from GeomDataAPI import *
+
+
+# Initialization of the Sketch
+# ----------------------------
+
+def addTo(doc):
+ return featureToCompositeFeature(doc.addFeature("Sketch"))
+
+
+def setXOYPlane(sketch):
+ geomDataAPI_Point(sketch.attribute("Origin")).setValue(0, 0, 0)
+ geomDataAPI_Dir(sketch.attribute("DirX")).setValue(1, 0, 0)
+ geomDataAPI_Dir(sketch.attribute("DirY")).setValue(0, 1, 0)
+ geomDataAPI_Dir(sketch.attribute("Norm")).setValue(0, 0, 1)
+
+
+# Point geometry
+# --------------
+
+def addPoint(x, y, sketch):
+ point = sketch.addFeature("SketchPoint")
+ geomDataAPI_Point2D(point.attribute("PointCoordindates")).setValue(x, y)
+ # Required to get the result, if needed for creating constraints
+ point.execute()
+ return point
+
+
+def getGeometry(point):
+ return geomDataAPI_Point2D(point.attribute("PointCoordindates"))
+
+
+# Line geometry
+# -------------
+
+def addClosedBrokenLine(coords, sketch):
+ c0 = coords[0]
+ c1 = coords[1]
+ bl = []
+ l1 = sketch.addFeature("SketchLine")
+ geomDataAPI_Point2D(l1.attribute("StartPoint")).setValue(c0.x(), c0.y())
+ geomDataAPI_Point2D(l1.attribute("EndPoint")).setValue(c1.x(), c1.y())
+ l1.execute()
+ bl.append(l1)
+ l0 = l1
+
+ for c2 in coords[2:]:
+ l2 = sketch.addFeature("SketchLine")
+ geomDataAPI_Point2D(
+ l2.attribute("StartPoint")).setValue(c1.x(), c1.y())
+ geomDataAPI_Point2D(l2.attribute("EndPoint")).setValue(c2.x(), c2.y())
+ l2.execute()
+ bl.append(l2)
+ constraint = sketch.addFeature("SketchConstraintCoincidence")
+ constraint.refattr("ConstraintEntityA").setAttr(
+ l1.attribute("EndPoint"))
+ constraint.refattr("ConstraintEntityB").setAttr(
+ l2.attribute("StartPoint"))
+ c1 = c2
+ l1 = l2
+
+ if len(coords) > 2:
+ l2 = sketch.addFeature("SketchLine")
+ geomDataAPI_Point2D(
+ l2.attribute("StartPoint")).setValue(c1.x(), c1.y())
+ geomDataAPI_Point2D(l2.attribute("EndPoint")).setValue(c0.x(), c0.y())
+ l2.execute()
+ bl.append(l2)
+ constraint = sketch.addFeature("SketchConstraintCoincidence")
+ constraint.refattr("ConstraintEntityA").setAttr(
+ l1.attribute("EndPoint"))
+ constraint.refattr("ConstraintEntityB").setAttr(
+ l2.attribute("StartPoint"))
+
+ constraint = sketch.addFeature("SketchConstraintCoincidence")
+ constraint.refattr("ConstraintEntityA").setAttr(
+ l2.attribute("EndPoint"))
+ constraint.refattr("ConstraintEntityB").setAttr(
+ l0.attribute("StartPoint"))
+
+ return bl
+
+
+def addLine(x1, y1, x2, y2, sketch):
+ line = sketch.addFeature("SketchLine")
+ geomDataAPI_Point2D(line.attribute("StartPoint")).setValue(x1, y1)
+ geomDataAPI_Point2D(line.attribute("EndPoint")).setValue(x2, y2)
+ # Required to get the result, if needed for creating constraints
+ line.execute()
+ return line
+
+
+def getGeometry(line):
+ return modelAPI_ResultConstruction(line.firstResult())
+
+
+def getStartPoint(line):
+ return geomDataAPI_Point2D(line.attribute("StartPoint"))
+
+
+def getEndPoint(line):
+ return geomDataAPI_Point2D(line.attribute("EndPoint"))
+
+
+# Constraints
+# -----------
+
+def makeCoincident(p1, p2, sketch):
+ constraint = sketch.addFeature("SketchConstraintCoincidence")
+ constraint.refattr("ConstraintEntityA").setAttr(p1)
+ constraint.refattr("ConstraintEntityB").setAttr(p2)
+ return constraint
+
+
+def makeParallel(l1, l2, sketch):
+ constraint = sketch.addFeature("SketchConstraintParallel")
+ constraint.refattr("ConstraintEntityA").setObject(l1)
+ constraint.refattr("ConstraintEntityB").setObject(l2)
+ return constraint
+
+
+def makePerpendicular(l1, l2, sketch):
+ constraint = sketch.addFeature("SketchConstraintPerpendicular")
+ constraint.refattr("ConstraintEntityA").setObject(l1)
+ constraint.refattr("ConstraintEntityB").setObject(l2)
+ return constraint
+
+
+def makeConstantLength(line, length, sketch):
+ constraint = sketch.addFeature("SketchConstraintLength")
+ constraint.refattr("ConstraintEntityA").setObject(line)
+ constraint.real("ConstraintValue").setValue(length)
+ return constraint
GeomValidators
ModelAPI
SketcherPrs
+ GeomDataAPI
${CAS_KERNEL}
${CAS_SHAPE}
)
{
SketchPlugin_SketchEntity::initAttributes();
- data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(START_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(END_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+ data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(START_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(END_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
{
SketchPlugin_SketchEntity::initAttributes();
- data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(RADIUS_ID(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+ data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
void SketchPlugin_ConstraintCoincidence::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
}
void SketchPlugin_ConstraintCoincidence::execute()
anAIS->setColor(0, 0, 255);
}
return anAIS;
-}
\ No newline at end of file
+}
//*************************************************************************************
void SketchPlugin_ConstraintDistance::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
}
//*************************************************************************************
void SketchPlugin_ConstraintEqual::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
}
void SketchPlugin_ConstraintEqual::execute()
void SketchPlugin_ConstraintFillet::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::type());
+ data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId());
// initialize attribute not applicable for user
data()->attribute(SketchPlugin_Constraint::ENTITY_C())->setInitialized();
}
void SketchPlugin_ConstraintHorizontal::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
}
void SketchPlugin_ConstraintHorizontal::execute()
void SketchPlugin_ConstraintLength::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
}
void SketchPlugin_ConstraintLength::execute()
void SketchPlugin_ConstraintMirror::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId());
}
void SketchPlugin_ConstraintMirror::execute()
void SketchPlugin_ConstraintParallel::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
- //data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+ //data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
}
void SketchPlugin_ConstraintParallel::execute()
void SketchPlugin_ConstraintPerpendicular::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
}
void SketchPlugin_ConstraintPerpendicular::execute()
void SketchPlugin_ConstraintRadius::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
}
void SketchPlugin_ConstraintRadius::execute()
void SketchPlugin_ConstraintRigid::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
}
void SketchPlugin_ConstraintRigid::execute()
void SketchPlugin_ConstraintTangent::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
}
void SketchPlugin_ConstraintTangent::execute()
void SketchPlugin_ConstraintVertical::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
}
void SketchPlugin_ConstraintVertical::execute()
{
SketchPlugin_SketchEntity::initAttributes();
- data()->addAttribute(START_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(END_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+ data()->addAttribute(START_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(END_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
{
SketchPlugin_SketchEntity::initAttributes();
- data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+ data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
void SketchPlugin_Sketch::initAttributes()
{
- data()->addAttribute(SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point::type());
- data()->addAttribute(SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir::type());
- data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::type());
- data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::type());
+ data()->addAttribute(SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point::typeId());
+ data()->addAttribute(SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir::typeId());
+ data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::typeId());
+ data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::typeId());
// the selected face, base for the sketcher plane, not obligatory
- data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+ data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(
getKind(), SketchPlugin_SketchEntity::EXTERNAL_ID());
}
void SketchPlugin_SketchEntity::initAttributes()
{
- data()->addAttribute(AUXILIARY_ID(), ModelAPI_AttributeBoolean::type());
+ data()->addAttribute(AUXILIARY_ID(), ModelAPI_AttributeBoolean::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), AUXILIARY_ID());
}
virtual bool isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments) const;
};
+// virtual bool isValid(const AttributePtr& theAttribute,
+// const std::list<std::string>& theArguments) const;
+//
+// //! Returns true if object is good for the feature attribute
+// virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+// const ObjectPtr& theObject, const GeomShapePtr& theShape) const;
+//
+// //! Returns true if the attribute is good for the feature attribute
+// virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+// const AttributePtr& theAttribute) const;
+//};
+
+// commented in v1.0.2, master:
+/**\class SketchPlugin_DifferentObjectsValidator
+ * \ingroup Validators
+ *
+ * Check that there is no same object was already selected in the feature.
+ * For an example: to avoid perpendicularity on line and the same line.
+ */
+// Use PartSet_DifferentObjectsValidator instead
+//class SketchPlugin_DifferentObjectsValidator : public ModelAPI_RefAttrValidator
+//{
+// public:
+// //! returns true if attribute is valid
+// //! \param theAttribute the checked attribute
+// //! \param theArguments arguments of the attribute
+// virtual bool isValid(
+// const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const;
+// //! Returns true if object is good for the feature attribute
+// virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+// const ObjectPtr& theObject) const;
+// //! Returns true if the attribute is good for the feature attribute
+// virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+// const AttributePtr& theAttribute) const;
+//};
+// ======= end of todo
/**\class SketchPlugin_TangentAttrValidator
SketchPlugin_ConstraintCoincidence
static const std::string MY_CONSTRAINT_COINCIDENCE_ID("SketchConstraintCoincidence");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
"""
from GeomDataAPI import *
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
SketchPlugin_ConstraintDistance
static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance");
- data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
"""
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
SketchPlugin_ConstraintEqual
static const std::string MY_CONSTRAINT_EQAUL_ID("SketchConstraintEqual");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
"""
from GeomDataAPI import *
SketchPlugin_ConstraintHorizontal
static const std::string MY_CONSTRAINT_HORIZONTAL_ID("SketchConstraintHorizontal");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
"""
from GeomDataAPI import *
SketchPlugin_ConstraintLength
static const std::string MY_CONSTRAINT_LENGTH_ID("SketchConstraintLength");
- data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
"""
from GeomDataAPI import *
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
SketchPlugin_ConstraintMirror
static const std::string MY_CONSTRAINT_MIRROR_ID("SketchConstraintMirror");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefListAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefListAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefListAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefListAttr::typeId());
"""
from GeomDataAPI import *
SketchPlugin_ConstraintParallel
static const std::string MY_CONSTRAINT_PARALLEL_ID("SketchConstraintParallel");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
"""
from GeomDataAPI import *
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
SketchPlugin_ConstraintPerpendicular
static const std::string MY_CONSTRAINT_PERPENDICULAR_ID("SketchConstraintPerpendicular");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
"""
from GeomDataAPI import *
from ModelAPI import *
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
SketchPlugin_ConstraintRadius
static const std::string MY_CONSTRAINT_RADIUS_ID("SketchConstraintRadius");
- data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
"""
from GeomDataAPI import *
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
SketchPlugin_ConstraintRigid
static const std::string MY_CONSTRAINT_RIGID_ID("SketchConstraintRigid");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
"""
from GeomDataAPI import *
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
SketchPlugin_ConstraintTangent
static const std::string MY_CONSTRAINT_TANGENT_ID("SketchConstraintTangent");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
"""
from GeomDataAPI import *
SketchPlugin_ConstraintVertical
static const std::string MY_CONSTRAINT_VERTICAL_ID("SketchConstraintVertical");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
"""
from GeomDataAPI import *
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
static const std::string MY_CENTER_ID = "ArcCenter";
static const std::string MY_START_ID = "ArcStartPoint";
static const std::string MY_END_ID = "ArcEndPoint";
- data()->addAttribute(SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(SketchPlugin_Arc::START_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(SketchPlugin_Arc::END_ID(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Arc::START_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Arc::END_ID(), GeomDataAPI_Point2D::typeId());
static const std::string MY_CIRCLE_ID("SketchCircle");
static const std::string MY_CIRCLE_CENTER_ID("CircleCenter");
static const std::string MY_CIRCLE_RADIUS_ID("CircleRadius");
- data()->addAttribute(SketchPlugin_Circle::CENTER_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(SketchPlugin_Circle::RADIUS_ID(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(SketchPlugin_Circle::CENTER_ID(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Circle::RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
"""
#=========================================================================
aSession.startOperation()
#aSketchFeature = aDocument.addFeature("Sketch")
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
assert (not anCircleCentr.isInitialized())
aCircleRadius = aSketchCircle.real("CircleRadius")
assert (type(aCircleRadius) == ModelAPI_AttributeDouble)
-# ModelAPI_AttributeDouble.type() is checked in ModelAPI_TestConstants
-assert (aCircleRadius.attributeType() == ModelAPI_AttributeDouble.type())
+# ModelAPI_AttributeDouble.typeId() is checked in ModelAPI_TestConstants
+assert (aCircleRadius.attributeType() == ModelAPI_AttributeDouble.typeId())
assert (aCircleRadius.value() == 0)
anCircleCentr.setValue(-25., -25)
aCircleRadius.setValue(25.)
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
assert (aSketchFeature.getKind() == "Sketch")
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
id="ConstraintEntityB"
label="Last object"
tooltip="Select point, line end point, line, center of circle or arc."
- shape_types="edge vertex">
+ shape_types="edge vertex">
<validator id="PartSet_DifferentObjects"/>
<validator id="SketchPlugin_DistanceAttr" parameters="ConstraintEntityA"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
<validator id="GeomValidators_EdgeOrVertex"/>
</sketch_shape_selector>
+ <!--
+ TODO(nds): v1.0.2, master
+ shape_types="edge vertex">
+ <validator id="PartSet_DifferentObjects"/>
+ <validator id="SketchPlugin_DistanceAttr" parameters="ConstraintEntityA"/>
+ <selection_filter id="MultiFilter" parameters="line,vertex"/>
+ </sketch_shape_selector>
+
+ <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+ -->
<sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
</sketch_constraint_shape_selector>
+<!--
+ TODO(nds): v1.0.2, master
+ <sketch_constraint_shape_selector id="ConstraintEntityA"
+ label="First line" tooltip="Select a line" shape_types="edge">
+ <selection_filter id="EdgeFilter" parameters="line"/>
+ </sketch_constraint_shape_selector>
+
+ <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select a line"
+ shape_types="edge">
+ <selection_filter id="EdgeFilter" parameters="line"/>
+ <validator id="PartSet_DifferentObjects"/>
+ </sketch_constraint_shape_selector>
+
+ <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+-->
<validator id="PartSet_ParallelValidator"/>
</feature>
<!-- SketchConstraintPerpendicular -->
- <feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines" icon=":icons/perpendicular.png">
+ <feature id="SketchConstraintPerpendicular" title="Perpendicular"
+ tooltip="Create constraint defining two perpendicular lines"
+ icon=":icons/perpendicular.png">
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="First line" tooltip="Select an line"
shape_types="edge">
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
<validator id="GeomValidators_Edge" parameters="line"/>
</sketch_constraint_shape_selector>
+<!--
+ TODO(nds): v1.0.2, master
+ <sketch_constraint_shape_selector id="ConstraintEntityA"
+ label="First line" tooltip="Select an line"
+ shape_types="edge">
+ <selection_filter id="EdgeFilter" parameters="line"/>
+ </sketch_constraint_shape_selector>
+
+ <sketch_constraint_shape_selector id="ConstraintEntityB"
+ label="Last line" tooltip="Select an line"
+ shape_types="edge">
+ <validator id="PartSet_DifferentObjects"/>
+ <selection_filter id="EdgeFilter" parameters="line"/>
+ </sketch_constraint_shape_selector>
+-->
<validator id="PartSet_PerpendicularValidator"/>
</feature>
} else {
if (anAttrRef->attr().get() != NULL) {
const std::string aType = anAttrRef->attr()->attributeType();
- if (aType == GeomDataAPI_Point2D::type())
+ if (aType == GeomDataAPI_Point2D::typeId())
return POINT2D;
- if (aType == GeomDataAPI_Point2D::type())
+ if (aType == GeomDataAPI_Point2D::typeId())
return POINT2D;
}
}
aBaseFeature = aRC ? aRC->document()->feature(aRC) :
std::dynamic_pointer_cast<SketchPlugin_Feature>(*aBaseIter);
if (!aBaseFeature) continue;
- std::list<AttributePtr> aPoints = aBaseFeature->data()->attributes(GeomDataAPI_Point2D::type());
+ std::list<AttributePtr> aPoints = aBaseFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<AttributePtr>::iterator anIt = aPoints.begin();
for ( ; anIt != aPoints.end(); anIt++) {
// Arcs are fixed by center and start points only (to avoid solving errors in SolveSpace)
continue;
}
std::list<AttributePtr> anAttributes =
- aBaseFeature[indAttr]->data()->attributes(GeomDataAPI_Point2D::type());
+ aBaseFeature[indAttr]->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<AttributePtr>::iterator anIt = anAttributes.begin();
for ( ; anIt != anAttributes.end(); anIt++) {
// Arc should be fixed by center and start points only (to avoid "conflicting constraints" message)