X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConstructionAPI%2FConstructionAPI_Point.cpp;h=2656c55dc23528881c5478826f72b9b76ec86ae2;hb=0de6abc2ba4932e6c5b52009f62774c68791ccde;hp=26df2de8b15e6261ae423312947583c99a706fc4;hpb=1f4eea0442b8b32ac5e3bd7c4c7266102a0f4908;p=modules%2Fshaper.git diff --git a/src/ConstructionAPI/ConstructionAPI_Point.cpp b/src/ConstructionAPI/ConstructionAPI_Point.cpp index 26df2de8b..2656c55dc 100644 --- a/src/ConstructionAPI/ConstructionAPI_Point.cpp +++ b/src/ConstructionAPI/ConstructionAPI_Point.cpp @@ -1,62 +1,196 @@ -// Name : ConstructionAPI_Point.cpp -// Purpose: +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com // -// History: -// 29/03/16 - Sergey POKHODENKO - Creation of the file -//-------------------------------------------------------------------------------------- #include "ConstructionAPI_Point.h" -//-------------------------------------------------------------------------------------- -#include -#include -#include - -#include -//-------------------------------------------------------------------------------------- -ConstructionAPI_Point::ConstructionAPI_Point( - const std::shared_ptr & theFeature) + +#include + +#include +#include +#include + +//================================================================================================== +ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr& theFeature) : ModelHighAPI_Interface(theFeature) { initialize(); } -ConstructionAPI_Point::ConstructionAPI_Point( - const std::shared_ptr & theFeature, - const ModelHighAPI_Double & theX, - const ModelHighAPI_Double & theY, - const ModelHighAPI_Double & theZ) +//================================================================================================== +ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr& theFeature, + const ModelHighAPI_Double& theX, + const ModelHighAPI_Double& theY, + const ModelHighAPI_Double& theZ) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setByXYZ(theX, theY, theZ); + } +} + +/*//================================================================================================== +ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theEdge, + const ModelHighAPI_Double& theDistanceValue, + const bool theDistancePercent, + const bool theReverse) : ModelHighAPI_Interface(theFeature) { - if (initialize()) - setPoint(theX, theY, theZ); + if(initialize()) { + setByDistanceOnEdge(theEdge, theDistanceValue, theDistancePercent, theReverse); + } } +//================================================================================================== +ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theObject1, + const ModelHighAPI_Selection& theObject2) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + GeomAPI_Shape::ShapeType aType1 = getShapeType(theObject1); + GeomAPI_Shape::ShapeType aType2 = getShapeType(theObject2); + + if(aType1 == GeomAPI_Shape::VERTEX && aType2 == GeomAPI_Shape::FACE) { + // If first object is vertex and second object is face then set by projection. + setByProjection(theObject1, theObject2); + } else if(aType1 == GeomAPI_Shape::EDGE && aType2 == GeomAPI_Shape::EDGE) { + // If both objects are edges then set by lines intersection. + setByLinesIntersection(theObject1, theObject2); + } else if(aType1 == GeomAPI_Shape::EDGE && aType2 == GeomAPI_Shape::FACE) { + // If first object is edge and second object is face then set by line and plane intersection. + setByLineAndPlaneIntersection(theObject1, theObject2); + } + } +}*/ + +//================================================================================================== ConstructionAPI_Point::~ConstructionAPI_Point() { } -//-------------------------------------------------------------------------------------- -void ConstructionAPI_Point::setPoint(const ModelHighAPI_Double & theX, - const ModelHighAPI_Double & theY, - const ModelHighAPI_Double & theZ) +//================================================================================================== +void ConstructionAPI_Point::setByXYZ(const ModelHighAPI_Double& theX, + const ModelHighAPI_Double& theY, + const ModelHighAPI_Double& theZ) +{ + //fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod); + fillAttribute(theX, myx); + fillAttribute(theY, myy); + fillAttribute(theZ, myz); + + execute(false); +} + +/*//================================================================================================== +void ConstructionAPI_Point::setByDistanceOnEdge(const ModelHighAPI_Selection& theEdge, + const ModelHighAPI_Double& theDistanceValue, + const bool theDistancePercent, + const bool theReverse) { - theX.fillAttribute(myx); - theY.fillAttribute(myy); - theZ.fillAttribute(myz); + fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_DISTANCE_ON_EDGE(), mycreationMethod); + fillAttribute(theEdge, myedge); + fillAttribute(theDistanceValue, mydistanceValue); + fillAttribute(theDistancePercent, mydistancePercent); + fillAttribute(theReverse, myreverse); execute(); } -//-------------------------------------------------------------------------------------- -// TODO(spo): make add* as static functions of the class -PointPtr addPoint( - const std::shared_ptr & thePart, - const ModelHighAPI_Double& theX, - const ModelHighAPI_Double& theY, - const ModelHighAPI_Double& theZ) +//================================================================================================== +void ConstructionAPI_Point::setByProjection(const ModelHighAPI_Selection& theVertex, + const ModelHighAPI_Selection& theFace) +{ + fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION(), mycreationMethod); + fillAttribute(theVertex, mypoint); + fillAttribute(theFace, myplane); + + execute(); +} + +//================================================================================================== +void ConstructionAPI_Point::setByLinesIntersection(const ModelHighAPI_Selection& theEdge1, + const ModelHighAPI_Selection& theEdge2) +{ + fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_LINES_INTERSECTION(), mycreationMethod); + fillAttribute(theEdge1, myfirstLine); + fillAttribute(theEdge2, mysecondLine); + + execute(); +} + +//================================================================================================== +void ConstructionAPI_Point::setByLineAndPlaneIntersection(const ModelHighAPI_Selection& theEdge, + const ModelHighAPI_Selection& theFace) +{ + fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION(), mycreationMethod); + fillAttribute(theEdge, myintersectionLine); + fillAttribute(theFace, myintersectionPlane); + + execute(); +}*/ + +//================================================================================================== +void ConstructionAPI_Point::dump(ModelHighAPI_Dumper& theDumper) const +{ + // TODO: all types of points + + FeaturePtr aBase = feature(); + const std::string& aDocName = theDumper.name(aBase->document()); + + AttributeDoublePtr anAttrX = aBase->real(ConstructionPlugin_Point::X()); + AttributeDoublePtr anAttrY = aBase->real(ConstructionPlugin_Point::Y()); + AttributeDoublePtr anAttrZ = aBase->real(ConstructionPlugin_Point::Z()); + theDumper << aBase << " = model.addPoint(" << aDocName << ", " + << anAttrX << ", " << anAttrY << ", " << anAttrZ << ")" << std::endl; +} + +//================================================================================================== +PointPtr addPoint(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theX, + const ModelHighAPI_Double& theY, + const ModelHighAPI_Double& theZ) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(ConstructionAPI_Point::ID()); return PointPtr(new ConstructionAPI_Point(aFeature, theX, theY, theZ)); } + +/*//================================================================================================== +PointPtr addPoint(const std::shared_ptr & thePart, + const ModelHighAPI_Selection& theEdge, + const ModelHighAPI_Double& theDistanceValue, + const bool theDistancePercent, + const bool theReverse) +{ + // TODO(spo): check that thePart is not empty + std::shared_ptr aFeature = thePart->addFeature(ConstructionAPI_Point::ID()); + return PointPtr(new ConstructionAPI_Point(aFeature, theEdge, theDistanceValue, theDistancePercent, theReverse)); +} + +//================================================================================================== +PointPtr addPoint(const std::shared_ptr & thePart, + const ModelHighAPI_Selection& theObject1, + const ModelHighAPI_Selection& theObject2) +{ + // TODO(spo): check that thePart is not empty + std::shared_ptr aFeature = thePart->addFeature(ConstructionAPI_Point::ID()); + return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2)); +}*/