From: nds Date: Thu, 24 Apr 2014 08:42:31 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~124 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cf45387763e7aec06b955f71082eba8d65057b49;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines Visualize three planes for sketch. --- diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 509d8ac2d..40fcc4633 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -6,10 +6,12 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(PROJECT_HEADERS GeomAlgoAPI.h + GeomAlgoAPI_CompoundBuilder.h GeomAlgoAPI_FaceBuilder.h ) SET(PROJECT_SOURCES + GeomAlgoAPI_CompoundBuilder.cpp GeomAlgoAPI_FaceBuilder.cpp ) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp new file mode 100644 index 000000000..2882ee2fa --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp @@ -0,0 +1,28 @@ +// File: GeomAlgoAPI_CompoundBuilder.cpp +// Created: 24 Apr 2014 +// Author: Natalia ERMOLAEVA + +#include +//#include +//#include +//#include +#include +#include + +boost::shared_ptr GeomAlgoAPI_CompoundBuilder::compound + (std::list > theShapes) +{ + BRep_Builder aBuilder; + TopoDS_Compound aComp; + aBuilder.MakeCompound(aComp); + + std::list >::const_iterator anIt = theShapes.begin(), + aLast = theShapes.end(); + for (; anIt != aLast; anIt++) { + aBuilder.Add(aComp, (*anIt)->impl()); + } + + boost::shared_ptr aRes(new GeomAPI_Shape); + aRes->setImpl(new TopoDS_Shape(aComp)); + return aRes; +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.h new file mode 100644 index 000000000..5cca6ad87 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.h @@ -0,0 +1,30 @@ +// File: GeomAlgoAPI_CompoundBuilder.h +// Created: 24 Apr 2014 +// Author: Natalia ERMOLAEVA + +#ifndef GeomAlgoAPI_CompoundBuilder_HeaderFile +#define GeomAlgoAPI_CompoundBuilder_HeaderFile + +#include +#include +#include +#include +#include + +#include + +/**\class GeomAlgoAPI_CompoundBuilder + * \ingroup DataAlgo + * \brief Allows to create face-shapes by different parameters + */ + +class GEOMALGOAPI_EXPORT GeomAlgoAPI_CompoundBuilder +{ +public: + /// Creates compund of the given shapes + /// \param theShapes a list of shapes + static boost::shared_ptr compound + (std::list > theShapes); +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 5a597ebf6..2eaa512c8 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -5,6 +5,7 @@ #include "SketchPlugin_Sketch.h" #include #include +#include using namespace std; @@ -25,12 +26,24 @@ void SketchPlugin_Sketch::execute() } const boost::shared_ptr& SketchPlugin_Sketch::preview() +{ + std::list > aFaces; + + addPlane(1, 0, 0, aFaces); // YZ plane + addPlane(0, 1, 0, aFaces); // XZ plane + addPlane(0, 0, 1, aFaces); // XY plane + boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces); + setPreview(aCompound); + + return getPreview(); +} + +void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ, + std::list >& theShapes) const { boost::shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); - boost::shared_ptr aNormal(new GeomAPI_Dir(1, 0, 0)); + boost::shared_ptr aNormal(new GeomAPI_Dir(theX, theY, theZ)); boost::shared_ptr aFace = GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE); - setPreview(aFace); - - return getPreview(); + theShapes.push_back(aFace); } diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 4cceee37f..ed936bde9 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -8,6 +8,8 @@ #include "SketchPlugin.h" #include +#include + /// part reference attribute const std::string PART_ATTR_DOC_REF = "SketchDocument"; @@ -37,6 +39,15 @@ public: /// Use plugin manager for features creation SketchPlugin_Sketch(); +protected: + /// Creates a plane and append it to the list + /// \param theX the X normal value + /// \param theY the Y normal value + /// \param theZ the Z normal value + /// \param theShapes the list of result shapes + void addPlane(double theX, double theY, double theZ, + std::list >& theShapes) const; + }; #endif