From 7ecefe4ca74618ab6fc2e7990b6ad50c12bca63c Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 8 May 2014 07:14:30 +0400 Subject: [PATCH] Preliminary changes for SketchSolver --- CMakeCommon/FindSolveSpace.cmake | 6 +++ CMakeLists.txt | 2 + linux_env.sh | 4 ++ msvc10_env.bat | 5 +++ src/SketchPlugin/CMakeLists.txt | 2 + src/SketchPlugin/SketchPlugin_Point.cpp | 42 +++++++++++++++++++++ src/SketchPlugin/SketchPlugin_Point.h | 48 ++++++++++++++++++++++++ src/SketchPlugin/plugin-Sketch.xml | 1 + src/SketchSolver/CMakeLists.txt | 31 +++++++++++++++ src/SketchSolver/SketchSolver.h | 18 +++++++++ src/SketchSolver/SketchSolver_Solver.cpp | 5 +++ src/SketchSolver/SketchSolver_Solver.h | 10 +++++ 12 files changed, 174 insertions(+) create mode 100644 CMakeCommon/FindSolveSpace.cmake create mode 100644 src/SketchPlugin/SketchPlugin_Point.cpp create mode 100644 src/SketchPlugin/SketchPlugin_Point.h create mode 100644 src/SketchSolver/CMakeLists.txt create mode 100644 src/SketchSolver/SketchSolver.h create mode 100644 src/SketchSolver/SketchSolver_Solver.cpp create mode 100644 src/SketchSolver/SketchSolver_Solver.h diff --git a/CMakeCommon/FindSolveSpace.cmake b/CMakeCommon/FindSolveSpace.cmake new file mode 100644 index 000000000..b373d2c40 --- /dev/null +++ b/CMakeCommon/FindSolveSpace.cmake @@ -0,0 +1,6 @@ +SET(SLVS_ROOT_DIR $ENV{SOLVESPACE_ROOT_DIR}) + +INCLUDE_DIRECTORIES(${SLVS_ROOT_DIR}/include) +LINK_DIRECTORIES(${SLVS_ROOT_DIR}/lib) + +SET(SLVS_LIBRARIES ${SLVS_ROOT_DIR}/lib/slvs.lib) diff --git a/CMakeLists.txt b/CMakeLists.txt index 223001654..18fbdfc7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ INCLUDE(FindQt) INCLUDE(FindBoost) INCLUDE(FindPython) INCLUDE(FindSalome) +INCLUDE(FindSolveSpace) IF(UNIX) IF(CMAKE_COMPILER_IS_GNUCC) @@ -31,6 +32,7 @@ ADD_SUBDIRECTORY (src/GeomDataAPI) ADD_SUBDIRECTORY (src/PartSetPlugin) ADD_SUBDIRECTORY (src/ConstructionPlugin) ADD_SUBDIRECTORY (src/SketchPlugin) +ADD_SUBDIRECTORY (src/SketchSolver) ADD_SUBDIRECTORY (src/ModuleBase) ADD_SUBDIRECTORY (src/PartSet) ADD_SUBDIRECTORY (src/PyConsole) diff --git a/linux_env.sh b/linux_env.sh index 170f3bf3d..8fb9f33ff 100644 --- a/linux_env.sh +++ b/linux_env.sh @@ -68,6 +68,10 @@ export LIBXML2_INCLUDE_DIR=${LIBXML2_ROOT_DIR}/include/libxml2 export LIBXML2_LIB_DIR=${LIBXML2_ROOT_DIR}/lib export LIBXML2_BIN_DIR=${LIBXML2_ROOT_DIR}/bin ## +#------ SolveSpace ------ +export SOLVESPACE_ROOT_DIR=${PDIR}/solvespace-2.0 +export LD_LIBRARY_PATH=${SOLVESPACE_ROOT_DIR}/lib:${LD_LIBRARY_PATH} +## #------ OCCT ------ export CAS_ROOT_DIR=${PDIR}/OCCT-6.7.0 diff --git a/msvc10_env.bat b/msvc10_env.bat index 7717e8047..1d2233ce4 100644 --- a/msvc10_env.bat +++ b/msvc10_env.bat @@ -126,6 +126,11 @@ set PATH=%CMAKEDIR%\bin;%PATH% @SET PATH=%BOOST_ROOT_DIR%\lib;%PATH% @REM ------------------------- +@REM ------------------------- +@SET SOLVESPACE_ROOT_DIR=%PDIR%\solvespace-2.0 +@SET PATH=%SOLVESPACE_ROOT_DIR%\lib;%PATH% +@REM ------------------------- + @SET NEW_GEOM_CONFIG_FILE=%ROOT_DIR%\install\plugins @SET PATH=%ROOT_DIR%\install\plugins;%PATH% diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 347fabe88..15ec42e10 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -6,6 +6,7 @@ SET(PROJECT_HEADERS SketchPlugin_Plugin.h SketchPlugin_Sketch.h SketchPlugin_Line.h + SketchPlugin_Point.h ) SET(PROJECT_SOURCES @@ -13,6 +14,7 @@ SET(PROJECT_SOURCES SketchPlugin_Plugin.cpp SketchPlugin_Sketch.cpp SketchPlugin_Line.cpp + SketchPlugin_Point.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp new file mode 100644 index 000000000..fa77d2494 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -0,0 +1,42 @@ +// File: SketchPlugin_Point.cpp +// Created: 07 May 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_Point.h" +#include "SketchPlugin_Sketch.h" +#include +////#include +////#include +#include + +using namespace std; + +////// face of the square-face displayed for selection of general plane +////const double PLANE_SIZE = 200; + +SketchPlugin_Point::SketchPlugin_Point() +{ +} + +void SketchPlugin_Point::initAttributes() +{ + data()->addAttribute(POINT_ATTR_COORD, GeomDataAPI_Point2D::type()); +} + +void SketchPlugin_Point::execute() +{ +} + +const boost::shared_ptr& SketchPlugin_Point::preview() +{ + SketchPlugin_Sketch* aSketch = sketch(); + // compute a point in 3D view + boost::shared_ptr aPoint = + boost::dynamic_pointer_cast(data()->attribute(POINT_ATTR_COORD)); + boost::shared_ptr aPoint3D(aSketch->to3D(aPoint->x(), aPoint->y())); + // make a visible point + //boost::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd); + //setPreview(anEdge); + + return getPreview(); +} diff --git a/src/SketchPlugin/SketchPlugin_Point.h b/src/SketchPlugin/SketchPlugin_Point.h new file mode 100644 index 000000000..f4ecc4936 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_Point.h @@ -0,0 +1,48 @@ +// File: SketchPlugin_Point.h +// Created: 07 May 2014 +// Author: Artem ZHIDKOV + +#ifndef SketchPlugin_Point_HeaderFile +#define SketchPlugin_Point_HeaderFile + +#include "SketchPlugin.h" +#include "SketchPlugin_Feature.h" +#include + +/// Coordinates of the point +const std::string POINT_ATTR_COORD("PointCoordindates"); + +/**\class SketchPlugin_Point + * \ingroup DataModel + * \brief Feature for creation of a new point. + */ +class SketchPlugin_Point: public SketchPlugin_Feature +{ +public: + /// Returns the kind of a feature + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + {static std::string MY_KIND = "SketchPoint"; return MY_KIND;} + + /// Returns to which group in the document must be added feature + SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() + {static std::string MY_GROUP = "Sketch"; return MY_GROUP;} + + /// Creates a new part document if needed + SKETCHPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + SKETCHPLUGIN_EXPORT virtual void initAttributes(); + + /// Returns the sketch preview + SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); + + /// Adds sub-feature of the higher level feature (sub-element of the sketch) + /// \param theFeature sub-feature + SKETCHPLUGIN_EXPORT virtual const void addSub( + const boost::shared_ptr& theFeature) {}; + + /// Use plugin manager for features creation + SketchPlugin_Point(); +}; + +#endif diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 2feedd6d7..8730c2ef8 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -5,6 +5,7 @@