]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix compilation error on Linux. Part III.
authorazv <azv@opencascade.com>
Tue, 15 Dec 2015 07:20:16 +0000 (10:20 +0300)
committerazv <azv@opencascade.com>
Tue, 15 Dec 2015 07:20:16 +0000 (10:20 +0300)
src/SketchSolver/SketchSolver_ConstraintFixed.cpp
src/SketchSolver/SketchSolver_ConstraintMirror.cpp
src/SketchSolver/SketchSolver_ConstraintParametric.cpp [deleted file]
src/SketchSolver/SketchSolver_ConstraintParametric.h [deleted file]

index eed87a344ba86a4e06ec8af6207d5c6b458ab944..3e7a9f9db63d9af0cde9bbe777846a61392a7517 100644 (file)
@@ -119,15 +119,16 @@ void SketchSolver_ConstraintFixed::getAttributes(
   } else if (myBaseConstraint) {
     // Constraint Fixed is added by user.
     // Get the attribute of constraint (it should be alone in the list of constraints).
-    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-        myBaseConstraint->attribute(SketchPlugin_ConstraintRigid::ENTITY_A()));
+    AttributePtr anAttr = myBaseConstraint->attribute(SketchPlugin_ConstraintRigid::ENTITY_A());
+    AttributeRefAttrPtr aRefAttr =
+        std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttr);
     if (!aRefAttr || !aRefAttr->isInitialized()) {
       myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();
       return;
     }
 
-    myStorage->update(aRefAttr, myGroupID);
-    aSolverEntity = myStorage->entity(aRefAttr);
+    myStorage->update(anAttr, myGroupID);
+    aSolverEntity = myStorage->entity(anAttr);
   } else
     myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();
 
