0028226: Incorrect history support in ShapeUpgrade_UnifySameDomain algorithm
[occt.git] / src / ShapeUpgrade / ShapeUpgrade_UnifySameDomain.hxx
CommitLineData
42cf5bc1 1//-Copyright: Open CASCADE 2014
2// Created on: 2012-06-09
3// Created by: jgv@ROLEX
4// Copyright (c) 2012-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _ShapeUpgrade_UnifySameDomain_HeaderFile
18#define _ShapeUpgrade_UnifySameDomain_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <TopoDS_Shape.hxx>
24#include <Standard_Boolean.hxx>
25#include <MMgt_TShared.hxx>
f7d70540 26#include <TopTools_DataMapOfShapeShape.hxx>
56091b56 27#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
9ed6494b 28#include <TopTools_MapOfShape.hxx>
42cf5bc1 29class ShapeBuild_ReShape;
30class TopoDS_Shape;
31
32
33class ShapeUpgrade_UnifySameDomain;
34DEFINE_STANDARD_HANDLE(ShapeUpgrade_UnifySameDomain, MMgt_TShared)
35
cef6867c 36//! This tool tries to unify faces and edges of the shape which lies on the same geometry.
37//! Faces/edges considering as 'same-domain' if a group of neighbouring faces/edges lying on coincident surfaces/curves.
38//! In this case these faces/edges can be unified into one face/edge.
39//! ShapeUpgrade_UnifySameDomain initialized by the shape and the next optional parameters:
40//! UnifyFaces - tries to unify all possible faces
41//! UnifyEdges - tries to unify all possible edges
42//! ConcatBSplines - if this flag set to true then all neighbouring edges which lays
43//! on the BSpline or Bezier curves with C1 continuity on their common vertices will be merged into one common edge
44//! The output result of tool is an unified shape
45//! All the modifications of initial shape are recorded during unifying.
46//! Method Generated() can be used to obtain the new (unified) shape from the old one
42cf5bc1 47class ShapeUpgrade_UnifySameDomain : public MMgt_TShared
48{
49
50public:
51
52
53 //! empty constructor
54 Standard_EXPORT ShapeUpgrade_UnifySameDomain();
55
56 Standard_EXPORT ShapeUpgrade_UnifySameDomain(const TopoDS_Shape& aShape, const Standard_Boolean UnifyEdges = Standard_True, const Standard_Boolean UnifyFaces = Standard_True, const Standard_Boolean ConcatBSplines = Standard_False);
57
cef6867c 58 //! Initializes with a shape
42cf5bc1 59 Standard_EXPORT void Initialize (const TopoDS_Shape& aShape, const Standard_Boolean UnifyEdges = Standard_True, const Standard_Boolean UnifyFaces = Standard_True, const Standard_Boolean ConcatBSplines = Standard_False);
60
fe1a6e4e 61 //! Sets the flag defining whether it is allowed to create
62 //! internal edges inside merged faces in the case of non-manifold
63 //! topology. Without this flag merging through multi connected edge
64 //! is forbidden. Default value is false.
65 Standard_EXPORT void AllowInternalEdges (const Standard_Boolean theValue);
2ba9eb30 66
9ed6494b 67 //! Sets the shape for avoid merging of the faces in given places.
68 //! This shape can be vertex or edge.
69 //! If shape is vertex it forbids merging of connected edges.
70 //! If shape is edge it forbids merging of connected faces.
71 Standard_EXPORT void KeepShape(const TopoDS_Shape& theShape);
72
73 //! Sets the map of shapes for avoid merging of the faces in given places
74 //! These shapes can be vertexes or edges.
75 //! If shape is vertex it forbids merging of connected edges.
76 //! If shape is edge it forbids merging of connected faces.
77 Standard_EXPORT void KeepShapes(const TopTools_MapOfShape& theShapes);
78
2ba9eb30 79 //! Sets the linear tolerance. Default value is Precision::Confusion().
80 void SetLinearTolerance(const Standard_Real theValue)
81 {
82 myLinTol = theValue;
83 }
84
85 //! Sets the angular tolerance. Default value is Precision::Angular().
86 void SetAngularTolerance(const Standard_Real theValue)
87 {
88 myAngTol = theValue;
89 }
90
42cf5bc1 91 //! Builds the resulting shape
92 Standard_EXPORT void Build();
93
94 //! Gives the resulting shape
95 Standard_EXPORT const TopoDS_Shape& Shape() const;
96
20aa0d3f 97 //! Returns list of new common shapes from the old one shape.
98 //! After successful common operation based on <aShape> list
99 //! will contain new generated shape.
100 //! In other cases it will return an empty list
101 Standard_EXPORT const TopTools_ListOfShape& Generated(const TopoDS_Shape& aShape);
102
103 //! Returns list of new modified shapes.
104 //! After successful modifying <aShape> without geometry changes list
105 //! will contain new modified shape.
106 //! In other cases it will return an empty list
107 Standard_EXPORT const TopTools_ListOfShape& Modified(const TopoDS_Shape& aShape);
108
109 //! Returns true if the <aShape> has been deleted. The
110 //! result shape of the operation does not contain even trace of <aShape>.
111 Standard_EXPORT Standard_Boolean IsDeleted(const TopoDS_Shape& aShape);
42cf5bc1 112
113 //! this method makes if possible a common face from each
114 //! group of faces lying on coincident surfaces
115 Standard_EXPORT void UnifyFaces();
116
117 //! this method makes if possible a common edge from each
118 //! group of edges connecting common couple of faces
119 Standard_EXPORT void UnifyEdges();
120
121 //! this method unifies same domain faces and edges
122 Standard_EXPORT void UnifyFacesAndEdges();
123
124
125
126
92efcf78 127 DEFINE_STANDARD_RTTIEXT(ShapeUpgrade_UnifySameDomain,MMgt_TShared)
42cf5bc1 128
129protected:
130
131
132
133
134private:
135
56091b56 136 void IntUnifyFaces(const TopoDS_Shape& theInpShape,
137 const TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces,
138 Standard_Boolean IsCheckSharedEdgeOri);
42cf5bc1 139
140 TopoDS_Shape myInitShape;
2ba9eb30 141 Standard_Real myLinTol;
142 Standard_Real myAngTol;
42cf5bc1 143 Standard_Boolean myUnifyFaces;
144 Standard_Boolean myUnifyEdges;
145 Standard_Boolean myConcatBSplines;
fe1a6e4e 146 Standard_Boolean myAllowInternal;
42cf5bc1 147 TopoDS_Shape myShape;
148 Handle(ShapeBuild_ReShape) myContext;
20aa0d3f 149 TopTools_DataMapOfShapeShape myOldToGeneratedShapes;
150 TopTools_ListOfShape myHistShapes;
151 TopTools_MapOfShape myRemovedShapes;
9ed6494b 152 TopTools_MapOfShape myKeepShapes;
42cf5bc1 153
154
155};
156
157
158
159
160
161
162
163#endif // _ShapeUpgrade_UnifySameDomain_HeaderFile