1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

Compare commits

..

3 Commits

Author SHA1 Message Date
vmigunov
a0c6a637fa 0023860: Bad memory access intersecting two nearly coincident cylindrical faces
Test of 2 nearly coincident cylindrical faces intersection is added
2022-08-12 12:29:03 +03:00
mzernova
81d569625e 0033084: Visualization - Cylindrical prism is selectable only by its base when extruded in some directions
Fixed bounding boxes for Select3D_SensitiveCylinder.

Added display of Select3D_SensitiveCylinder presentation using the "vsensdis" command.
Added test vselect/bugs/bug33084.
2022-08-04 17:50:46 +03:00
ngavrilo
6072d3093c 0032992: Visualization - Font_TextFormatter should wrap words when possible 2022-08-02 17:13:03 +03:00
6 changed files with 102 additions and 10 deletions

View File

@@ -103,7 +103,7 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c
"-na - disables the approximation of the section curves.\n",
__FILE__, bsection, g);
//
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2] "
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2] [-noapprox] "
"[-p u1 v1 u2 v2 (to add start points] [-v (for extended output)]",
__FILE__, bopcurves, g);
theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-c] [-ni] [-ai]",
@@ -544,7 +544,7 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
const char** a)
{
if (n<3) {
di << "Usage: bopcurves F1 F2 [-2d/-2d1/-2d2] "
di << "Usage: bopcurves F1 F2 [-2d/-2d1/-2d2] [-noapprox] "
"[-p u1 v1 u2 v2 (to add start points] [-v (for extended output)]\n";
return 1;
}
@@ -597,6 +597,9 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
else if (!strcasecmp(a[i],"-2d2")) {
aToApproxC2dOnS2 = Standard_True;
}
else if (!strcasecmp(a[i],"-noapprox")) {
aToApproxC3d = Standard_False;
}
else if (!strcasecmp(a[i],"-p")) {
IntSurf_PntOn2S aPt;
const Standard_Real aU1 = Draw::Atof(a[++i]);

View File

@@ -60,6 +60,7 @@ Font_TextFormatter::Font_TextFormatter()
myAlignY (Graphic3d_VTA_TOP),
myTabSize (8),
myWrappingWidth (0.0f),
myIsWordWrapping (true),
myLastSymbolWidth (0.0f),
myMaxSymbolWidth (0.0f),
//
@@ -249,6 +250,7 @@ void Font_TextFormatter::Format()
}
}
Standard_Utf32Char aCharPrev = 0;
for (Font_TextFormatter::Iterator aFormatterIt(*this);
aFormatterIt.More(); aFormatterIt.Next())
{
@@ -269,12 +271,30 @@ void Font_TextFormatter::Format()
Font_Rect aBndBox;
GlyphBoundingBox (aRectIter, aBndBox);
const Standard_ShortReal aNextXPos = aBndBox.Right - BottomLeft (aFirstCornerId).x();
if (aNextXPos > aMaxLineWidth) // wrap the line and do processing of the symbol
Standard_Boolean isCurWordFits = true;
if(myIsWordWrapping && IsSeparatorSymbol(aCharPrev))
{
for (Font_TextFormatter::Iterator aWordIt = aFormatterIt; aWordIt.More(); aWordIt.Next())
{
if (IsSeparatorSymbol(aWordIt.Symbol()))
{
break;
}
float aWordWidthPx = myCorners[aWordIt.SymbolPosition()].x() - myCorners[aRectIter].x();
if (aNextXPos + aWordWidthPx > aMaxLineWidth)
{
isCurWordFits = false;
break;
}
}
}
if (aNextXPos > aMaxLineWidth || !isCurWordFits) // wrap the line and do processing of the symbol
{
const Standard_Integer aLastRect = aRectIter - 1; // last rect on current line
newLine (aLastRect, aMaxLineWidth);
}
}
aCharPrev = aCharThis;
}
myBndWidth = aMaxLineWidth;

View File

@@ -220,6 +220,12 @@ public:
//! Returns text maximum width, zero means that the text is not bounded by width
Standard_ShortReal Wrapping() const { return myWrappingWidth; }
//! returns TRUE when trying not to break words when wrapping text
Standard_Boolean WordWrapping () const { return myIsWordWrapping; }
//! returns TRUE when trying not to break words when wrapping text
void SetWordWrapping (const Standard_Boolean theIsWordWrapping) { myIsWordWrapping = theIsWordWrapping; }
//! @return width of formatted text.
inline Standard_ShortReal ResultWidth() const
{
@@ -274,6 +280,14 @@ public:
return Standard_False;
}
//! Returns true if the symbol separates words when wrapping is enabled
static Standard_Boolean IsSeparatorSymbol (const Standard_Utf32Char& theSymbol)
{
return theSymbol == '\x0A' // new line
|| theSymbol == ' ' // space
|| theSymbol == '\x09'; // tab
}
DEFINE_STANDARD_RTTIEXT (Font_TextFormatter, Standard_Transient)
protected: //! @name class auxiliary methods
@@ -288,6 +302,7 @@ protected: //! @name configuration
Graphic3d_VerticalTextAlignment myAlignY; //!< vertical alignment style
Standard_Integer myTabSize; //!< horizontal tabulation width (number of space symbols)
Standard_ShortReal myWrappingWidth; //!< text is wrapped by the width if defined (more 0)
Standard_Boolean myIsWordWrapping; //!< if TRUE try not to break words when wrapping text (true by default)
Standard_ShortReal myLastSymbolWidth; //!< width of the last symbol
Standard_ShortReal myMaxSymbolWidth; //!< maximum symbol width of the formatter string