index 12b009f6f9e0fe68ee5794367d21d99ccd9186b9..be15c46a0970b0f1a73e091a11db56fa72acf99c 100644 (file)
@@ -17,9 +17,10 @@ void SketchSolver_ConstraintMirror::getAttributes(
     std::vector<EntityWrapperPtr>& theBaseEntities,
     std::vector<EntityWrapperPtr>& theMirrorEntities)
 {
-  AttributeRefAttrPtr aMirLineAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-      myBaseConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  if (!aMirLineAttr || !aMirLineAttr->isInitialized() || !aMirLineAttr->isObject()) {
+  AttributePtr aMirLineAttr = myBaseConstraint->attribute(SketchPlugin_Constraint::ENTITY_A());
+  AttributeRefAttrPtr aMirLineRefAttr =
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aMirLineAttr);
+  if (!aMirLineRefAttr || !aMirLineRefAttr->isInitialized() || !aMirLineRefAttr->isObject()) {
     myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();
     return;
   }
diff --git a/src/SketchSolver/SketchSolver_ConstraintParametric.cpp b/src/SketchSolver/SketchSolver_ConstraintParametric.cpp
deleted file mode 100644 (file)
index bd533ce..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-#include <SketchSolver_ConstraintParametric.h>
-#include <SketchSolver_Error.h>
-#include <SketchSolver_Group.h>
-
-#include <GeomDataAPI_Point2D.h>
-
-SketchSolver_ConstraintParametric::SketchSolver_ConstraintParametric(AttributePtr theAttribute)
-  : SketchSolver_ConstraintRigid(ConstraintPtr()),
-    myBaseAttribute(theAttribute)
-{
-  process();
-}
-
-void SketchSolver_ConstraintParametric::process()
-{
-  cleanErrorMsg();
-  if (!myBaseAttribute || !myStorage || myGroup == 0) {
-    /// TODO: Put error message here
-    return;
-  }
-  if (!mySlvsConstraints.empty()) // some data is changed, update constraint
-    update(myBaseConstraint);
-
-  Slvs_hEntity anAttrID;
-  getAttributes(anAttrID);
-  if (!myErrorMsg.empty() || (myFeatureMap.empty() && myAttributeMap.empty()))
-    return;
-
-  myHorizLineID = SLVS_E_UNKNOWN;
-  myVertLineID = SLVS_E_UNKNOWN;
-
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(myBaseAttribute);
-  if (!aPoint)
-    return;
-  if (!aPoint->textX().empty()) {
-    // Create vertical line with fixed boundary point
-    Slvs_Entity aLine = createLine(aPoint->x(), -100.0, aPoint->x(), 100.0);
-    // Place point on line
-    Slvs_Constraint aConstraint = Slvs_MakeConstraint(SLVS_C_UNKNOWN, myGroup->getId(),
-        SLVS_C_PT_ON_LINE, myGroup->getWorkplaneId(), 0.0, anAttrID, SLVS_E_UNKNOWN,
-        aLine.h, SLVS_E_UNKNOWN);
-    aConstraint.h = myStorage->addConstraint(aConstraint);
-    mySlvsConstraints.push_back(aConstraint.h);
-    myVertLineID = aLine.h;
-    myX = aPoint->x();
-  }
-  if (!aPoint->textY().empty()) {
-    // Create horizontal line with fixed boundary points
-    Slvs_Entity aLine = createLine(-100.0, aPoint->y(), 100.0, aPoint->y());
-    // Place point on line
-    Slvs_Constraint aConstraint = Slvs_MakeConstraint(SLVS_C_UNKNOWN, myGroup->getId(),
-        SLVS_C_PT_ON_LINE, myGroup->getWorkplaneId(), 0.0, anAttrID, SLVS_E_UNKNOWN,
-        aLine.h, SLVS_E_UNKNOWN);
-    aConstraint.h = myStorage->addConstraint(aConstraint);
-    mySlvsConstraints.push_back(aConstraint.h);
-    myHorizLineID = aLine.h;
-    myY = aPoint->y();
-  }
-}
-
-
-void SketchSolver_ConstraintParametric::getAttributes(Slvs_hEntity& theAttributeID)
-{
-  int aType = SLVS_E_UNKNOWN; // type of created entity
-  theAttributeID = SLVS_E_UNKNOWN;
-  theAttributeID = myGroup->getAttributeId(myBaseAttribute);
-  if (theAttributeID == SLVS_E_UNKNOWN) {
-    theAttributeID = changeEntity(myBaseAttribute, aType);
-    if (theAttributeID == SLVS_E_UNKNOWN) {
-      myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();
-      return;
-    }
-  }
-  else
-     myAttributeMap[myBaseAttribute] = theAttributeID;
-}
-
-
-void SketchSolver_ConstraintParametric::update(ConstraintPtr theConstraint)
-{
-  cleanErrorMsg();
-  if (!theConstraint || theConstraint == myBaseConstraint) {
-    std::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(myBaseAttribute);
-    if (aPoint && ((!aPoint->textX().empty() && myVertLineID == SLVS_E_UNKNOWN) || 
-        (!aPoint->textY().empty() && myHorizLineID == SLVS_E_UNKNOWN))) {
-      remove();
-      process();
-      return;
-    }
-  }
-  adjustConstraint();
-}
-
-void SketchSolver_ConstraintParametric::refresh()
-{
-  Slvs_hEntity aBasePointID = myAttributeMap[myBaseAttribute];
-  const Slvs_Entity& aBasePoint = myStorage->getEntity(aBasePointID);
-  double aXY[2];
-  aXY[0] = myVertLineID  != SLVS_E_UNKNOWN ? myX : myStorage->getParameter(aBasePoint.param[0]).val;
-  aXY[1] = myHorizLineID != SLVS_E_UNKNOWN ? myY : myStorage->getParameter(aBasePoint.param[1]).val;
-
-  std::list<Slvs_Constraint> aCoincidence = myStorage->getConstraintsByType(SLVS_C_POINTS_COINCIDENT);
-  std::list<Slvs_Constraint>::const_iterator aCIt = aCoincidence.begin();
-  for (; aCIt != aCoincidence.end(); ++aCIt) {
-    if (aCIt->ptA != aBasePointID && aCIt->ptB != aBasePointID)
-      continue;
-    Slvs_hEntity anOtherPointID = aCIt->ptA == aBasePointID ? aCIt->ptB : aCIt->ptA;
-    const Slvs_Entity& aPoint = myStorage->getEntity(anOtherPointID);
-    for (int i = 0; i < 2; i++) {
-      Slvs_Param aParam = myStorage->getParameter(aPoint.param[i]);
-      aParam.val = aXY[i];
-      myStorage->updateParameter(aParam);
-    }
-  }
-}
-
-void SketchSolver_ConstraintParametric::adjustConstraint()
-{
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(myBaseAttribute);
-  if (!aPoint)
-    return;
-
-  if (!aPoint->textX().empty()) {
-    const Slvs_Entity& aLine = myStorage->getEntity(myVertLineID);
-    const Slvs_Entity& aStartPoint = myStorage->getEntity(aLine.point[0]);
-    Slvs_Param aParX = myStorage->getParameter(aStartPoint.param[0]);
-    aParX.val = aPoint->x();
-    myStorage->updateParameter(aParX);
-    myX = aParX.val;
-  }
-  if (!aPoint->textY().empty()) {
-    const Slvs_Entity& aLine = myStorage->getEntity(myHorizLineID);
-    const Slvs_Entity& aStartPoint = myStorage->getEntity(aLine.point[0]);
-    Slvs_Param aParY = myStorage->getParameter(aStartPoint.param[1]);
-    aParY.val = aPoint->y();
-    myStorage->updateParameter(aParY);
-    myY = aParY.val;
-  }
-}
-
-
-Slvs_Entity SketchSolver_ConstraintParametric::createLine(
-    double theStartX, double theStartY, double theEndX, double theEndY)
-{
-  // Start point
-  Slvs_Param aParX = Slvs_MakeParam(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP, theStartX);
-  Slvs_Param aParY = Slvs_MakeParam(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP, theStartY);
-  aParX.h = myStorage->addParameter(aParX);
-  aParY.h = myStorage->addParameter(aParY);
-  Slvs_Entity aStartPoint = Slvs_MakePoint2d(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP,
-    myGroup->getWorkplaneId(), aParX.h, aParY.h);
-  aStartPoint.h = myStorage->addEntity(aStartPoint);
-
-  // End point
-  aParX = Slvs_MakeParam(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP, theEndX);
-  aParY = Slvs_MakeParam(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP, theEndY);
-  aParX.h = myStorage->addParameter(aParX);
-  aParY.h = myStorage->addParameter(aParY);
-  Slvs_Entity aEndPoint = Slvs_MakePoint2d(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP,
-    myGroup->getWorkplaneId(), aParX.h, aParY.h);
-  aEndPoint.h = myStorage->addEntity(aEndPoint);
-
-  // Line
-  Slvs_Entity aLine = Slvs_MakeLineSegment(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP,
-    myGroup->getWorkplaneId(), aStartPoint.h, aEndPoint.h);
-  aLine.h = myStorage->addEntity(aLine);
-  return aLine;
-}
diff --git a/src/SketchSolver/SketchSolver_ConstraintParametric.h b/src/SketchSolver/SketchSolver_ConstraintParametric.h
deleted file mode 100644 (file)
index 3a25d96..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:    SketchSolver_ConstraintParametric.h
-// Created: 15 Jun 2015
-// Author:  Artem ZHIDKOV
-
-#ifndef SketchSolver_ConstraintParametric_H_
-#define SketchSolver_ConstraintParametric_H_
-
-#include "SketchSolver.h"
-#include <SketchSolver_ConstraintRigid.h>
-
-/** \class   SketchSolver_ConstraintParametric
- *  \ingroup Plugins
- *  \brief   Stores data of Rigid (Fixed) constraint for the attribute
- *           which coordinates are given by parametric expression
- */
-class SketchSolver_ConstraintParametric : public SketchSolver_ConstraintRigid
-{
-private:
-  /// Creates constraint to manage the given constraint from plugin
-  SketchSolver_ConstraintParametric()
-    : SketchSolver_ConstraintRigid(ConstraintPtr())
-  {}
-
-public:
-  /// Creates temporary constraint based on feature
-  SketchSolver_ConstraintParametric(AttributePtr theAttribute);
-
-  /// \brief Update constraint
-  virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
-
-  /// \brief Update points coincident with parametric one
-  virtual void refresh();
-
-protected:
-  /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
-  virtual void process();
-
-  /// \brief Convert attribute to the entity
-  /// \param[out] theAttributeID   identifier of the entity related to the attribute
-  virtual void getAttributes(Slvs_hEntity& theAttributeID);
-
-  /// \brief This method is used in derived objects to check consistence of constraint.
-  virtual void adjustConstraint();
-
-private:
-  /// \brief Create SolveSpace line with given coordinates
-  /// \return created line
-  Slvs_Entity createLine(double theStartX, double theStartY, double theEndX, double theEndY);
-
-private:
-  AttributePtr myBaseAttribute; ///< attribute given by expression
-  Slvs_hEntity myHorizLineID;   ///< identifier of horizontal line, containing the point
-  Slvs_hEntity myVertLineID;    ///< identifier of vertical line, containing the point
-  double myX, myY;
-};
-
-#endif