mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0032999: Modeling Algorithms - New option in ShapeUpgrade_ShapeDivide algorithm: splitting into N parts, into N*M parts
1. Multiple changes in ShapeUpgrade_ShapeDivideArea, ShapeUpgrade_FaceDivide, ShapeUpgrade_FaceDivideArea, ShapeUpgrade_SplitSurface, ShapeUpgrade_SplitSurfaceArea: new methods NbParts and SetSplittingByNumber, changes in ShapeUpgrade_FaceDivideArea::Perform and ShapeUpgrade_SplitSurfaceArea::Compute concerning new modes of splitting. 2. New Draw command "DT_SplitByNumber" for testing new modes of splitting. 3. New subgroups "split_number" and "split_two_numbers" in the group of tests "heal" for testing new modes of splitting.
This commit is contained in:
@@ -1190,6 +1190,52 @@ static Standard_Integer splitarea (Draw_Interpretor& di,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer splitbynumber (Draw_Interpretor& di,
|
||||
Standard_Integer argc,
|
||||
const char** argv)
|
||||
{
|
||||
if (argc < 4) {
|
||||
di << "bad number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TopoDS_Shape inputShape=DBRep::Get(argv[2], TopAbs_FACE);
|
||||
if (inputShape.IsNull()) {
|
||||
di << "Unknown face\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Integer aNbParts, aNumber1 = 0, aNumber2 = 0;
|
||||
aNbParts = aNumber1 = Draw::Atoi (argv[3]);
|
||||
if (argc > 4)
|
||||
aNumber2 = Draw::Atoi (argv[4]);
|
||||
|
||||
if (argc == 4 && aNbParts <= 0)
|
||||
{
|
||||
di << "Incorrect number of parts\n";
|
||||
return 1;
|
||||
}
|
||||
if (argc == 5 &&
|
||||
(aNumber1 <= 0 || aNumber2 <= 0))
|
||||
{
|
||||
di << "Incorrect numbers in U or V\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
ShapeUpgrade_ShapeDivideArea tool (inputShape);
|
||||
tool.SetSplittingByNumber (Standard_True);
|
||||
if (argc == 4)
|
||||
tool.NbParts() = aNbParts;
|
||||
else
|
||||
tool.SetNumbersUVSplits (aNumber1, aNumber2);
|
||||
tool.Perform();
|
||||
TopoDS_Shape res = tool.Result();
|
||||
|
||||
ShapeFix::SameParameter ( res, Standard_False );
|
||||
DBRep::Set ( argv[1], res );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer removeinternalwires (Draw_Interpretor& di,
|
||||
Standard_Integer argc,
|
||||
const char** argv)
|
||||
@@ -1624,6 +1670,8 @@ static Standard_Integer reshape(Draw_Interpretor& /*theDI*/,
|
||||
__FILE__,splitclosed,g);
|
||||
theCommands.Add ("DT_SplitByArea","result shape maxarea [preci]",
|
||||
__FILE__,splitarea,g);
|
||||
theCommands.Add ("DT_SplitByNumber","result face number [number2]",
|
||||
__FILE__,splitbynumber,g);
|
||||
|
||||
theCommands.Add ("RemoveIntWires","result minarea wholeshape [faces or wires] [moderemoveface ]",
|
||||
__FILE__,removeinternalwires,g);
|
||||
|
@@ -67,7 +67,7 @@ ShapeUpgrade_ClosedFaceDivide::ShapeUpgrade_ClosedFaceDivide(const TopoDS_Face&
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeUpgrade_ClosedFaceDivide::SplitSurface()
|
||||
Standard_Boolean ShapeUpgrade_ClosedFaceDivide::SplitSurface(const Standard_Real)
|
||||
{
|
||||
Handle(ShapeUpgrade_SplitSurface) SplitSurf = GetSplitSurfaceTool();
|
||||
if ( SplitSurf.IsNull() ) return Standard_False;
|
||||
|
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
//! Performs splitting of surface and computes the shell
|
||||
//! from source face.
|
||||
Standard_EXPORT virtual Standard_Boolean SplitSurface() Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean SplitSurface(const Standard_Real theArea = 0.) Standard_OVERRIDE;
|
||||
|
||||
//! Sets the number of cutting lines by which closed face will be split.
|
||||
//! The resulting faces will be num+1.
|
||||
|
@@ -92,12 +92,12 @@ void ShapeUpgrade_FaceDivide::SetSurfaceSegmentMode(const Standard_Boolean Segme
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeUpgrade_FaceDivide::Perform ()
|
||||
Standard_Boolean ShapeUpgrade_FaceDivide::Perform (const Standard_Real theArea)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
|
||||
if ( myFace.IsNull() ) return Standard_False;
|
||||
myResult = myFace;
|
||||
SplitSurface();
|
||||
SplitSurface (theArea);
|
||||
SplitCurves();
|
||||
return Status ( ShapeExtend_DONE );
|
||||
}
|
||||
@@ -107,7 +107,7 @@ Standard_Boolean ShapeUpgrade_FaceDivide::Perform ()
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeUpgrade_FaceDivide::SplitSurface ()
|
||||
Standard_Boolean ShapeUpgrade_FaceDivide::SplitSurface (const Standard_Real theArea)
|
||||
{
|
||||
Handle(ShapeUpgrade_SplitSurface) SplitSurf = GetSplitSurfaceTool();
|
||||
if ( SplitSurf.IsNull() ) return Standard_False;
|
||||
@@ -144,7 +144,7 @@ Standard_Boolean ShapeUpgrade_FaceDivide::SplitSurface ()
|
||||
if (Vl < aSVl) Vl += Min(dV, aSVl - Vl);
|
||||
}
|
||||
|
||||
SplitSurf->Init ( surf, Uf, Ul, Vf, Vl );
|
||||
SplitSurf->Init (surf, Uf, Ul, Vf, Vl, theArea);
|
||||
SplitSurf->Perform(mySegmentMode);
|
||||
|
||||
// If surface was neither split nor modified, do nothing
|
||||
|
@@ -72,11 +72,17 @@ public:
|
||||
//! The context is used to keep track of former splittings
|
||||
//! in order to keep sharings. It is updated according to
|
||||
//! modifications made.
|
||||
Standard_EXPORT virtual Standard_Boolean Perform();
|
||||
//! The optional argument <theArea> is used to initialize
|
||||
//! the tool for splitting surface in the case of
|
||||
//! splitting into N parts where N is user-defined.
|
||||
Standard_EXPORT virtual Standard_Boolean Perform(const Standard_Real theArea = 0.);
|
||||
|
||||
//! Performs splitting of surface and computes the shell
|
||||
//! from source face.
|
||||
Standard_EXPORT virtual Standard_Boolean SplitSurface();
|
||||
//! The optional argument <theArea> is used to initialize
|
||||
//! the tool for splitting surface in the case of
|
||||
//! splitting into N parts where N is user-defined.
|
||||
Standard_EXPORT virtual Standard_Boolean SplitSurface(const Standard_Real theArea = 0.);
|
||||
|
||||
//! Performs splitting of curves of all the edges in the
|
||||
//! shape and divides these edges.
|
||||
|
@@ -35,6 +35,9 @@ IMPLEMENT_STANDARD_RTTIEXT(ShapeUpgrade_FaceDivideArea,ShapeUpgrade_FaceDivide)
|
||||
ShapeUpgrade_FaceDivideArea::ShapeUpgrade_FaceDivideArea()
|
||||
{
|
||||
myMaxArea = Precision::Infinite();
|
||||
myNbParts = 0;
|
||||
myUnbSplit = myVnbSplit = -1;
|
||||
myIsSplittingByNumber = Standard_False;
|
||||
SetPrecision(1.e-5);
|
||||
SetSplitSurfaceTool (new ShapeUpgrade_SplitSurfaceArea);
|
||||
}
|
||||
@@ -47,6 +50,9 @@ ShapeUpgrade_FaceDivideArea::ShapeUpgrade_FaceDivideArea()
|
||||
ShapeUpgrade_FaceDivideArea::ShapeUpgrade_FaceDivideArea(const TopoDS_Face& F)
|
||||
{
|
||||
myMaxArea = Precision::Infinite();
|
||||
myNbParts = 0;
|
||||
myUnbSplit = myVnbSplit = -1;
|
||||
myIsSplittingByNumber = Standard_False;
|
||||
SetPrecision(1.e-5);
|
||||
SetSplitSurfaceTool (new ShapeUpgrade_SplitSurfaceArea);
|
||||
Init(F);
|
||||
@@ -57,54 +63,74 @@ ShapeUpgrade_FaceDivideArea::ShapeUpgrade_FaceDivideArea(const TopoDS_Face& F)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeUpgrade_FaceDivideArea::Perform()
|
||||
Standard_Boolean ShapeUpgrade_FaceDivideArea::Perform(const Standard_Real)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
|
||||
GProp_GProps aGprop;
|
||||
|
||||
|
||||
BRepGProp::SurfaceProperties(myFace,aGprop,Precision());
|
||||
Standard_Real anArea = aGprop.Mass();
|
||||
|
||||
Standard_Integer anbParts = 0;
|
||||
if (myMaxArea == -1)
|
||||
{
|
||||
anbParts = myNbParts;
|
||||
myMaxArea = anArea / anbParts;
|
||||
}
|
||||
|
||||
if((anArea - myMaxArea) < Precision::Confusion())
|
||||
return Standard_False;
|
||||
|
||||
Standard_Integer anbParts = RealToInt(ceil(anArea/myMaxArea));
|
||||
|
||||
if (anbParts == 0)
|
||||
anbParts = RealToInt(ceil(anArea/myMaxArea));
|
||||
|
||||
Handle(ShapeUpgrade_SplitSurfaceArea) aSurfTool= Handle(ShapeUpgrade_SplitSurfaceArea)::
|
||||
DownCast(GetSplitSurfaceTool ());
|
||||
if(aSurfTool.IsNull())
|
||||
return Standard_False;
|
||||
aSurfTool->NbParts() = anbParts;
|
||||
if(!ShapeUpgrade_FaceDivide::Perform())
|
||||
if (myIsSplittingByNumber)
|
||||
{
|
||||
aSurfTool->SetSplittingIntoSquares(Standard_True);
|
||||
aSurfTool->SetNumbersUVSplits (myUnbSplit, myVnbSplit);
|
||||
}
|
||||
if (!ShapeUpgrade_FaceDivide::Perform (anArea))
|
||||
return Standard_False;
|
||||
|
||||
TopoDS_Shape aResult = Result();
|
||||
if(aResult.ShapeType() == TopAbs_FACE)
|
||||
return Standard_False;
|
||||
Standard_Integer aStatus = myStatus;
|
||||
TopExp_Explorer aExpF(aResult,TopAbs_FACE);
|
||||
TopoDS_Shape aCopyRes = aResult.EmptyCopied();
|
||||
|
||||
Standard_Boolean isModified = Standard_False;
|
||||
for( ; aExpF.More() ; aExpF.Next()) {
|
||||
TopoDS_Shape aSh = Context()->Apply(aExpF.Current());
|
||||
TopoDS_Face aFace = TopoDS::Face(aSh);
|
||||
Init(aFace);
|
||||
BRep_Builder aB;
|
||||
if(Perform()) {
|
||||
isModified = Standard_True;
|
||||
TopoDS_Shape aRes = Result();
|
||||
TopExp_Explorer aExpR(aRes,TopAbs_FACE);
|
||||
for( ; aExpR.More(); aExpR.Next())
|
||||
aB.Add(aCopyRes,aExpR.Current());
|
||||
}
|
||||
else
|
||||
aB.Add(aCopyRes,aFace);
|
||||
}
|
||||
if(isModified)
|
||||
|
||||
if (!myIsSplittingByNumber)
|
||||
{
|
||||
if (aCopyRes.ShapeType() == TopAbs_WIRE || aCopyRes.ShapeType() == TopAbs_SHELL)
|
||||
aCopyRes.Closed (BRep_Tool::IsClosed (aCopyRes));
|
||||
Context()->Replace(aResult,aCopyRes);
|
||||
TopExp_Explorer aExpF(aResult,TopAbs_FACE);
|
||||
TopoDS_Shape aCopyRes = aResult.EmptyCopied();
|
||||
|
||||
Standard_Boolean isModified = Standard_False;
|
||||
for( ; aExpF.More() ; aExpF.Next()) {
|
||||
TopoDS_Shape aSh = Context()->Apply(aExpF.Current());
|
||||
TopoDS_Face aFace = TopoDS::Face(aSh);
|
||||
Init(aFace);
|
||||
BRep_Builder aB;
|
||||
if(Perform()) {
|
||||
isModified = Standard_True;
|
||||
TopoDS_Shape aRes = Result();
|
||||
TopExp_Explorer aExpR(aRes,TopAbs_FACE);
|
||||
for( ; aExpR.More(); aExpR.Next())
|
||||
aB.Add(aCopyRes,aExpR.Current());
|
||||
}
|
||||
else
|
||||
aB.Add(aCopyRes,aFace);
|
||||
}
|
||||
if(isModified)
|
||||
{
|
||||
if (aCopyRes.ShapeType() == TopAbs_WIRE || aCopyRes.ShapeType() == TopAbs_SHELL)
|
||||
aCopyRes.Closed (BRep_Tool::IsClosed (aCopyRes));
|
||||
Context()->Replace(aResult,aCopyRes);
|
||||
}
|
||||
}
|
||||
|
||||
myStatus |= aStatus;
|
||||
myResult = Context()->Apply ( aResult );
|
||||
return Status ( ShapeExtend_DONE );
|
||||
|
@@ -40,12 +40,24 @@ public:
|
||||
|
||||
//! Performs splitting and computes the resulting shell
|
||||
//! The context is used to keep track of former splittings
|
||||
Standard_EXPORT virtual Standard_Boolean Perform() Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Perform(const Standard_Real theArea = 0.) Standard_OVERRIDE;
|
||||
|
||||
//! Set max area allowed for faces
|
||||
Standard_Real& MaxArea();
|
||||
|
||||
//! Set number of parts expected
|
||||
Standard_Integer& NbParts();
|
||||
|
||||
//! Set fixed numbers of splits in U and V directions.
|
||||
//! Only for "Splitting By Numbers" mode
|
||||
void SetNumbersUVSplits(const Standard_Integer theNbUsplits,
|
||||
const Standard_Integer theNbVsplits);
|
||||
|
||||
//! Set splitting mode
|
||||
//! If the mode is "splitting by number",
|
||||
//! the face is splitted approximately into <myNbParts> parts,
|
||||
//! the parts are similar to squares in 2D.
|
||||
void SetSplittingByNumber(const Standard_Boolean theIsSplittingByNumber);
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(ShapeUpgrade_FaceDivideArea,ShapeUpgrade_FaceDivide)
|
||||
@@ -59,7 +71,10 @@ private:
|
||||
|
||||
|
||||
Standard_Real myMaxArea;
|
||||
|
||||
Standard_Integer myNbParts;
|
||||
Standard_Integer myUnbSplit;
|
||||
Standard_Integer myVnbSplit;
|
||||
Standard_Boolean myIsSplittingByNumber;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -17,3 +17,21 @@ inline Standard_Real& ShapeUpgrade_FaceDivideArea::MaxArea()
|
||||
}
|
||||
|
||||
|
||||
inline Standard_Integer& ShapeUpgrade_FaceDivideArea::NbParts()
|
||||
{
|
||||
return myNbParts;
|
||||
}
|
||||
|
||||
inline void ShapeUpgrade_FaceDivideArea::SetSplittingByNumber(const Standard_Boolean theIsSplittingByNumber)
|
||||
{
|
||||
myIsSplittingByNumber = theIsSplittingByNumber;
|
||||
}
|
||||
|
||||
inline void ShapeUpgrade_FaceDivideArea::SetNumbersUVSplits(const Standard_Integer theNbUsplits,
|
||||
const Standard_Integer theNbVsplits)
|
||||
{
|
||||
myUnbSplit = theNbUsplits;
|
||||
myVnbSplit = theNbVsplits;
|
||||
if (myUnbSplit > 0 && myVnbSplit > 0)
|
||||
myNbParts = myUnbSplit * myVnbSplit;
|
||||
}
|
||||
|
@@ -26,6 +26,9 @@ ShapeUpgrade_ShapeDivideArea::ShapeUpgrade_ShapeDivideArea():
|
||||
ShapeUpgrade_ShapeDivide()
|
||||
{
|
||||
myMaxArea = Precision::Infinite();
|
||||
myNbParts = 0;
|
||||
myUnbSplit = myVnbSplit = -1;
|
||||
myIsSplittingByNumber = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -38,6 +41,9 @@ ShapeUpgrade_ShapeDivideArea::ShapeUpgrade_ShapeDivideArea(const TopoDS_Shape& S
|
||||
|
||||
{
|
||||
myMaxArea = Precision::Infinite();
|
||||
myNbParts = 0;
|
||||
myUnbSplit = myVnbSplit = -1;
|
||||
myIsSplittingByNumber = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -49,6 +55,9 @@ ShapeUpgrade_ShapeDivideArea::ShapeUpgrade_ShapeDivideArea(const TopoDS_Shape& S
|
||||
{
|
||||
Handle(ShapeUpgrade_FaceDivideArea) aFaceTool = new ShapeUpgrade_FaceDivideArea;
|
||||
aFaceTool->MaxArea() = myMaxArea;
|
||||
aFaceTool->NbParts() = myNbParts;
|
||||
aFaceTool->SetNumbersUVSplits (myUnbSplit, myVnbSplit);
|
||||
aFaceTool->SetSplittingByNumber (myIsSplittingByNumber);
|
||||
return aFaceTool;
|
||||
}
|
||||
|
||||
|
@@ -41,7 +41,20 @@ public:
|
||||
//! Set max area allowed for faces
|
||||
Standard_Real& MaxArea();
|
||||
|
||||
//! Set number of parts expected
|
||||
//! for the case of splitting by number
|
||||
Standard_Integer& NbParts();
|
||||
|
||||
//! Set fixed numbers of splits in U and V directions.
|
||||
//! Only for "Splitting By Numbers" mode
|
||||
void SetNumbersUVSplits(const Standard_Integer theNbUsplits,
|
||||
const Standard_Integer theNbVsplits);
|
||||
|
||||
//! Set splitting mode
|
||||
//! If the mode is "splitting by number",
|
||||
//! the face is splitted approximately into <myNbParts> parts,
|
||||
//! the parts are similar to squares in 2D.
|
||||
void SetSplittingByNumber(const Standard_Boolean theIsSplittingByNumber);
|
||||
|
||||
|
||||
protected:
|
||||
@@ -57,8 +70,11 @@ private:
|
||||
|
||||
|
||||
|
||||
Standard_Real myMaxArea;
|
||||
|
||||
Standard_Real myMaxArea;
|
||||
Standard_Integer myNbParts;
|
||||
Standard_Integer myUnbSplit;
|
||||
Standard_Integer myVnbSplit;
|
||||
Standard_Boolean myIsSplittingByNumber;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -16,4 +16,25 @@ inline Standard_Real& ShapeUpgrade_ShapeDivideArea::MaxArea()
|
||||
return myMaxArea;
|
||||
}
|
||||
|
||||
inline Standard_Integer& ShapeUpgrade_ShapeDivideArea::NbParts()
|
||||
{
|
||||
return myNbParts;
|
||||
}
|
||||
|
||||
inline void ShapeUpgrade_ShapeDivideArea::SetSplittingByNumber(const Standard_Boolean theIsSplittingByNumber)
|
||||
{
|
||||
myIsSplittingByNumber = theIsSplittingByNumber;
|
||||
if (myIsSplittingByNumber)
|
||||
myMaxArea = -1;
|
||||
}
|
||||
|
||||
inline void ShapeUpgrade_ShapeDivideArea::SetNumbersUVSplits(const Standard_Integer theNbUsplits,
|
||||
const Standard_Integer theNbVsplits)
|
||||
{
|
||||
myIsSplittingByNumber = Standard_True;
|
||||
myMaxArea = -1;
|
||||
myUnbSplit = theNbUsplits;
|
||||
myVnbSplit = theNbVsplits;
|
||||
if (myUnbSplit > 0 && myVnbSplit > 0)
|
||||
myNbParts = myUnbSplit * myVnbSplit;
|
||||
}
|
||||
|
@@ -35,6 +35,10 @@
|
||||
#include <TColGeom_HArray2OfSurface.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_HSequenceOfReal.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <BRepLib_MakeEdge.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(ShapeUpgrade_SplitSurface,Standard_Transient)
|
||||
|
||||
@@ -79,8 +83,10 @@ void ShapeUpgrade_SplitSurface::Init(const Handle(Geom_Surface)& S)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeUpgrade_SplitSurface::Init(const Handle(Geom_Surface)& S, const Standard_Real UFirst,const Standard_Real ULast,
|
||||
const Standard_Real VFirst, const Standard_Real VLast)
|
||||
void ShapeUpgrade_SplitSurface::Init(const Handle(Geom_Surface)& S,
|
||||
const Standard_Real UFirst, const Standard_Real ULast,
|
||||
const Standard_Real VFirst, const Standard_Real VLast,
|
||||
const Standard_Real theArea)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
|
||||
@@ -92,6 +98,8 @@ void ShapeUpgrade_SplitSurface::Init(const Handle(Geom_Surface)& S, const Standa
|
||||
myNbResultingRow =1;
|
||||
myNbResultingCol =1;
|
||||
|
||||
myArea = theArea;
|
||||
|
||||
Standard_Real U1,U2,V1,V2;
|
||||
mySurface->Bounds(U1,U2,V1,V2);
|
||||
Standard_Real precision = Precision::PConfusion();
|
||||
@@ -116,6 +124,24 @@ void ShapeUpgrade_SplitSurface::Init(const Handle(Geom_Surface)& S, const Standa
|
||||
VF = Max(V1,VFirst);
|
||||
VL = Min(V2,VLast);
|
||||
}
|
||||
|
||||
if (myArea != 0.)
|
||||
{
|
||||
//<myArea> is set and will be used with <myUsize> and <myVsize>
|
||||
//in further computations
|
||||
Standard_Real Umid = (UF + UL)/2, Vmid = (VF + VL)/2;
|
||||
Handle (Geom_RectangularTrimmedSurface) aTrSurf =
|
||||
new Geom_RectangularTrimmedSurface (mySurface, UF, UL, VF, VL);
|
||||
Handle(Geom_Curve) anUiso = aTrSurf->UIso (Umid);
|
||||
Handle(Geom_Curve) aViso = aTrSurf->VIso (Vmid);
|
||||
TopoDS_Edge anEdgeUiso = BRepLib_MakeEdge (anUiso);
|
||||
TopoDS_Edge anEdgeViso = BRepLib_MakeEdge (aViso);
|
||||
GProp_GProps aGprop1, aGprop2;
|
||||
BRepGProp::LinearProperties (anEdgeViso, aGprop1);
|
||||
myUsize = aGprop1.Mass();
|
||||
BRepGProp::LinearProperties (anEdgeUiso, aGprop2);
|
||||
myVsize = aGprop2.Mass();
|
||||
}
|
||||
|
||||
if(UL-UF < precision) {
|
||||
Standard_Real p2 = precision/2.;
|
||||
|
@@ -49,7 +49,10 @@ public:
|
||||
Standard_EXPORT void Init (const Handle(Geom_Surface)& S);
|
||||
|
||||
//! Initializes with single supporting surface with bounding parameters.
|
||||
Standard_EXPORT void Init (const Handle(Geom_Surface)& S, const Standard_Real UFirst, const Standard_Real ULast, const Standard_Real VFirst, const Standard_Real VLast);
|
||||
Standard_EXPORT void Init (const Handle(Geom_Surface)& S,
|
||||
const Standard_Real UFirst, const Standard_Real ULast,
|
||||
const Standard_Real VFirst, const Standard_Real VLast,
|
||||
const Standard_Real theArea = 0.);
|
||||
|
||||
//! Sets U parameters where splitting has to be done
|
||||
Standard_EXPORT void SetUSplitValues (const Handle(TColStd_HSequenceOfReal)& UValues);
|
||||
@@ -109,6 +112,9 @@ protected:
|
||||
Handle(Geom_Surface) mySurface;
|
||||
Standard_Integer myStatus;
|
||||
Handle(ShapeExtend_CompositeSurface) myResSurfaces;
|
||||
Standard_Real myArea;
|
||||
Standard_Real myUsize;
|
||||
Standard_Real myVsize;
|
||||
|
||||
|
||||
private:
|
||||
|
@@ -26,7 +26,9 @@ IMPLEMENT_STANDARD_RTTIEXT(ShapeUpgrade_SplitSurfaceArea,ShapeUpgrade_SplitSurfa
|
||||
ShapeUpgrade_SplitSurfaceArea::ShapeUpgrade_SplitSurfaceArea():
|
||||
ShapeUpgrade_SplitSurface()
|
||||
{
|
||||
myNbParts =1;
|
||||
myNbParts = 1;
|
||||
myUnbSplit = myVnbSplit = -1;
|
||||
myIsSplittingIntoSquares = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -52,12 +54,42 @@ ShapeUpgrade_SplitSurfaceArea::ShapeUpgrade_SplitSurfaceArea():
|
||||
Standard_Real aNbUV = aUSize/aVSize;
|
||||
Handle(TColStd_HSequenceOfReal) aFirstSplit = (aNbUV <1. ? myVSplitValues : myUSplitValues);
|
||||
Handle(TColStd_HSequenceOfReal) aSecondSplit = (aNbUV <1. ? myUSplitValues : myVSplitValues);
|
||||
Standard_Boolean anIsUFirst = (aNbUV > 1.);
|
||||
if(aNbUV<1)
|
||||
aNbUV = 1./aNbUV;
|
||||
|
||||
Standard_Integer nbSplitF = (aNbUV >= myNbParts ? myNbParts : RealToInt(ceil(sqrt(myNbParts*ceil(aNbUV)))));
|
||||
Standard_Integer nbSplitS = (aNbUV >= myNbParts ? 0 : RealToInt(ceil((Standard_Real)myNbParts/(Standard_Real)nbSplitF)));
|
||||
if(nbSplitS ==1)
|
||||
|
||||
Standard_Boolean anIsFixedUVnbSplits = (myUnbSplit > 0 && myVnbSplit > 0);
|
||||
Standard_Integer nbSplitF, nbSplitS;
|
||||
if (myIsSplittingIntoSquares && myNbParts > 0)
|
||||
{
|
||||
if (!anIsFixedUVnbSplits) //(myUnbSplit <= 0 || myVnbSplit <= 0)
|
||||
{
|
||||
Standard_Real aSquareSize = Sqrt (myArea / myNbParts);
|
||||
myUnbSplit = (Standard_Integer)(myUsize / aSquareSize);
|
||||
myVnbSplit = (Standard_Integer)(myVsize / aSquareSize);
|
||||
if (myUnbSplit == 0)
|
||||
myUnbSplit = 1;
|
||||
if (myVnbSplit == 0)
|
||||
myVnbSplit = 1;
|
||||
}
|
||||
|
||||
if (anIsUFirst)
|
||||
{
|
||||
nbSplitF = myUnbSplit;
|
||||
nbSplitS = myVnbSplit;
|
||||
}
|
||||
else
|
||||
{
|
||||
nbSplitF = myVnbSplit;
|
||||
nbSplitS = myUnbSplit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nbSplitF = (aNbUV >= myNbParts ? myNbParts : RealToInt(ceil(sqrt(myNbParts*ceil(aNbUV)))));
|
||||
nbSplitS = (aNbUV >= myNbParts ? 0 : RealToInt(ceil((Standard_Real)myNbParts/(Standard_Real)nbSplitF)));
|
||||
}
|
||||
if(nbSplitS ==1 && !anIsFixedUVnbSplits)
|
||||
nbSplitS++;
|
||||
if(!nbSplitF)
|
||||
return;
|
||||
|
@@ -40,6 +40,17 @@ public:
|
||||
//! Set number of split for surfaces
|
||||
Standard_Integer& NbParts();
|
||||
|
||||
//! Set splitting mode
|
||||
//! If the mode is "splitting into squares",
|
||||
//! the face is splitted approximately into <myNbParts> parts,
|
||||
//! the parts are similar to squares in 2D.
|
||||
void SetSplittingIntoSquares(const Standard_Boolean theIsSplittingIntoSquares);
|
||||
|
||||
//! Set fixed numbers of splits in U and V directions.
|
||||
//! Only for "Splitting Into Squares" mode
|
||||
void SetNumbersUVSplits(const Standard_Integer theNbUsplits,
|
||||
const Standard_Integer theNbVsplits);
|
||||
|
||||
Standard_EXPORT virtual void Compute (const Standard_Boolean Segment = Standard_True) Standard_OVERRIDE;
|
||||
|
||||
|
||||
@@ -56,6 +67,9 @@ private:
|
||||
|
||||
|
||||
Standard_Integer myNbParts;
|
||||
Standard_Integer myUnbSplit;
|
||||
Standard_Integer myVnbSplit;
|
||||
Standard_Boolean myIsSplittingIntoSquares;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -16,4 +16,16 @@ inline Standard_Integer& ShapeUpgrade_SplitSurfaceArea::NbParts()
|
||||
return myNbParts;
|
||||
}
|
||||
|
||||
inline void ShapeUpgrade_SplitSurfaceArea::SetSplittingIntoSquares(const Standard_Boolean theIsSplittingIntoSquares)
|
||||
{
|
||||
myIsSplittingIntoSquares = theIsSplittingIntoSquares;
|
||||
}
|
||||
|
||||
inline void ShapeUpgrade_SplitSurfaceArea::SetNumbersUVSplits(const Standard_Integer theNbUsplits,
|
||||
const Standard_Integer theNbVsplits)
|
||||
{
|
||||
myUnbSplit = theNbUsplits;
|
||||
myVnbSplit = theNbVsplits;
|
||||
if (myUnbSplit > 0 && myVnbSplit > 0)
|
||||
myNbParts = myUnbSplit * myVnbSplit;
|
||||
}
|
||||
|
Reference in New Issue
Block a user