]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
SketchSolver: porting to Linux (changes for independance of SketchSolver and SketchPl...
authorazv <artem.zhidkov@opencascade.com>
Thu, 22 May 2014 07:19:41 +0000 (11:19 +0400)
committerazv <artem.zhidkov@opencascade.com>
Thu, 22 May 2014 07:19:41 +0000 (11:19 +0400)
CMakeLists.txt
src/PartSet/PartSet_OperationSketchBase.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchSolver/CMakeLists.txt
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/SketchSolver/SketchSolver_ConstraintManager.h

index 05f077144bf622b2307d970cc48560bde3ab18dd..bef4cdee832db553cbc8fc76202f5bfcf6f52b3b 100644 (file)
@@ -4,8 +4,6 @@ PROJECT (NewGEOM)
 
 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeCommon" ${CMAKE_MODULE_PATH})
 
-SET(CMAKE_SHARED_LINKER_FLAGS "${SMAKE_SHARED_LINKER_FLAGS} -Wl,-E")
-
 INCLUDE(Common)
 INCLUDE(FindQt)
 INCLUDE(FindBoost)
@@ -19,6 +17,7 @@ IF(UNIX)
         MESSAGE(STATUS "Setting -std=c++0x flag for the gcc...")
         MESSAGE(STATUS "Now gcc flags are: " ${CMAKE_CXX_FLAGS})
         
+       SET(CMAKE_SHARED_LINKER_FLAGS "${SMAKE_SHARED_LINKER_FLAGS} -Wl,-E")
     ENDIF(CMAKE_COMPILER_IS_GNUCC)
 ENDIF(UNIX)
 
index 37b92f35d62b26093b8329f78f2d68b96797b8f1..f5a122f477aee6afbdef2dee90a5b19093d90c5a 100644 (file)
@@ -36,6 +36,8 @@ boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
     if (anObj) 
       aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(anObj->featureRef());
   }
+  if (!aFeature)
+    return boost::shared_ptr<GeomAPI_Shape>();
   return aFeature->preview();
 }
 
index 8c2796b0d1ae77023523575e6ab81df11c5141e5..60fb882c0c186e5f45047274c60be0088e2799d4 100644 (file)
@@ -23,11 +23,12 @@ SET(PROJECT_SOURCES
 SET(PROJECT_LIBRARIES
     GeomAPI
     GeomAlgoAPI
+    ModelAPI
 )
 
 ADD_DEFINITIONS(-DSKETCHPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
 ADD_LIBRARY(SketchPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI)
+TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
   ../ModelAPI
index 20cd14b872f42d7f21fc3b0558616427018e3405..4656f25d530a1f00f4ed054757ab26a3d4c36f63 100644 (file)
@@ -15,6 +15,8 @@ SET(PROJECT_SOURCES
 SET(PROJECT_LIBRARIES
     ${SLVS_LIBRARIES}
     Events
+    ModelAPI
+    Model
 )
 
 INCLUDE_DIRECTORIES(
index bf9ad5e101ab3fb092cb81a3ab9246f0ce64ab79..c83e865b8a9b19f79a4d33e24f8f7d22fd35d5e6 100644 (file)
@@ -19,6 +19,7 @@
 #include <SketchPlugin_Sketch.h>
 
 #include <math.h>
+#include <assert.h>
 
 /// Tolerance for value of parameters
 const double tolerance = 1.e-10;
@@ -26,7 +27,7 @@ const double tolerance = 1.e-10;
 // Initialization of constraint manager self pointer
 SketchSolver_ConstraintManager* SketchSolver_ConstraintManager::_self = 0;
 
-/// Global constaint manager object
+/// Global constraint manager object
 SketchSolver_ConstraintManager* myManager = SketchSolver_ConstraintManager::Instance();
 
 /// This value is used to give unique index to the groups
@@ -60,6 +61,7 @@ SketchSolver_ConstraintManager::SketchSolver_ConstraintManager()
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURES_MOVED));
 }
 
 SketchSolver_ConstraintManager::~SketchSolver_ConstraintManager()
@@ -75,34 +77,29 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
     const Model_FeatureUpdatedMessage* aUpdateMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
 
     // Only sketches and constraints can be added by Create event
-    boost::shared_ptr<SketchPlugin_Sketch> aSketch = 
-      boost::dynamic_pointer_cast<SketchPlugin_Sketch>(aUpdateMsg->feature());
-    if (aSketch)
+    const std::string& aFeatureKind = aUpdateMsg->feature()->getKind();
+    if (aFeatureKind.compare("Sketch") == 0)
     {
+      boost::shared_ptr<SketchPlugin_Feature> aSketch =
+        boost::dynamic_pointer_cast<SketchPlugin_Feature>(aUpdateMsg->feature());
       changeWorkplane(aSketch);
       return ;
     }
-    boost::shared_ptr<SketchPlugin_Constraint> aConstraint = 
+    boost::shared_ptr<SketchPlugin_Constraint> aConstraint =
       boost::dynamic_pointer_cast<SketchPlugin_Constraint>(aUpdateMsg->feature());
     if (aConstraint)
-    {
       changeConstraint(aConstraint);
-
-      // Solve the set of constraints
-      resolveConstraints();
-      return ;
-    }
-
-    // Sketch plugin features only can be updated
-    boost::shared_ptr<SketchPlugin_Feature> aFeature = 
-      boost::dynamic_pointer_cast<SketchPlugin_Feature>(aUpdateMsg->feature());
-    if (aFeature)
+    else
     {
-      updateEntity(aFeature);
-
-      // Solve the set of constraints
-      resolveConstraints();
+      // Sketch plugin features can be only updated
+      boost::shared_ptr<SketchPlugin_Feature> aFeature =
+        boost::dynamic_pointer_cast<SketchPlugin_Feature>(aUpdateMsg->feature());
+      if (aFeature)
+        updateEntity(aFeature);
     }
+
+    // Solve the set of constraints
+    resolveConstraints();
   }
   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED))
   {
@@ -126,7 +123,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
   }
 }
 
