20 #ifndef PartSet_Tools_H
21 #define PartSet_Tools_H
27 #include <Bnd_Box.hxx>
33 #include <ModelAPI_CompositeFeature.h>
34 #include <ModelAPI_Object.h>
35 #include <ModelAPI_Attribute.h>
36 #include <ModelAPI_AttributeSelection.h>
38 #include <Events_Message.h>
40 #include <TopoDS_Shape.hxx>
84 static int getAISDefaultWidth();
89 static gp_Pnt convertClickToPoint(QPoint thePoint, Handle(V3d_View) theView);
97 static void convertTo2D(
const gp_Pnt& thePoint, FeaturePtr theSketch,
98 Handle(V3d_View) theView,
99 double& theX,
double& theY);
105 static std::shared_ptr<GeomAPI_Pnt2d> convertTo2D(FeaturePtr theSketch,
106 const std::shared_ptr<GeomAPI_Pnt>& thePnt);
112 static std::shared_ptr<GeomAPI_Pnt> convertTo3D(
const double theX,
const double theY,
113 FeaturePtr theSketch);
116 static std::shared_ptr<ModelAPI_Document> document();
122 static void setFeatureValue(FeaturePtr theFeature,
double theX,
const std::string& theAttribute);
129 static double featureValue(FeaturePtr theFeature,
const std::string& theAttribute,
bool& isValid);
137 static FeaturePtr feature(FeaturePtr theFeature,
const std::string& theAttribute,
138 const std::string& theKind);
144 static void createConstraint(CompositeFeaturePtr theSketch,
145 std::shared_ptr<GeomDataAPI_Point2D> thePoint1,
146 std::shared_ptr<GeomDataAPI_Point2D> thePoint2);
151 static std::shared_ptr<GeomAPI_Pln> sketchPlane(CompositeFeaturePtr theSketch);
156 static void nullifySketchPlane(CompositeFeaturePtr theSketch);
159 static std::pair<bool, gp_Ax3> getWorldCSAt(
const GeomAPI_Face& theFace,
double U,
double V);
162 static std::pair<bool, gp_Pnt> getWorldPointByUV(
const GeomAPI_Face& theFace,
double U,
double V);
168 static std::pair<bool, Bnd_Box> getBBoxAtCS(
const GeomAPI_Shape& theShape,
const gp_Ax3 theCS);
171 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneDefaultSize(CompositeFeaturePtr theSketch);
174 static std::shared_ptr<ModelAPI_AttributeBoolean> sketchPlaneAxesEnabled(CompositeFeaturePtr theSketch);
177 static std::shared_ptr<ModelAPI_AttributeBoolean> sketchPlaneSubstrateEnabled(CompositeFeaturePtr theSketch);
180 static std::shared_ptr<ModelAPI_AttributeString> sketchPlaneGridType(CompositeFeaturePtr theSketch);
190 static std::string toString(Enum iType);
191 static Enum fromString(
const std::string& iTypeString);
194 static const std::array<std::string, 3> STRINGS;
197 static void setSketchPlaneGridType(CompositeFeaturePtr theSketch, SketchPlaneGridType::Enum theType);
198 static SketchPlaneGridType::Enum getSketchPlaneGridType(CompositeFeaturePtr theSketch);
201 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneRectangularGridStepX(CompositeFeaturePtr theSketch);
204 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneRectangularGridStepY(CompositeFeaturePtr theSketch);
207 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneRectangularGridOffsetAngle(CompositeFeaturePtr theSketch);
210 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneRectangularGridOffsetX(CompositeFeaturePtr theSketch);
213 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneRectangularGridOffsetY(CompositeFeaturePtr theSketch);
216 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneCircularGridStepR(CompositeFeaturePtr theSketch);
219 static std::shared_ptr<ModelAPI_AttributeInteger> sketchPlaneCircularGridNumOfAngSegments(CompositeFeaturePtr theSketch);
222 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneCircularGridOffsetAngle(CompositeFeaturePtr theSketch);
225 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneCircularGridOffsetX(CompositeFeaturePtr theSketch);
228 static std::shared_ptr<ModelAPI_AttributeDouble> sketchPlaneCircularGridOffsetY(CompositeFeaturePtr theSketch);
235 static std::shared_ptr<GeomAPI_Pnt> point3D(std::shared_ptr<GeomAPI_Pnt2d> thePoint2D,
236 CompositeFeaturePtr theSketch);
243 static std::shared_ptr<ModelAPI_Result> findFixedObjectByExternal(
244 const TopoDS_Shape& theShape,
245 const ObjectPtr& theObject,
246 CompositeFeaturePtr theSketch);
256 static std::shared_ptr<ModelAPI_Result> createFixedObjectByExternal(
257 const std::shared_ptr<GeomAPI_Shape>& theShape,
258 const ObjectPtr& theObject,
259 CompositeFeaturePtr theSketch,
260 const bool theTemporary,
261 FeaturePtr& theCreatedFeature);
267 static bool isContainPresentation(
const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theSelected,
268 const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
277 static std::pair<AttributePtr, int> findAttributeBy2dPoint(ObjectPtr theObj,
278 const TopoDS_Shape theShape,
279 FeaturePtr theSketch);
287 static std::shared_ptr<GeomAPI_Shape> findShapeBy2DPoint(
const AttributePtr& theAttribute,
295 static std::shared_ptr<GeomAPI_Pnt2d> getPoint(std::shared_ptr<ModelAPI_Feature>& theFeature,
296 const std::string& theAttribute);
304 static std::shared_ptr<GeomAPI_Pnt2d> getPnt2d(QMouseEvent* theEvent,
306 const FeaturePtr& theSketch);
314 static std::shared_ptr<GeomAPI_Pnt2d> getPnt2d(
const Handle(V3d_View)& theView,
315 const TopoDS_Shape& theShape,
316 const FeaturePtr& theSketch);
326 static FeaturePtr findFirstCoincidence(
const FeaturePtr& theFeature,
327 std::shared_ptr<GeomAPI_Pnt2d> thePoint);
336 static void findCoincidences(FeaturePtr theStartCoin, QList<FeaturePtr>& theList,
337 QList<FeaturePtr>& theCoincidencies,
338 std::string theAttr, QList<bool>& theIsAttributes);
345 static FeaturePtr findRefsToMeFeature(FeaturePtr theFeature,
const std::string& theFeatureId)
347 if (!theFeature.get())
351 const std::set<AttributePtr>& aRefsList = theFeature->data()->refsToMe();
352 std::set<AttributePtr>::const_iterator anIt;
353 for (anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) {
354 FeaturePtr aRefFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*anIt)->owner());
355 if (aRefFeature && aRefFeature->getKind() == theFeatureId)
365 static std::shared_ptr<GeomAPI_Pnt2d> getCoincedencePoint(FeaturePtr theStartCoin);
368 static void sendSubFeaturesEvent(
const CompositeFeaturePtr& theComposite,
376 static bool isAuxiliarySketchEntity(
const ObjectPtr& theObject);
382 static bool isIncludeIntoSketchResult(
const ObjectPtr& theObject);
384 static ResultPtr createFixedByExternalCenter(
const ObjectPtr& theObject,
385 const std::shared_ptr<GeomAPI_Edge>& theEdge,
387 const CompositeFeaturePtr& theSketch,
389 FeaturePtr& theCreatedFeature);
392 static void getFirstAndLastIndexInFolder(
const ObjectPtr& theFolder,
393 int& theFirst,
int& theLast);
399 static void getDefaultColor(ObjectPtr theObject,
const bool isEmptyColorValid,
400 std::vector<int>& theColor);
405 static double getDefaultDeflection(
const ObjectPtr& theObject);
411 static double getDefaultTransparency();
416 static QCursor getOperationCursor();
Identifier of the event kind.
Definition: Events_Message.h:36
Interface to the edge object.
Definition: GeomAPI_Edge.h:38
Interface to the face object.
Definition: GeomAPI_Face.h:36
\Plane in 3D place, defined by normal, center and x-direction.
Definition: GeomAPI_Pln.h:38
2D point defined by two coordinates
Definition: GeomAPI_Pnt2d.h:36
3D point defined by three coordinates
Definition: GeomAPI_Pnt.h:38
Interface to the topological shape object.
Definition: GeomAPI_Shape.h:43
Interface to the vertex object.
Definition: GeomAPI_Vertex.h:31
Attribute that contains 2D point coordinates.
Definition: GeomDataAPI_Point2D.h:37
CenterType
Type of the center of the circular of elliptic edge.
Definition: ModelAPI_AttributeSelection.h:38
The result of a feature.
Definition: ModelAPI_Result.h:37
Interface to ViewWindow object which contains 3d scene.
Definition: ModuleBase_IViewWindow.h:34
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
Presentation.
Definition: ModuleBase_ViewerPrs.h:37