View File

@@ -2500,6 +2500,11 @@ static int VDrawText (Draw_Interpretor& theDI,
}
aTextFormatter->SetWrapping ((Standard_ShortReal)Draw::Atof(theArgVec[++anArgIt]));
}
else if (aParam == "-wordwrapping")
{
const bool isWordWrapping = Draw::ParseOnOffNoIterator(theArgsNb, theArgVec, anArgIt);
aTextFormatter->SetWordWrapping(isWordWrapping);
}
else if (aParam == "-aspect"
&& anArgIt + 1 < theArgsNb)
{
@@ -6925,6 +6930,7 @@ vdrawtext name text
[-zoom {0|1}]=0
[-height height]=16
[-wrapping width]=40
[-wordwrapping {0|1}]=1
[-aspect {regular|bold|italic|boldItalic}]=regular
[-font font]=Times
[-2d] [-perspos {X Y Z}]={0 0 0}

View File

@@ -0,0 +1,39 @@
puts "================================================="
puts "0023860: Bad memory access intersecting two nearly coincident cylindrical faces"
puts "================================================="
puts ""
cylinder c1 1031.3339148728076 -113.25868616662650 56.152387686082520 \
-0.86602540378443815 0.50000000000000089 0.00000000000000000 \
-0.50000000000000089 -0.86602540378443815 0.00000000000000000 \
76.499999999999986
cylinder c2 1017.0706583606553 -103.24955863669388 56.152387686082548 \
0.86602540378443915 -0.49999999999999933 0.00000000000000000 \
0.49999999999999933 0.86602540378443915 0.00000000000000000 \
76.499999999999986
mkface f1 c1
mkface f2 c2
set curves_found [lindex [split [bopcurves f1 f2 -2d -noapprox] "\n"] 1]
if { $curves_found != "2 curve(s) found." } {
puts "Error wrong curves number"
}
smallview
donly c_1 c_2
fit
xwd ${imagedir}/${casename}_1.png
set lines [split [dump c_1] "\n"]
if { [lindex $lines 4] != " Origin :1031.71804748645, -112.593348962955, -20.34375449469 " ||
[lindex $lines 5] != " Axis :-0.866025403784438, 0.500000000000001, 0 " } {
puts "Error: wrong first curve"
}
set lines [split [dump c_2] "\n"]
if { [lindex $lines 4] != " Origin :1031.71804748645, -112.593348962957, 132.648529866855 " ||
[lindex $lines 5] != " Axis :-0.866025403784438, 0.500000000000001, 0 "} {
puts "Error: wrong second curve"
}

View File

@@ -4,21 +4,30 @@ puts ""
puts "==========="
pload MODELING VISUALIZATION
vinit View1
vinit View1 -width 500
vclear
vaxo
box b1 10 0 360 10 180 40
box b1 10 0 460 10 180 40
vdisplay b1
vdrawtext t1 "Top text on plane yOz\n(not wrapped)" -pos 10 5 400 -color green -plane 1 0 0 0 1 0 -valign top -font SansFont -zoom 1
vdrawtext t1 "Top text on plane yOz\n(not wrapped)" -pos 10 5 500 -color green -plane 1 0 0 0 1 0 -valign top -font SansFont -zoom 1
box b2 10 0 240 10 130 60
box b2 10 0 340 10 130 60
vdisplay b2
vdrawtext t2 "Top text on plane yOz\n(wrapping=120)" -pos 10 5 300 -color green -wrapping 120 -plane 1 0 0 0 1 0 -valign top -font SansFont -zoom 1
vdrawtext t2 "Top text on plane yOz\n(wrapping=120)" -pos 10 5 400 -color green -wrapping 120 -plane 1 0 0 0 1 0 -valign top -font SansFont -zoom 1
box b3 10 0 60 10 60 150
box b3 10 0 160 10 60 150
vdisplay b3
vdrawtext t3 "Top text on plane yOz\n(wrapping=50)" -pos 10 5 200 -color green -wrapping 50 -plane 1 0 0 0 1 0 -valign top -font SansFont -zoom 1
vdrawtext t3 "Top text on plane yOz\n(wrapping=50)" -pos 10 5 300 -color green -wrapping 50 -plane 1 0 0 0 1 0 -valign top -font SansFont -zoom 1
box b4 10 200 400 10 130 100
vdisplay b4
vdrawtext t4 "Top text on plane yOz\n(wrapping=120, word wrapping disabled)" -pos 10 205 500 -color green -wrapping 120 -plane 1 0 0 0 1 0 -valign top -font SansFont -zoom 1 -wordwrapping 0
box b5 10 200 160 10 60 200
vdisplay b5
vdrawtext t5 "Top text on plane yOz\n(wrapping=50, word wrapping disabled)" -pos 10 205 350 -color green -wrapping 50 -plane 1 0 0 0 1 0 -valign top -font SansFont -zoom 1 -wordwrapping 0
vright
vfit