-bool SketchSolver_ConstraintManager::changeWorkplane(boost::shared_ptr<SketchPlugin_Sketch> theSketch)
+bool SketchSolver_ConstraintManager::changeWorkplane(boost::shared_ptr<SketchPlugin_Feature> theSketch)
 {
   bool aResult = true; // changed when a workplane wrongly updated
   bool isUpdated = false;
@@ -164,7 +161,7 @@ bool SketchSolver_ConstraintManager::changeConstraint(
   // Process the groups list
   if (aGroups.size() == 0)
   { // There are no groups applicable for this constraint => create new one
-    boost::shared_ptr<SketchPlugin_Sketch> aWP = findWorkplaneForConstraint(theConstraint);
+    boost::shared_ptr<SketchPlugin_Feature> aWP = findWorkplaneForConstraint(theConstraint);
     if (!aWP) return false;
     SketchSolver_ConstraintGroup* aGroup = new SketchSolver_ConstraintGroup(aWP);
     if (!aGroup->changeConstraint(theConstraint))
@@ -196,15 +193,12 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr<SketchPlugin
 {
   // Create list of attributes depending on type of the feature
   std::vector<std::string> anAttrList;
+  const std::string& aFeatureKind = theFeature->getKind();
   // Point
-  boost::shared_ptr<SketchPlugin_Point> aPoint = 
-    boost::dynamic_pointer_cast<SketchPlugin_Point>(theFeature);
-  if (aPoint)
+  if (aFeatureKind.compare("SketchPoint") == 0)
     anAttrList.push_back(POINT_ATTR_COORD);
   // Line
-  boost::shared_ptr<SketchPlugin_Line> aLine = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(theFeature);
-  if (aLine)
+  else if (aFeatureKind.compare("SketchLine") == 0)
   {
     anAttrList.push_back(LINE_ATTR_START);
     anAttrList.push_back(LINE_ATTR_END);
@@ -218,7 +212,7 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr<SketchPlugin
     std::vector<SketchSolver_ConstraintGroup*>::iterator aGroupIter;
     for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
     {
-      boost::shared_ptr<ModelAPI_Attribute> anAttribute = 
+      boost::shared_ptr<ModelAPI_Attribute> anAttribute =
         boost::dynamic_pointer_cast<ModelAPI_Attribute>(theFeature->data()->attribute(*anAttrIter));
       (*aGroupIter)->updateEntityIfPossible(anAttribute);
     }
@@ -227,10 +221,10 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr<SketchPlugin
 
 
 void SketchSolver_ConstraintManager::findGroups(
-              boost::shared_ptr<SketchPlugin_Constraint> theConstraint, 
+              boost::shared_ptr<SketchPlugin_Constraint> theConstraint,
               std::vector<Slvs_hGroup>&                  theGroupIDs) const
 {
-  boost::shared_ptr<SketchPlugin_Sketch> aWP = findWorkplaneForConstraint(theConstraint);
+  boost::shared_ptr<SketchPlugin_Feature> aWP = findWorkplaneForConstraint(theConstraint);
 
   std::vector<SketchSolver_ConstraintGroup*>::const_iterator aGroupIter;
   for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
@@ -238,14 +232,14 @@ void SketchSolver_ConstraintManager::findGroups(
       theGroupIDs.push_back((*aGroupIter)->getId());
 }
 
-boost::shared_ptr<SketchPlugin_Sketch> SketchSolver_ConstraintManager::findWorkplaneForConstraint(
+boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWorkplaneForConstraint(
               boost::shared_ptr<SketchPlugin_Constraint> theConstraint) const
 {
   std::vector<SketchSolver_ConstraintGroup*>::const_iterator aGroupIter;
   for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
   {
-    boost::shared_ptr<SketchPlugin_Sketch> aWP = (*aGroupIter)->getWorkplane();
-    boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures = 
+    boost::shared_ptr<SketchPlugin_Feature> aWP = (*aGroupIter)->getWorkplane();
+    boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SKETCH_ATTR_FEATURES));
     std::list< boost::shared_ptr<ModelAPI_Feature> > aFeaturesList = aWPFeatures->list();
     std::list< boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIter;
@@ -254,12 +248,12 @@ boost::shared_ptr<SketchPlugin_Sketch> SketchSolver_ConstraintManager::findWorkp
         return aWP; // workplane is found
   }
 
-  return boost::shared_ptr<SketchPlugin_Sketch>();
+  return boost::shared_ptr<SketchPlugin_Feature>();
 }
 
 void SketchSolver_ConstraintManager::resolveConstraints()
 {
-  std::vector<SketchSolver_ConstraintGroup*>::iterator aGroupIter; 
+  std::vector<SketchSolver_ConstraintGroup*>::iterator aGroupIter;
   for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
     (*aGroupIter)->resolveConstraints();
 }
@@ -271,7 +265,7 @@ void SketchSolver_ConstraintManager::resolveConstraints()
 // ========================================================
 
 SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::
-  SketchSolver_ConstraintGroup(boost::shared_ptr<SketchPlugin_Sketch> theWorkplane)
+  SketchSolver_ConstraintGroup(boost::shared_ptr<SketchPlugin_Feature> theWorkplane)
   : myID(++myGroupIndexer),
     myParamMaxID(0),
     myEntityMaxID(0),
@@ -286,7 +280,7 @@ SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::
 
   // Initialize workplane
   myWorkplane.h = SLVS_E_UNKNOWN;
-  addWorkplane(theWorkplane);
+  assert(addWorkplane(theWorkplane));
 }
 
 SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::~SketchSolver_ConstraintGroup()
@@ -302,7 +296,7 @@ SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::~SketchSolver_Cons
 }
 
 bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::isBaseWorkplane(
-                boost::shared_ptr<SketchPlugin_Sketch> theWorkplane) const
+                boost::shared_ptr<SketchPlugin_Feature> theWorkplane) const
 {
   return theWorkplane == mySketch;
 }
@@ -337,7 +331,7 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::changeConstra
 
   // Get constraint type and verify the constraint parameters are correct
   int aConstrType = getConstraintType(theConstraint);
-  if (aConstrType == SLVS_C_UNKNOWN || 
+  if (aConstrType == SLVS_C_UNKNOWN ||
      (aConstrMapIter != myConstraintMap.end() && aConstrIter->type != aConstrType))
     return false;
 
@@ -359,7 +353,7 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::changeConstra
   for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
   {
     aConstrEnt[indAttr] = SLVS_E_UNKNOWN;
-    boost::shared_ptr<ModelAPI_AttributeRefAttr> aConstrAttr = 
+    boost::shared_ptr<ModelAPI_AttributeRefAttr> aConstrAttr =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
         theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
       );
@@ -370,8 +364,8 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::changeConstra
   if (aConstrMapIter == myConstraintMap.end())
   {
     // Create SolveSpace constraint structure
-    Slvs_Constraint aConstraint = 
-      Slvs_MakeConstraint(++myConstrMaxID, myID, aConstrType, myWorkplane.h, 
+    Slvs_Constraint aConstraint =
+      Slvs_MakeConstraint(++myConstrMaxID, myID, aConstrType, myWorkplane.h,
                           aDistance, aConstrEnt[0], aConstrEnt[1], aConstrEnt[2], aConstrEnt[3]);
     myConstraints.push_back(aConstraint);
     myConstraintMap[theConstraint] = aConstraint.h;
@@ -398,7 +392,7 @@ Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::chang
   // Look over supported types of entities
 
   // Point in 3D
-  boost::shared_ptr<GeomDataAPI_Point> aPoint = 
+  boost::shared_ptr<GeomDataAPI_Point> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point>(theEntity);
   if (aPoint)
   {
@@ -417,7 +411,7 @@ Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::chang
   }
 
   // Point in 2D
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D = 
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theEntity);
   if (aPoint2D)
   {
@@ -438,29 +432,29 @@ Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::chang
   }
 
   /// \todo Other types of entities
-  
+
   // Unsupported or wrong entity type
   return SLVS_E_UNKNOWN;
 }
 
 Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::changeNormal(
-                boost::shared_ptr<ModelAPI_Attribute> theDirX, 
-                boost::shared_ptr<ModelAPI_Attribute> theDirY, 
+                boost::shared_ptr<ModelAPI_Attribute> theDirX,
+                boost::shared_ptr<ModelAPI_Attribute> theDirY,
                 boost::shared_ptr<ModelAPI_Attribute> theNorm)
 {
-  boost::shared_ptr<GeomDataAPI_Dir> aDirX = 
+  boost::shared_ptr<GeomDataAPI_Dir> aDirX =
     boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theDirX);
-  boost::shared_ptr<GeomDataAPI_Dir> aDirY = 
+  boost::shared_ptr<GeomDataAPI_Dir> aDirY =
     boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theDirY);
-  if (!aDirX || !aDirY || 
+  if (!aDirX || !aDirY ||
      (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) ||
      (fabs(aDirY->x()) + fabs(aDirY->y()) + fabs(aDirY->z()) < tolerance))
     return SLVS_E_UNKNOWN;
 
   // quaternion parameters of normal vector
   double qw, qx, qy, qz;
-  Slvs_MakeQuaternion(aDirX->x(), aDirX->y(), aDirX->z(), 
-                      aDirY->x(), aDirY->y(), aDirY->z(), 
+  Slvs_MakeQuaternion(aDirX->x(), aDirX->y(), aDirX->z(),
+                      aDirY->x(), aDirY->y(), aDirY->z(),
                       &qw, &qx, &qy, &qz);
   double aNormCoord[4] = {qw, qx, qy, qz};
 
@@ -486,7 +480,7 @@ Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::chang
     return aEntIter->second;
 
   // Create a normal
-  Slvs_Entity aNormal = Slvs_MakeNormal3d(++myEntityMaxID, myID, 
+  Slvs_Entity aNormal = Slvs_MakeNormal3d(++myEntityMaxID, myID,
                 aNormParams[0], aNormParams[1], aNormParams[2], aNormParams[3]);
   myEntities.push_back(aNormal);
   myEntityMap[theNorm] = aNormal.h;
@@ -495,13 +489,14 @@ Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::chang
 
 
 bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::addWorkplane(
-                boost::shared_ptr<SketchPlugin_Sketch> theSketch)
+                boost::shared_ptr<SketchPlugin_Feature> theSketch)
 {
-  if (myWorkplane.h)
-    return false; // the workplane already exists
+  if (myWorkplane.h || theSketch->getKind().compare("Sketch") != 0)
+    return false; // the workplane already exists or the function parameter is not Sketch
 
   mySketch = theSketch;
-  return updateWorkplane();
+  updateWorkplane();
+  return true;
 }
 
 bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateWorkplane()
@@ -529,7 +524,7 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateWorkpla
 
 
 Slvs_hParam SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::changeParameter(
-                const double&                            theParam, 
+                const double&                            theParam,
                 std::vector<Slvs_Param>::const_iterator& thePrmIter)
 {
   if (thePrmIter != myParams.end())
@@ -556,23 +551,22 @@ Slvs_hParam SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::change
 int SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::getConstraintType(
                 const boost::shared_ptr<SketchPlugin_Constraint>& theConstraint) const
 {
+  const std::string& aConstraintKind = theConstraint->getKind();
   // Constraint for coincidence of two points
-  boost::shared_ptr<SketchPlugin_ConstraintCoincidence> aPtEquiv = 
-    boost::dynamic_pointer_cast<SketchPlugin_ConstraintCoincidence>(theConstraint);
-  if (aPtEquiv)
+  if (aConstraintKind.compare("SketchConstraintCoincidence") == 0)
   {
     // Verify the constraint has only two attributes and they are points
-    int aPt2d = 0; // bit-mapped field, each bit indicates whether the attribute is 2D point 
+    int aPt2d = 0; // bit-mapped field, each bit indicates whether the attribute is 2D point
     int aPt3d = 0; // bit-mapped field, the same information for 3D points
     for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
     {
-      boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+      boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
           theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
         );
       if (!anAttr) continue;
       // Verify the attribute is a 2D point
-      boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D = 
+      boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
       if (aPoint2D)
       {
@@ -580,7 +574,7 @@ int SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::getConstraintT
         continue;
       }
       // Verify the attribute is a 3D point
-      boost::shared_ptr<GeomDataAPI_Point> aPoint3D = 
+      boost::shared_ptr<GeomDataAPI_Point> aPoint3D =
         boost::dynamic_pointer_cast<GeomDataAPI_Point>(anAttr->attr());
       if (aPoint3D)
       {
@@ -658,7 +652,7 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateGroup()
     if (aConstrPos < (int)myConstraints.size())
     {
       Slvs_hEntity aConstrEnt[] = {
-        myConstraints[aConstrPos].ptA,     myConstraints[aConstrPos].ptB, 
+        myConstraints[aConstrPos].ptA,     myConstraints[aConstrPos].ptB,
         myConstraints[aConstrPos].entityA, myConstraints[aConstrPos].entityB};
       for (int i = 0; i < 4; i++)
         if (aConstrEnt[i] != SLVS_E_UNKNOWN)
@@ -697,7 +691,7 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateGroup()
         myParamMaxID -= aNbParams;
       // Remove parameters of the entity
       int aParamPos = Search(aEntIter->param[0], myParams);
-      myParams.erase(myParams.begin() + aParamPos, 
+      myParams.erase(myParams.begin() + aParamPos,
                      myParams.begin() + aParamPos + aNbParams);
 
       // Remove entity
@@ -718,7 +712,7 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateGroup()
 }
 
 void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateAttribute(
-                boost::shared_ptr<ModelAPI_Attribute> theAttribute, 
+                boost::shared_ptr<ModelAPI_Attribute> theAttribute,
                 const Slvs_hEntity&                   theEntityID)
 {
   // Search the position of the first parameter of the entity
@@ -728,7 +722,7 @@ void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateAttribu
   // Look over supported types of entities
 
   // Point in 3D
-  boost::shared_ptr<GeomDataAPI_Point> aPoint = 
+  boost::shared_ptr<GeomDataAPI_Point> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point>(theAttribute);
   if (aPoint)
   {
@@ -739,7 +733,7 @@ void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateAttribu
   }
 
   // Point in 2D
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D = 
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theAttribute);
   if (aPoint2D)
   {
@@ -756,9 +750,9 @@ void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateEntityI
 {
   if (myEntityMap.find(theEntity) != myEntityMap.end())
   {
-    // If the attribute is a point and it is changed (the group needs to rebuild), 
-    // probably user has dragged this point into this position, 
-    // so it is necessary to add constraint which will quarantee the point will not change
+    // If the attribute is a point and it is changed (the group needs to rebuild),
+    // probably user has dragged this point into this position,
+    // so it is necessary to add constraint which will guarantee the point will not change
 
     // Store myNeedToSolve flag to verify the entity is really changed
     bool aNeedToSolveCopy = myNeedToSolve;
@@ -769,9 +763,9 @@ void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateEntityI
     if (myNeedToSolve) // the entity is changed
     {
       // Verify the entity is a point and add temporary constraint of permanency
-      boost::shared_ptr<GeomDataAPI_Point> aPoint = 
+      boost::shared_ptr<GeomDataAPI_Point> aPoint =
         boost::dynamic_pointer_cast<GeomDataAPI_Point>(theEntity);
-      boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D = 
+      boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theEntity);
       if (aPoint || aPoint2D)
         addTemporaryConstraintWhereDragged(theEntity);
@@ -790,7 +784,7 @@ void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::addTemporaryC
     anEntIter = myEntityMap.find(theEntity);
 
   // Create WHERE_DRAGGED constraint
-  Slvs_Constraint aWDConstr = Slvs_MakeConstraint(++myConstrMaxID, myID, SLVS_C_WHERE_DRAGGED, 
+  Slvs_Constraint aWDConstr = Slvs_MakeConstraint(++myConstrMaxID, myID, SLVS_C_WHERE_DRAGGED,
                                                   myWorkplane.h, 0.0, anEntIter->second, 0, 0, 0);
   myConstraints.push_back(aWDConstr);
   myTempConstraints.push_back(aWDConstr.h);
index b96b6ea19fc85a40489da0781472fc0d4060db0e..9cbb23bab85a60b03f8b6758f3e2e070ca1d06a1 100644 (file)
@@ -26,7 +26,7 @@
 
 /** \class   SketchSolver_ConstraintManager
  *  \ingroup DataModel
- *  \brief   Listens the changes of SketchPlugin features and transforms the Constraint 
+ *  \brief   Listens the changes of SketchPlugin features and transforms the Constraint
  *           feature into the format understandable by SolveSpace library.
  *
  *  Constraints created for SolveSpace library are divided into the groups.
@@ -66,11 +66,12 @@ protected:
 
   /** \brief Adds or updates a workplane in the manager
    *  \param[in] theSketch the feature to create or update workplane
-   *  \return \c true if the workplane cahnged successfully
+   *  \return \c true if the workplane changed successfully
+   *  \remark Type of theSketch is not verified inside
    */
-  bool changeWorkplane(boost::shared_ptr<SketchPlugin_Sketch> theSketch);
+  bool changeWorkplane(boost::shared_ptr<SketchPlugin_Feature> theSketch);
 
-  /** \brief Removes a workplane from the manager. 
+  /** \brief Removes a workplane from the manager.
    *         All groups based on such workplane will be removed too.
    *  \param[in] theSketch the feature to be removed
    *  \return \c true if the workplane removed successfully
@@ -93,14 +94,14 @@ private:
    *  \param[in]  theConstraint constraint to be found
    *  \param[out] theGroups     list of group indexes interacted with constraint
    */
-  void findGroups(boost::shared_ptr<SketchPlugin_Constraint> theConstraint, 
+  void findGroups(boost::shared_ptr<SketchPlugin_Constraint> theConstraint,
                   std::vector<Slvs_hGroup>&                  theGroupIDs) const;
 
   /** \brief Searches in the list of groups the workplane which constains specified constraint
    *  \param[in] theConstraint constraint to be found
-   *  \return workplane contains the constraint
+   *  \return workplane containing the constraint
    */
-  boost::shared_ptr<SketchPlugin_Sketch> findWorkplaneForConstraint(
+  boost::shared_ptr<SketchPlugin_Feature> findWorkplaneForConstraint(
                   boost::shared_ptr<SketchPlugin_Constraint> theConstraint) const;
 
 private:
@@ -116,9 +117,11 @@ private:
 class SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup
 {
 public:
-  /** \brief New group based on specified workplane
+  /** \brief New group based on specified workplane.
+   *         Throws an exception if theWorkplane is not an object of SketchPlugin_Sketch type
+   *  \remark Type of theSketch is not verified inside
    */
-  SketchSolver_ConstraintGroup(boost::shared_ptr<SketchPlugin_Sketch> theWorkplane);
+  SketchSolver_ConstraintGroup(boost::shared_ptr<SketchPlugin_Feature> theWorkplane);
 
   ~SketchSolver_ConstraintGroup();
 
@@ -138,13 +141,13 @@ public:
    */
   bool isInteract(boost::shared_ptr<SketchPlugin_Constraint> theConstraint) const;
 
-  /** \brief Verifies the specified workplane is the same as a base workplane for this group
-   *  \param[in] theWorkplane workplane to be compared
+  /** \brief Verifies the specified feature is equal to the base workplane for this group
+   *  \param[in] theWorkplane the feature to be compared with base workplane
    *  \return \c true if workplanes are the same
    */
-  bool isBaseWorkplane(boost::shared_ptr<SketchPlugin_Sketch> theWorkplane) const;
+  bool isBaseWorkplane(boost::shared_ptr<SketchPlugin_Feature> theWorkplane) const;
 
-  boost::shared_ptr<SketchPlugin_Sketch> getWorkplane() const
+  boost::shared_ptr<SketchPlugin_Feature> getWorkplane() const
   { return mySketch; }
 
   /** \brief Update parameters of workplane. Should be called when Update event is coming.
@@ -179,10 +182,10 @@ protected:
 
   /** \brief Adds or updates a normal in the group
    *
-   *  Normal is a special entity in SolveSpace, which defines a direction in 3D and 
+   *  Normal is a special entity in SolveSpace, which defines a direction in 3D and
    *  a rotation about this direction. So, SolveSpace represents normals as unit quaternions.
    *
-   *  To define a normal there should be specified two coordinate axis 
+   *  To define a normal there should be specified two coordinate axis
    *  on the plane transversed to created normal.
    *
    *  \param[in] theDirX first coordinate axis of the plane
@@ -190,17 +193,17 @@ protected:
    *  \param[in] theNorm attribute for the normal (used to identify newly created entity)
    *  \return identifier of created or updated normal
    */
-  Slvs_hEntity changeNormal(boost::shared_ptr<ModelAPI_Attribute> theDirX, 
-                            boost::shared_ptr<ModelAPI_Attribute> theDirY, 
+  Slvs_hEntity changeNormal(boost::shared_ptr<ModelAPI_Attribute> theDirX,
+                            boost::shared_ptr<ModelAPI_Attribute> theDirY,
                             boost::shared_ptr<ModelAPI_Attribute> theNorm);
 
   /** \brief Adds or updates a parameter in the group
    *  \param[in] theParam   the value of parameter
-   *  \param[in] thePrmIter the cell in the list of parameters which should be changed 
+   *  \param[in] thePrmIter the cell in the list of parameters which should be changed
    *                        (the iterator will be increased if it does not reach the end of the list)
    *  \return identifier of changed parameter; when the parameter cannot be created, returned ID is 0
    */
-  Slvs_hParam changeParameter(const double& theParam, 
+  Slvs_hParam changeParameter(const double& theParam,
                               std::vector<Slvs_Param>::const_iterator& thePrmIter);
 
   /** \brief Compute constraint type according to SolveSpace identifiers
@@ -230,7 +233,7 @@ private:
    *  \param[in] theSketch parameters of workplane are the attributes of this sketch
    *  \return \c true if success, \c false if workplane parameters are not consistent
    */
-  bool addWorkplane(boost::shared_ptr<SketchPlugin_Sketch> theSketch);
+  bool addWorkplane(boost::shared_ptr<SketchPlugin_Feature> theSketch);
 
 private:
   // SolveSpace entities
@@ -247,12 +250,12 @@ private:
   SketchSolver_Solver          myConstrSolver;  ///< Solver for set of equations obtained by constraints
 
   // SketchPlugin entities
-  boost::shared_ptr<SketchPlugin_Sketch> mySketch; ///< Equivalent to workplane
-  std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint> 
-                                myConstraintMap;   ///< The map between SketchPlugin and SolveSpace constraints
-  std::list<Slvs_hConstraint> myTempConstraints;   ///< The list of identifiers of temporary constraints
+  boost::shared_ptr<SketchPlugin_Feature> mySketch; ///< Equivalent to workplane
+  std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>
+                                myConstraintMap;    ///< The map between SketchPlugin and SolveSpace constraints
+  std::list<Slvs_hConstraint> myTempConstraints;    ///< The list of identifiers of temporary constraints
   std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>
-                                myEntityMap;       ///< The map between parameters of constraints and their equivalent SolveSpace entities
+                                myEntityMap;        ///< The map between parameters of constraints and their equivalent SolveSpace entities
 };
 
 #endif