1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

Compare commits

...

5 Commits

Author SHA1 Message Date
ink
18b05637bd 0026411: Necessary to improve XCAF to store and querying GD&T data. 2015-08-18 12:50:58 +03:00
isk
59b82b1526 GetFont method at Graphic3d_AspectText3d is added. 2015-06-25 12:59:59 +03:00
isk
aae09937f1 0026343: Visualization - Zoom persistent text with 3D orientation 2015-06-23 23:06:17 +03:00
isk
ae2ec4761a 0026361: Visualization - move OpenGl_TextFormatter to Font_TextFormatter
for usage without OpenGL.
Split OpenGl_TextFormatter on Font_TextFormatter and OpenGl_TextBuilder.
Font_TextFormatter can format a text independetly of OpenGl now.
OpenGl_TextBuilder generates primitive array required for rendering text
using OpenGl_Font instance.
2015-06-23 22:43:45 +03:00
vpa
50f75c7c72 0026304: Visualization - wrong calculation of point in SelectMgr_RectangularFrustum::DetectedPoint 2015-06-22 16:06:59 +03:00
71 changed files with 6401 additions and 364 deletions

View File

@@ -402,6 +402,7 @@ p VrmlAPI
p VrmlConverter
p VrmlData
p XCAFApp
p XCAFDimTolObjects
p XCAFDoc
p XCAFDrivers
p XCAFPrs
@@ -481,4 +482,4 @@ p IVtkVTK
p IVtkTools
t TKIVtk
p IVtkDraw
t TKIVtkDraw
t TKIVtkDraw

View File

@@ -31,10 +31,10 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject)
//purpose :
//=======================================================================
AIS_TextLabel::AIS_TextLabel()
: myText ("?"),
myPosition (0.0, 0.0, 0.0),
myFont ("Courier"),
myFontAspect (Font_FA_Regular)
: myText ("?"),
myFont ("Courier"),
myFontAspect (Font_FA_Regular),
myHasOrientation3D (Standard_False)
{
myDrawer->SetTextAspect (new Prs3d_TextAspect());
@@ -76,7 +76,7 @@ void AIS_TextLabel::SetText (const TCollection_ExtendedString& theText)
//=======================================================================
void AIS_TextLabel::SetPosition (const gp_Pnt& thePosition)
{
myPosition = thePosition;
myOrientation3D.SetLocation (thePosition);
}
//=======================================================================
@@ -143,6 +143,43 @@ void AIS_TextLabel::SetFont (Standard_CString theFont)
myDrawer->TextAspect()->SetFont (myFont.ToCString());
}
//=======================================================================
//function : Set3dOrientation
//purpose :
//=======================================================================
void AIS_TextLabel::SetOrientation3D (const gp_Ax2& theOrientation)
{
myHasOrientation3D = Standard_True;
myOrientation3D = theOrientation;
}
//=======================================================================
//function : Position
//purpose :
//=======================================================================
const gp_Pnt& AIS_TextLabel::Position() const
{
return myOrientation3D.Location();
}
//=======================================================================
//function : Orientation3D
//purpose :
//=======================================================================
const gp_Ax2& AIS_TextLabel::Orientation3D() const
{
return myOrientation3D;
}
//=======================================================================
//function : HasOrientation3D()
//purpose :
//=======================================================================
Standard_Boolean AIS_TextLabel::HasOrientation3D() const
{
return myHasOrientation3D;
}
//=======================================================================
//function : Compute
//purpose :
@@ -156,7 +193,16 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePr
case 0:
{
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
Prs3d_Text::Draw (thePrs, anAsp, myText, myPosition);
if (myHasOrientation3D)
{
Prs3d_Text::Draw (thePrs, anAsp, myText, myOrientation3D);
}
else
{
Prs3d_Text::Draw (thePrs, anAsp, myText, Position());
}
break;
}
}
@@ -174,7 +220,7 @@ void AIS_TextLabel::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
case 0:
{
Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner (this, 10);
Handle(Select3D_SensitivePoint) aSensitivePoint = new Select3D_SensitivePoint (anEntityOwner, myPosition);
Handle(Select3D_SensitivePoint) aSensitivePoint = new Select3D_SensitivePoint (anEntityOwner, Position());
theSelection->Add (aSensitivePoint);
break;
}

View File

@@ -18,6 +18,7 @@
#include <AIS_InteractiveObject.hxx>
#include <gp_Pnt.hxx>
#include <gp_Ax2.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Font_FontAspect.hxx>
@@ -64,6 +65,18 @@ public:
//! Setup font.
Standard_EXPORT void SetFont (Standard_CString theFont);
//! Setup orientation 3D.
Standard_EXPORT void SetOrientation3D (const gp_Ax2& theOrientation);
//! Returns position.
Standard_EXPORT const gp_Pnt& Position() const;
//! Returns orientation 3D.
Standard_EXPORT const gp_Ax2& Orientation3D() const;
//! Returns true if current text placement in 3D.
Standard_EXPORT Standard_Boolean HasOrientation3D() const;
private:
//! Compute
@@ -78,9 +91,10 @@ private:
protected:
TCollection_ExtendedString myText;
gp_Pnt myPosition;
TCollection_AsciiString myFont;
Font_FontAspect myFontAspect;
gp_Ax2 myOrientation3D;
Standard_Boolean myHasOrientation3D;
public:

View File

@@ -7,3 +7,5 @@ Font_FTLibrary.hxx
Font_FTLibrary.cxx
Font_NListOfSystemFont.hxx
Font_NameOfFont.hxx
Font_TextFormatter.hxx
Font_TextFormatter.cxx

View File

@@ -15,6 +15,8 @@
#include <Font_FTFont.hxx>
#include <Font_FontMgr.hxx>
#include <Font_TextFormatter.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
@@ -257,3 +259,25 @@ float Font_FTFont::AdvanceY (const Standard_Utf32Char theUCharNext)
}
return fromFTPoints<float> (myKernAdvance.y + myFTFace->glyph->advance.y);
}
// =======================================================================
// function : BoundingBox
// purpose :
// =======================================================================
Font_FTFont::Rect Font_FTFont::BoundingBox (const NCollection_String& theString,
const Graphic3d_HorizontalTextAlignment theAlignX,
const Graphic3d_VerticalTextAlignment theAlignY)
{
Font_TextFormatter aFormatter;
aFormatter.SetupAlignment (theAlignX, theAlignY);
aFormatter.Reset();
aFormatter.Append (theString, *this);
aFormatter.Format();
Rect aBndBox;
aFormatter.BndBox (aBndBox);
return aBndBox;
}

View File

@@ -16,11 +16,13 @@
#ifndef _Font_FTFont_H__
#define _Font_FTFont_H__
#include <NCollection_Vec2.hxx>
#include <NCollection_String.hxx>
#include <Font_FTLibrary.hxx>
#include <Image_PixMap.hxx>
#include <Font_FontAspect.hxx>
#include <Font_FTLibrary.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Image_PixMap.hxx>
#include <NCollection_String.hxx>
#include <NCollection_Vec2.hxx>
//! Wrapper over FreeType font.
//! Notice that this class uses internal buffers for loaded glyphs
@@ -178,6 +180,15 @@ public:
theRect.Bottom = float(myFTFace->glyph->bitmap_top - (int )aBitmap.rows);
}
//! Computes bounding box of the given text using plain-text formatter (Font_TextFormatter).
//! Note that bounding box takes into account text alignments. It can have negative coordinates.
//! The width and height easy to get by the following formulas:
//! Width = Rect.Right - Rect.Left;
//! Height = Rect.Top - Rect.Bottom;
Standard_EXPORT Rect BoundingBox (const NCollection_String& theString,
const Graphic3d_HorizontalTextAlignment theAlignX,
const Graphic3d_VerticalTextAlignment theAlignY);
protected:
//! Convert value to 26.6 fixed-point format for FT library API.

View File

@@ -13,18 +13,14 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_TextFormatter.hxx>
#include <OpenGl_VertexBufferCompat.hxx>
#include <cmath>
#include <Font_TextFormatter.hxx>
namespace
{
//! Auxiliary function to translate rectangle by the vector.
inline void move (Font_FTFont::Rect& theRect,
const OpenGl_Vec2& theVec)
inline void move (Font_FTFont::Rect& theRect,
const NCollection_Vec2<Standard_ShortReal>& theVec)
{
theRect.Left += theVec.x();
theRect.Right += theVec.x();
@@ -33,41 +29,27 @@ namespace
}
//! Auxiliary function to translate rectangles by the vector.
inline void move (NCollection_Vector<OpenGl_Font::Tile>& theRects,
const OpenGl_Vec2& theMoveVec,
Standard_Integer theCharLower,
const Standard_Integer theCharUpper)
inline void move (NCollection_Vector<Font_FTFont::Rect>& theRects,
const NCollection_Vec2<Standard_ShortReal>& theMoveVec,
Standard_Integer theCharLower,
const Standard_Integer theCharUpper)
{
for(; theCharLower <= theCharUpper; ++theCharLower)
{
Font_FTFont::Rect& aRect = theRects.ChangeValue (theCharLower).px;
Font_FTFont::Rect& aRect = theRects.ChangeValue (theCharLower);
move (aRect, theMoveVec);
}
}
//! Auxiliary function to translate rectangles in horizontal direction.
/*inline void moveX (NCollection_Vector<OpenGl_Font::Tile>& theRects,
const Standard_ShortReal theMoveVec,
Standard_Integer theCharLower,
const Standard_Integer theCharUpper)
{
for (; theCharLower <= theCharUpper; ++theCharLower)
{
Font_FTFont::Rect& aRect = theRects.ChangeValue (theCharLower).px;
aRect.Left += theMoveVec;
aRect.Right += theMoveVec;
}
}*/
//! Auxiliary function to translate rectangles in vertical direction.
inline void moveY (NCollection_Vector<OpenGl_Font::Tile>& theRects,
inline void moveY (NCollection_Vector<Font_FTFont::Rect>& theRects,
const Standard_ShortReal theMoveVec,
Standard_Integer theCharLower,
const Standard_Integer theCharUpper)
{
for(; theCharLower <= theCharUpper; ++theCharLower)
{
Font_FTFont::Rect& aRect = theRects.ChangeValue (theCharLower).px;
Font_FTFont::Rect& aRect = theRects.ChangeValue (theCharLower);
aRect.Top += theMoveVec;
aRect.Bottom += theMoveVec;
}
@@ -76,23 +58,24 @@ namespace
//! Apply floor to vector components.
//! @param theVec - vector to change (by reference!)
//! @return modified vector
inline OpenGl_Vec2& floor (OpenGl_Vec2& theVec)
inline NCollection_Vec2<Standard_ShortReal>& floor (NCollection_Vec2<Standard_ShortReal>& theVec)
{
theVec.x() = std::floor (theVec.x());
theVec.y() = std::floor (theVec.y());
return theVec;
}
};
}
IMPLEMENT_STANDARD_HANDLE (OpenGl_TextFormatter, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_TextFormatter, Standard_Transient)
IMPLEMENT_STANDARD_HANDLE (Font_TextFormatter, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(Font_TextFormatter, Standard_Transient)
// =======================================================================
// function : OpenGl_TextFormatter
// function : Font_TextFormatter
// purpose :
// =======================================================================
OpenGl_TextFormatter::OpenGl_TextFormatter()
Font_TextFormatter::Font_TextFormatter()
: myAlignX (Graphic3d_HTA_LEFT),
myAlignY (Graphic3d_VTA_TOP),
myTabSize (8),
@@ -121,8 +104,8 @@ OpenGl_TextFormatter::OpenGl_TextFormatter()
// function : SetupAlignment
// purpose :
// =======================================================================
void OpenGl_TextFormatter::SetupAlignment (const Graphic3d_HorizontalTextAlignment theAlignX,
const Graphic3d_VerticalTextAlignment theAlignY)
void Font_TextFormatter::SetupAlignment (const Graphic3d_HorizontalTextAlignment theAlignX,
const Graphic3d_VerticalTextAlignment theAlignY)
{
myAlignX = theAlignX;
myAlignY = theAlignY;
@@ -132,7 +115,7 @@ void OpenGl_TextFormatter::SetupAlignment (const Graphic3d_HorizontalTextAlignme
// function : Reset
// purpose :
// =======================================================================
void OpenGl_TextFormatter::Reset()
void Font_TextFormatter::Reset()
{
myIsFormatted = false;
myString.Clear();
@@ -143,142 +126,12 @@ void OpenGl_TextFormatter::Reset()
myNewLines.Clear();
}
// =======================================================================
// function : Result
// purpose :
// =======================================================================
void OpenGl_TextFormatter::Result (NCollection_Vector<GLuint>& theTextures,
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > >& theVertsPerTexture,
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > >& theTCrdsPerTexture) const
{
OpenGl_Vec2 aVec (0.0f, 0.0f);
theTextures.Clear();
theVertsPerTexture.Clear();
theTCrdsPerTexture.Clear();
for (Standard_Integer aRectIter = 0; aRectIter < myRectsNb; ++aRectIter)
{
const Font_FTFont::Rect& aRect = myRects.Value (aRectIter).px;
const Font_FTFont::Rect& aRectUV = myRects.Value (aRectIter).uv;
const GLuint aTexture = myRects.Value (aRectIter).texture;
Standard_Integer aListId = 0;
for (aListId = 0; aListId < theTextures.Length(); ++aListId)
{
if (theTextures.Value (aListId) == aTexture)
{
break;
}
}
if (aListId >= theTextures.Length())
{
theTextures.Append (aTexture);
theVertsPerTexture.Append (new NCollection_Vector<OpenGl_Vec2>());
theTCrdsPerTexture.Append (new NCollection_Vector<OpenGl_Vec2>());
}
NCollection_Vector<OpenGl_Vec2>& aVerts = *theVertsPerTexture.ChangeValue (aListId);
NCollection_Vector<OpenGl_Vec2>& aTCrds = *theTCrdsPerTexture.ChangeValue (aListId);
// apply floor on position to avoid blurring issues
// due to cross-pixel coordinates
aVerts.Append (floor(aRect.TopRight (aVec)));
aVerts.Append (floor(aRect.TopLeft (aVec)));
aVerts.Append (floor(aRect.BottomLeft (aVec)));
aTCrds.Append (aRectUV.TopRight (aVec));
aTCrds.Append (aRectUV.TopLeft (aVec));
aTCrds.Append (aRectUV.BottomLeft (aVec));
aVerts.Append (floor(aRect.BottomRight (aVec)));
aVerts.Append (floor(aRect.TopRight (aVec)));
aVerts.Append (floor(aRect.BottomLeft (aVec)));
aTCrds.Append (aRectUV.BottomRight (aVec));
aTCrds.Append (aRectUV.TopRight (aVec));
aTCrds.Append (aRectUV.BottomLeft (aVec));
}
}
// =======================================================================
// function : Result
// purpose :
// =======================================================================
void OpenGl_TextFormatter::Result (const Handle(OpenGl_Context)& theCtx,
NCollection_Vector<GLuint>& theTextures,
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theVertsPerTexture,
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theTCrdsPerTexture) const
{
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > > aVertsPerTexture;
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > > aTCrdsPerTexture;
Result (theTextures, aVertsPerTexture, aTCrdsPerTexture);
if (theVertsPerTexture.Length() != theTextures.Length())
{
for (Standard_Integer aTextureIter = 0; aTextureIter < theVertsPerTexture.Length(); ++aTextureIter)
{
theVertsPerTexture.Value (aTextureIter)->Release (theCtx.operator->());
theTCrdsPerTexture.Value (aTextureIter)->Release (theCtx.operator->());
}
theVertsPerTexture.Clear();
theTCrdsPerTexture.Clear();
const bool isNormalMode = theCtx->ToUseVbo();
Handle(OpenGl_VertexBuffer) aVertsVbo, aTcrdsVbo;
while (theVertsPerTexture.Length() < theTextures.Length())
{
if (isNormalMode)
{
aVertsVbo = new OpenGl_VertexBuffer();
aTcrdsVbo = new OpenGl_VertexBuffer();
}
else
{
aVertsVbo = new OpenGl_VertexBufferCompat();
aTcrdsVbo = new OpenGl_VertexBufferCompat();
}
theVertsPerTexture.Append (aVertsVbo);
theTCrdsPerTexture.Append (aTcrdsVbo);
aVertsVbo->Create (theCtx);
aTcrdsVbo->Create (theCtx);
}
}
for (Standard_Integer aTextureIter = 0; aTextureIter < theTextures.Length(); ++aTextureIter)
{
const NCollection_Vector<OpenGl_Vec2>& aVerts = *aVertsPerTexture.Value (aTextureIter);
Handle(OpenGl_VertexBuffer)& aVertsVbo = theVertsPerTexture.ChangeValue (aTextureIter);
if (!aVertsVbo->Init (theCtx, 2, aVerts.Length(), (GLfloat* )NULL)
|| !myVboEditor.Init (theCtx, aVertsVbo))
{
continue;
}
for (Standard_Integer aVertIter = 0; aVertIter < aVerts.Length(); ++aVertIter, myVboEditor.Next())
{
myVboEditor.Value() = aVerts.Value (aVertIter);
}
myVboEditor.Flush();
const NCollection_Vector<OpenGl_Vec2>& aTCrds = *aTCrdsPerTexture.Value (aTextureIter);
Handle(OpenGl_VertexBuffer)& aTCrdsVbo = theTCrdsPerTexture.ChangeValue (aTextureIter);
if (!aTCrdsVbo->Init (theCtx, 2, aVerts.Length(), (GLfloat* )NULL)
|| !myVboEditor.Init (theCtx, aTCrdsVbo))
{
continue;
}
for (Standard_Integer aVertIter = 0; aVertIter < aVerts.Length(); ++aVertIter, myVboEditor.Next())
{
myVboEditor.Value() = aTCrds.Value (aVertIter);
}
myVboEditor.Flush();
}
myVboEditor.Init (NULL, NULL);
}
// =======================================================================
// function : Append
// purpose :
// =======================================================================
void OpenGl_TextFormatter::Append (const Handle(OpenGl_Context)& theCtx,
const NCollection_String& theString,
OpenGl_Font& theFont)
void Font_TextFormatter::Append (const NCollection_String& theString,
Font_FTFont& theFont)
{
if (theString.IsEmpty())
{
@@ -292,8 +145,7 @@ void OpenGl_TextFormatter::Append (const Handle(OpenGl_Context)& theCtx,
int aSymbolsCounter = 0; // special counter to process tabulation symbols
// first pass - render all symbols using associated font on single ZERO baseline
OpenGl_Font::Tile aTile;
memset (&aTile, 0, sizeof(aTile));
Font_FTFont::Rect aRect = {};
for (NCollection_Utf8Iter anIter = theString.Iterator(); *anIter != 0;)
{
const Standard_Utf32Char aCharThis = *anIter;
@@ -328,10 +180,18 @@ void OpenGl_TextFormatter::Append (const Handle(OpenGl_Context)& theCtx,
}
++aSymbolsCounter;
theFont.RenderGlyph (theCtx,
aCharThis, aCharNext,
aTile, myPen);
myRects.Append (aTile);
theFont.RenderGlyph (aCharThis);
theFont.GlyphRect (aRect);
aRect.Top += myPen.y();
aRect.Bottom += myPen.y();
aRect.Left += myPen.x();
aRect.Right += myPen.x();
myPen.x() += theFont.AdvanceX (aCharThis, aCharNext);
myRects.Append (aRect);
++myRectsNb;
}
@@ -341,7 +201,7 @@ void OpenGl_TextFormatter::Append (const Handle(OpenGl_Context)& theCtx,
// function : newLine
// purpose :
// =======================================================================
void OpenGl_TextFormatter::newLine (const Standard_Integer theLastRect)
void Font_TextFormatter::newLine (const Standard_Integer theLastRect)
{
if (myRectLineStart >= myRectsNb)
{
@@ -386,7 +246,7 @@ void OpenGl_TextFormatter::newLine (const Standard_Integer theLastRect)
myRectLineStart = myRectWordStart = theLastRect + 1;
if (myRectLineStart < myRectsNb)
{
myLineLeft = myRects.Value (myRectLineStart).px.Left;
myLineLeft = myRects.Value (myRectLineStart).Left;
}
}
@@ -394,7 +254,7 @@ void OpenGl_TextFormatter::newLine (const Standard_Integer theLastRect)
// function : Format
// purpose :
// =======================================================================
void OpenGl_TextFormatter::Format()
void Font_TextFormatter::Format()
{
if (myRectsNb == 0 || myIsFormatted)
{
@@ -413,6 +273,7 @@ void OpenGl_TextFormatter::Format()
myPenCurrLine = -myAscender;
Standard_Integer aRectIter = 0;
myNewLineNb = 0;
Standard_ShortReal aMaxLineWidth = -1.0f;
for (NCollection_Utf8Iter anIter = myString.Iterator(); *anIter != 0; ++anIter)
{
const Standard_Utf32Char aCharThis = *anIter;
@@ -426,6 +287,16 @@ void OpenGl_TextFormatter::Format()
}
else if (aCharThis == '\x0A') // LF (line feed, new line)
{
// calculate max line width
if (myNewLineNb == 0)
{
aMaxLineWidth = myNewLines.Value(0);
}
else
{
aMaxLineWidth = Max (aMaxLineWidth, myNewLines.Value (myNewLineNb) - myNewLines.Value (myNewLineNb - 1));
}
const Standard_Integer aLastRect = aRectIter - 1; // last rect on current line
newLine (aLastRect);
++myNewLineNb;
@@ -438,12 +309,21 @@ void OpenGl_TextFormatter::Format()
continue;
}
Standard_ShortReal aWidth = myRects.Value (aRectIter).px.Right - myLineLeft;
myBndWidth = Max (myBndWidth, aWidth);
++aRectIter;
}
// If only one line
if (aMaxLineWidth < 0.0f)
{
aMaxLineWidth = myPen.x();
}
else // Consider last line
{
aMaxLineWidth = Max (aMaxLineWidth, myPen.x() - myNewLines.Value (myNewLineNb - 1));
}
myBndWidth = aMaxLineWidth;
// move last line
newLine (myRectsNb - 1);

View File

@@ -13,25 +13,19 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _OpenGl_TextFormatter_H__
#define _OpenGl_TextFormatter_H__
#ifndef Font_TextFormatter_Header
#define Font_TextFormatter_Header
#include <OpenGl_Font.hxx>
#include <OpenGl_VertexBufferEditor.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <NCollection_String.hxx>
#include <Font_FTFont.hxx>
#include <NCollection_Vector.hxx>
//! This class intended to prepare formatted text.
class OpenGl_TextFormatter : public Standard_Transient
class Font_TextFormatter : public Standard_Transient
{
public:
//! Default constructor.
Standard_EXPORT OpenGl_TextFormatter();
Standard_EXPORT Font_TextFormatter();
//! Setup alignment style.
Standard_EXPORT void SetupAlignment (const Graphic3d_HorizontalTextAlignment theAlignX,
@@ -41,24 +35,30 @@ public:
Standard_EXPORT void Reset();
//! Render specified text to inner buffer.
Standard_EXPORT void Append (const Handle(OpenGl_Context)& theCtx,
const NCollection_String& theString,
OpenGl_Font& theFont);
Standard_EXPORT void Append (const NCollection_String& theString,
Font_FTFont& theFont);
//! Perform formatting on the buffered text.
//! Should not be called more than once after initialization!
Standard_EXPORT void Format();
//! Retrieve formatting results.
Standard_EXPORT void Result (NCollection_Vector<GLuint>& theTextures,
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > >& theVertsPerTexture,
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > >& theTCrdsPerTexture) const;
//! Returns specific glyph rectangle.
inline const Font_FTFont::Rect& Rect (const Standard_Integer theIndex) const
{
return myRects.Value (theIndex);
}
//! Retrieve formatting results.
Standard_EXPORT void Result (const Handle(OpenGl_Context)& theCtx,
NCollection_Vector<GLuint>& theTextures,
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theVertsPerTexture,
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theTCrdsPerTexture) const;
//! Returns current rendering string.
inline const NCollection_String& String() const
{
return myString;
}
//! Returns tab size.
inline Standard_Integer TabSize() const
{
return myTabSize;
}
//! @return width of formatted text.
inline Standard_ShortReal ResultWidth() const
@@ -106,8 +106,9 @@ protected: //! @name configuration
protected: //! @name input data
NCollection_String myString; //!< currently rendered text
OpenGl_Vec2 myPen; //!< current pen position
NCollection_Vector<OpenGl_Font::Tile>
NCollection_Vec2<Standard_ShortReal>
myPen; //!< current pen position
NCollection_Vector<Font_FTFont::Rect>
myRects; //!< glyphs rectangles
Standard_Integer myRectsNb; //!< rectangles number
NCollection_Vector<Standard_ShortReal>
@@ -116,10 +117,6 @@ protected: //! @name input data
Standard_ShortReal myAscender; //!<
bool myIsFormatted; //!< formatting state
protected:
mutable OpenGl_VertexBufferEditor<OpenGl_Vec2> myVboEditor;
protected: //! @name temporary variables for formatting routines
Standard_Integer myLinesNb; //!< overall (new)lines number (including splitting by width limit)
@@ -132,14 +129,15 @@ protected: //! @name temporary variables for formatting routines
Standard_ShortReal myLineTail;
Standard_ShortReal myBndTop;
Standard_ShortReal myBndWidth;
OpenGl_Vec2 myMoveVec; //!< local variable
NCollection_Vec2<Standard_ShortReal>
myMoveVec; //!< local variable
public:
DEFINE_STANDARD_RTTI(OpenGl_TextFormatter) // Type definition
DEFINE_STANDARD_RTTI(Font_TextFormatter) // Type definition
};
DEFINE_STANDARD_HANDLE(OpenGl_TextFormatter, Standard_Transient)
DEFINE_STANDARD_HANDLE(Font_TextFormatter, Standard_Transient)
#endif // _OpenGl_TextFormatter_H__
#endif // Font_TextFormatter_Header

View File

@@ -103,6 +103,11 @@ is
---AFont may be to take means from User(example "Courier New")
---or Font name defined in Font_NameOfFont(example Font_NOF_ASCII_MONO)
---or use default font("Courier")
GetFont (me) returns AsciiString from TCollection;
---Level: Public
---Purpose: Returns font name.
---C++: return const&
SetSpace ( me : mutable;

View File

@@ -128,6 +128,11 @@ void Graphic3d_AspectText3d::SetFont (const Standard_CString AFont) {
MyFont = aTemp;
}
const TCollection_AsciiString& Graphic3d_AspectText3d::GetFont() const
{
return MyFont;
}
void Graphic3d_AspectText3d::SetSpace (const Standard_Real ASpace) {
MySpace = ASpace;

View File

@@ -46,6 +46,9 @@ deferred class Group from Graphic3d inherits TShared
--
-- Developers are strongly recommended to take all the above into account when filling Graphic3d_Group
-- with aspects and primitives and choose the group usage model beforehand out of application needs.
--
-- Note that some Graphic3d_Group class virtual methods contain only base implementation
-- that is extended by the descendant class in OpenGl package.
---Warning:
---References:
@@ -331,7 +334,7 @@ deferred class Group from Graphic3d inherits TShared
-- AAngle : Orientation of the text
-- (with respect to the horizontal).
---Category: Methods to create Text
Text ( me : mutable;
AText : ExtendedString from TCollection;
APoint : Vertex from Graphic3d;
@@ -353,7 +356,33 @@ deferred class Group from Graphic3d inherits TShared
-- AHta : HTA_LEFT
-- AVta : VTA_BOTTOM
---Category: Methods to create Text
Text (me : mutable;
theTextUtf : CString from Standard;
theOrientation : Ax2 from gp;
theHeight : Real from Standard;
theAngle : PlaneAngle from Quantity;
theTp : TextPath from Graphic3d;
theHTA : HorizontalTextAlignment from Graphic3d;
theVTA : VerticalTextAlignment from Graphic3d;
theToEvalMinMax : Boolean from Standard = Standard_True) is virtual;
---Level: Public
---Purpose: Creates the string <theText> at orientation <theOrientation> in 3D space.
---Category: Methods to create Text
Text (me : mutable;
theText : ExtendedString from TCollection;
theOrientation : Ax2 from gp;
theHeight : Real from Standard;
theAngle : PlaneAngle from Quantity;
theTp : TextPath from Graphic3d;
theHTA : HorizontalTextAlignment from Graphic3d;
theVTA : VerticalTextAlignment from Graphic3d;
theToEvalMinMax : Boolean from Standard = Standard_True) is static;
---Level: Internal
---Purpose: Creates the string <theText> at orientation <theOrientation> in 3D space.
---Category: Methods to create Text
---------------------------------------
---Category: Methods to create Triangle
---------------------------------------

View File

@@ -1138,6 +1138,59 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
theTp, theHta, theVta, theToEvalMinMax);
}
// =======================================================================
// function : Text
// purpose :
// =======================================================================
void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
const gp_Ax2& theOrientation,
const Standard_Real theHeight,
const Quantity_PlaneAngle theAngle,
const Graphic3d_TextPath theTP,
const Graphic3d_HorizontalTextAlignment theHTA,
const Graphic3d_VerticalTextAlignment theVTA,
const Standard_Boolean theToEvalMinMax)
{
const NCollection_String aText ((Standard_Utf16Char*)(theText.ToExtString()));
Text (aText.ToCString(),
theOrientation,
theHeight,
theAngle,
theTP,
theHTA,
theVTA,
theToEvalMinMax);
}
// =======================================================================
// function : Text
// purpose :
// =======================================================================
void Graphic3d_Group::Text (const Standard_CString /*theText*/,
const gp_Ax2& theOrientation,
const Standard_Real /*theHeight*/,
const Quantity_PlaneAngle /*theAngle*/,
const Graphic3d_TextPath /*theTp*/,
const Graphic3d_HorizontalTextAlignment /*theHta*/,
const Graphic3d_VerticalTextAlignment /*theVta*/,
const Standard_Boolean theToEvalMinMax)
{
if (IsDeleted())
{
return;
}
if (theToEvalMinMax)
{
myStructure->CStructure()->Is2dText = Standard_False;
myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (theOrientation.Location().X()),
static_cast<Standard_ShortReal> (theOrientation.Location().Y()),
static_cast<Standard_ShortReal> (theOrientation.Location().Z()),
1.0f));
}
Update();
}
// =======================================================================
// function : Text
// purpose :

View File

@@ -26,8 +26,6 @@ OpenGl_Element.hxx
OpenGl_Element.cxx
OpenGl_Text.hxx
OpenGl_Text.cxx
OpenGl_TextFormatter.hxx
OpenGl_TextFormatter.cxx
OpenGl_PointSprite.hxx
OpenGl_PointSprite.cxx
Handle_OpenGl_PointSprite.hxx
@@ -169,3 +167,5 @@ OpenGl_Sphere.hxx
OpenGl_Sphere.cxx
OpenGl_BackgroundArray.hxx
OpenGl_BackgroundArray.cxx
OpenGl_TextBuilder.hxx
OpenGl_TextBuilder.cxx

View File

@@ -234,3 +234,33 @@ void OpenGl_Font::RenderGlyph (const Handle(OpenGl_Context)& theCtx,
thePen.x() += myFont->AdvanceX (theUChar, theUCharNext);
}
// =======================================================================
// function : RenderGlyph
// purpose :
// =======================================================================
bool OpenGl_Font::RenderGlyph (const Handle(OpenGl_Context)& theCtx,
const Standard_Utf32Char theUChar,
Tile& theGlyph)
{
Standard_Integer aTileId = 0;
if (!myGlyphMap.Find (theUChar,aTileId))
{
if (renderGlyph (theCtx, theUChar))
{
aTileId = myLastTileId;
}
else
{
return false;
}
myGlyphMap.Bind (theUChar, aTileId);
}
const OpenGl_Font::Tile& aTile = myTiles.Value (aTileId);
theGlyph.uv = aTile.uv;
theGlyph.texture = aTile.texture;
return true;
}

View File

@@ -128,6 +128,11 @@ public:
Tile& theGlyph,
OpenGl_Vec2& thePen);
//! Render glyph to texture if not already.
Standard_EXPORT bool RenderGlyph (const Handle(OpenGl_Context)& theCtx,
const Standard_Utf32Char theUChar,
Tile& theGlyph);
protected:
//! Render new glyph to the texture.

View File

@@ -232,6 +232,46 @@ void OpenGl_Group::Text (const Standard_CString theTextUtf,
theTp, theHta, theVta, theToEvalMinMax);
}
// =======================================================================
// function : Text
// purpose :
// =======================================================================
void OpenGl_Group::Text (const Standard_CString theTextUtf,
const gp_Ax2& theOrientation,
const Standard_Real theHeight,
const Quantity_PlaneAngle theAngle,
const Graphic3d_TextPath theTp,
const Graphic3d_HorizontalTextAlignment theHTA,
const Graphic3d_VerticalTextAlignment theVTA,
const Standard_Boolean theToEvalMinMax)
{
if (IsDeleted())
{
return;
}
OpenGl_TextParam aParams;
OpenGl_Structure* aStruct = GlStruct();
aParams.Height = int ((theHeight < 2.0) ? aStruct->GlDriver()->DefaultTextHeight() : theHeight);
aParams.HAlign = theHTA;
aParams.VAlign = theVTA;
OpenGl_Text* aText = new OpenGl_Text (theTextUtf, theOrientation, aParams);
AddElement (aText);
Graphic3d_Group::Text (theTextUtf,
theOrientation,
theHeight,
theAngle,
theTp,
theHTA,
theVTA,
theToEvalMinMax);
}
// =======================================================================
// function : UserDraw
// purpose :

View File

@@ -77,6 +77,16 @@ public:
const Graphic3d_VerticalTextAlignment theVta,
const Standard_Boolean theToEvalMinMax);
//! Add text element in 3D space.
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
const gp_Ax2& theOrientation,
const Standard_Real theHeight,
const Quantity_PlaneAngle theAngle,
const Graphic3d_TextPath theTp,
const Graphic3d_HorizontalTextAlignment theHTA,
const Graphic3d_VerticalTextAlignment theVTA,
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
//! Add UserDraw element using obsolete API
Standard_EXPORT virtual void UserDraw (const Standard_Address theObject,
const Standard_Boolean theToEvalMinMax,

View File

@@ -22,6 +22,7 @@
#include <OpenGl_Text.hxx>
#include <OpenGl_Utils.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_View.hxx>
#include <Font_FontMgr.hxx>
#include <TCollection_HAsciiString.hxx>
@@ -146,7 +147,8 @@ OpenGl_Text::OpenGl_Text()
myWinZ (0.0f),
myScaleHeight (1.0f),
myPoint (0.0f, 0.0f, 0.0f),
myIs2d (false)
myIs2d (false),
myHasPlane (false)
{
myParams.Height = 10;
myParams.HAlign = Graphic3d_HTA_LEFT;
@@ -168,11 +170,36 @@ OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
myParams (theParams),
myString (theText),
myPoint (thePoint),
myIs2d (false)
myIs2d (false),
myHasPlane (false)
{
//
}
// =======================================================================
// function : OpenGl_Text
// purpose :
// =======================================================================
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
const gp_Ax2& theOrientation,
const OpenGl_TextParam& theParams)
: myWinX (0.0),
myWinY (0.0),
myWinZ (0.0),
myScaleHeight (1.0),
myExportHeight (1.0),
myParams (theParams),
myString (theText),
myOrientation (theOrientation),
myIs2d (false),
myHasPlane (true)
{
const gp_Pnt& aPoint = theOrientation.Location();
myPoint = OpenGl_Vec3 (static_cast<Standard_ShortReal> (aPoint.X()),
static_cast<Standard_ShortReal> (aPoint.Y()),
static_cast<Standard_ShortReal> (aPoint.Z()));
}
// =======================================================================
// function : SetPosition
// purpose :
@@ -389,6 +416,9 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
aTextAspect, aTextAspect->ShaderProgramRes (aCtx));
}
myOrientationMatrix = theWorkspace->ActiveView()->Camera()->OrientationMatrix();
myProjMatrix.Convert (aCtx->ProjectionState.Current());
// use highlight color or colors from aspect
if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
{
@@ -441,6 +471,16 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx,
const OpenGl_Vec3 theDVec) const
{
OpenGl_Mat4d aModViewMat;
OpenGl_Mat4d aProjectMat;
if (myHasPlane)
{
aProjectMat = myProjMatrix * myOrientationMatrix;
}
else
{
aProjectMat = myProjMatrix;
}
if (myIs2d)
{
@@ -457,14 +497,28 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx,
std::floor (myWinY + theDVec.y()),
myWinZ + theDVec.z(),
OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX),
OpenGl_Mat4d::Map (myProjMatrix),
OpenGl_Mat4d::Map (aProjectMat),
myViewport,
anObjX,
anObjY,
anObjZ);
OpenGl_Utils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
OpenGl_Utils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0);
if (myHasPlane)
{
const gp_Dir& aVectorDir = myOrientation.XDirection();
const gp_Dir& aVectorUp = myOrientation.Direction();
const gp_Dir& aVectorRight = myOrientation.YDirection();
aModViewMat.SetColumn (3, OpenGl_Vec3d (anObjX, anObjY, anObjZ));
aModViewMat.SetColumn (2, OpenGl_Vec3d (aVectorUp.X(), aVectorUp.Y(), aVectorUp.Z()));
aModViewMat.SetColumn (1, OpenGl_Vec3d (aVectorRight.X(), aVectorRight.Y(), aVectorRight.Z()));
aModViewMat.SetColumn (0, OpenGl_Vec3d (aVectorDir.X(), aVectorDir.Y(), aVectorDir.Z()));
}
else
{
OpenGl_Utils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
OpenGl_Utils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0);
}
if (!theTextAspect.IsZoomable())
{
@@ -489,6 +543,9 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx,
theCtx->WorldViewState.SetCurrent<Standard_Real> (aModViewMat);
theCtx->ApplyWorldViewMatrix();
theCtx->ProjectionState.SetCurrent<Standard_Real> (aProjectMat);
theCtx->ApplyProjectionMatrix();
if (!theCtx->ActiveProgram().IsNull())
{
// Upload updated state to shader program
@@ -580,7 +637,10 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
if (!aRequestedFont.IsNull())
{
aFontFt = new Font_FTFont (NULL);
if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight))
// 96 is default resolution (dpi) for display devices like the screen.
// Support of adaptive calculation of the resolution is necessary.
if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight, 96))
{
aFont = new OpenGl_Font (aFontFt, theKey);
if (!aFont->Init (theCtx))
@@ -655,13 +715,23 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
if (myTextures.IsEmpty())
{
OpenGl_TextFormatter aFormatter;
Font_TextFormatter aFormatter;
aFormatter.SetupAlignment (myParams.HAlign, myParams.VAlign);
aFormatter.Reset();
aFormatter.Append (theCtx, myString, *myFont.operator->());
aFormatter.Append (myString, *myFont->FTFont());
aFormatter.Format();
aFormatter.Result (theCtx, myTextures, myVertsVbo, myTCrdsVbo);
OpenGl_TextBuilder aBuilder;
aBuilder.Perform (aFormatter,
theCtx,
*myFont.operator->(),
myTextures,
myVertsVbo,
myTCrdsVbo);
aFormatter.BndBox (myBndBox);
}
@@ -680,7 +750,6 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
if (!myIs2d)
{
glGetIntegerv (GL_VIEWPORT, myViewport);
myProjMatrix.Convert (theCtx->ProjectionState.Current());
OpenGl_Utils::Project<Standard_Real> (myPoint.x(),
myPoint.y(),
@@ -824,6 +893,9 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f));
drawText (thePrintCtx, theCtx, theTextAspect);
theCtx->ProjectionState.SetCurrent<Standard_Real> (myProjMatrix);
theCtx->ApplyProjectionMatrix();
#if !defined(GL_ES_VERSION_2_0)
if (theCtx->core11 != NULL)
{

View File

@@ -20,13 +20,15 @@
#include <OpenGl_AspectText.hxx>
#include <OpenGl_TextParam.hxx>
#include <OpenGl_TextFormatter.hxx>
#include <OpenGl_TextBuilder.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <gp_Ax2.hxx>
class Handle(OpenGl_PrinterContext);
//! Text rendering
@@ -40,6 +42,11 @@ public:
const OpenGl_Vec3& thePoint,
const OpenGl_TextParam& theParams);
//! Creates new text in 3D space.
Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
const gp_Ax2& theOrientation,
const OpenGl_TextParam& theParams);
//! Setup new string and position
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
const Standard_Utf8Char* theText,
@@ -139,6 +146,7 @@ protected:
mutable OpenGl_Mat4d myProjMatrix;
mutable OpenGl_Mat4d myModelMatrix;
mutable OpenGl_Mat4d myOrientationMatrix;
mutable GLint myViewport[4];
mutable GLdouble myWinX;
mutable GLdouble myWinY;
@@ -152,6 +160,8 @@ protected:
NCollection_String myString;
OpenGl_Vec3 myPoint;
bool myIs2d;
gp_Ax2 myOrientation; //!< Text orientation in 3D space.
bool myHasPlane; //!< Check if text have orientation in 3D space.
public:

View File

@@ -0,0 +1,217 @@
// Created on: 2015-06-18
// Created by: Ilya SEVRIKOV
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_TextBuilder.hxx>
#include <OpenGl_VertexBufferCompat.hxx>
namespace
{
//! Apply floor to vector components.
//! @param theVec - vector to change (by reference!)
//! @return modified vector
inline OpenGl_Vec2& floor (OpenGl_Vec2& theVec)
{
theVec.x() = std::floor (theVec.x());
theVec.y() = std::floor (theVec.y());
return theVec;
}
};
// =======================================================================
// function : OpenGl_TextBuilder
// purpose :
// =======================================================================
OpenGl_TextBuilder::OpenGl_TextBuilder()
{
//
}
// =======================================================================
// function : createGlyphs
// purpose :
// =======================================================================
void OpenGl_TextBuilder::createGlyphs (const Font_TextFormatter& theFormatter,
const Handle(OpenGl_Context)& theCtx,
OpenGl_Font& theFont,
NCollection_Vector<GLuint>& theTextures,
NCollection_Vector<NCollection_Handle<NCollection_Vector<OpenGl_Vec2> > >& theVertsPerTexture,
NCollection_Vector<NCollection_Handle<NCollection_Vector<OpenGl_Vec2> > >& theTCrdsPerTexture)
{
OpenGl_Vec2 aVec (0.0f, 0.0f);
theTextures.Clear();
theVertsPerTexture.Clear();
theTCrdsPerTexture.Clear();
OpenGl_Font::Tile aTile = {};
OpenGl_Vec2 aPen (0.0f, 0.0f);
Standard_Integer aRectsNb = 0;
Standard_Integer aSymbolsCounter = 0;
for (NCollection_Utf8Iter anIter = theFormatter.String().Iterator(); *anIter != 0;)
{
const Standard_Utf32Char aCharThis = *anIter;
const Standard_Utf32Char aCharNext = *++anIter;
if (aCharThis == '\x0D' // CR (carriage return)
|| aCharThis == '\a' // BEL (alarm)
|| aCharThis == '\f' // FF (form feed) NP (new page)
|| aCharThis == '\b' // BS (backspace)
|| aCharThis == '\v') // VT (vertical tab)
{
continue; // skip unsupported carriage control codes
}
else if (aCharThis == '\x0A') // LF (line feed, new line)
{
aSymbolsCounter = 0;
continue; // will be processed on second pass
}
else if (aCharThis == ' ')
{
++aSymbolsCounter;
aPen.x() += theFont.AdvanceX (' ', aCharNext);
continue;
}
else if (aCharThis == '\t')
{
const Standard_Integer aSpacesNum = (theFormatter.TabSize() - (aSymbolsCounter - 1) % theFormatter.TabSize());
aPen.x() += theFont.AdvanceX (' ', aCharNext) * Standard_ShortReal(aSpacesNum);
aSymbolsCounter += aSpacesNum;
continue;
}
++aSymbolsCounter;
theFont.RenderGlyph (theCtx, aCharThis, aTile);
const Font_FTFont::Rect& aRect = theFormatter.Rect (aRectsNb);
const Font_FTFont::Rect& aRectUV = aTile.uv;
const GLuint aTexture = aTile.texture;
Standard_Integer aListId = 0;
for (aListId = 0; aListId < theTextures.Length(); ++aListId)
{
if (theTextures.Value (aListId) == aTexture)
{
break;
}
}
if (aListId >= theTextures.Length())
{
theTextures.Append (aTexture);
theVertsPerTexture.Append (new NCollection_Vector<OpenGl_Vec2>());
theTCrdsPerTexture.Append (new NCollection_Vector<OpenGl_Vec2>());
}
NCollection_Vector<OpenGl_Vec2>& aVerts = *theVertsPerTexture.ChangeValue (aListId);
NCollection_Vector<OpenGl_Vec2>& aTCrds = *theTCrdsPerTexture.ChangeValue (aListId);
// apply floor on position to avoid blurring issues
// due to cross-pixel coordinates
aVerts.Append (floor(aRect.TopRight (aVec)));
aVerts.Append (floor(aRect.TopLeft (aVec)));
aVerts.Append (floor(aRect.BottomLeft (aVec)));
aTCrds.Append (aRectUV.TopRight (aVec));
aTCrds.Append (aRectUV.TopLeft (aVec));
aTCrds.Append (aRectUV.BottomLeft (aVec));
aVerts.Append (floor(aRect.BottomRight (aVec)));
aVerts.Append (floor(aRect.TopRight (aVec)));
aVerts.Append (floor(aRect.BottomLeft (aVec)));
aTCrds.Append (aRectUV.BottomRight (aVec));
aTCrds.Append (aRectUV.TopRight (aVec));
aTCrds.Append (aRectUV.BottomLeft (aVec));
++aRectsNb;
}
}
// =======================================================================
// function : CreateTextures
// purpose :
// =======================================================================
void OpenGl_TextBuilder::Perform (const Font_TextFormatter& theFormatter,
const Handle_OpenGl_Context& theCtx,
OpenGl_Font& theFont,
NCollection_Vector<GLuint>& theTextures,
NCollection_Vector<Handle_OpenGl_VertexBuffer>& theVertsPerTexture,
NCollection_Vector<Handle_OpenGl_VertexBuffer>& theTCrdsPerTexture)
{
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > > aVertsPerTexture;
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > > aTCrdsPerTexture;
createGlyphs (theFormatter, theCtx, theFont, theTextures, aVertsPerTexture, aTCrdsPerTexture);
if (theVertsPerTexture.Length() != theTextures.Length())
{
for (Standard_Integer aTextureIter = 0; aTextureIter < theVertsPerTexture.Length(); ++aTextureIter)
{
theVertsPerTexture.Value (aTextureIter)->Release (theCtx.operator->());
theTCrdsPerTexture.Value (aTextureIter)->Release (theCtx.operator->());
}
theVertsPerTexture.Clear();
theTCrdsPerTexture.Clear();
const bool isNormalMode = theCtx->ToUseVbo();
Handle(OpenGl_VertexBuffer) aVertsVbo, aTcrdsVbo;
while (theVertsPerTexture.Length() < theTextures.Length())
{
if (isNormalMode)
{
aVertsVbo = new OpenGl_VertexBuffer();
aTcrdsVbo = new OpenGl_VertexBuffer();
}
else
{
aVertsVbo = new OpenGl_VertexBufferCompat();
aTcrdsVbo = new OpenGl_VertexBufferCompat();
}
theVertsPerTexture.Append (aVertsVbo);
theTCrdsPerTexture.Append (aTcrdsVbo);
aVertsVbo->Create (theCtx);
aTcrdsVbo->Create (theCtx);
}
}
for (Standard_Integer aTextureIter = 0; aTextureIter < theTextures.Length(); ++aTextureIter)
{
const NCollection_Vector<OpenGl_Vec2>& aVerts = *aVertsPerTexture.Value (aTextureIter);
Handle(OpenGl_VertexBuffer)& aVertsVbo = theVertsPerTexture.ChangeValue (aTextureIter);
if (!aVertsVbo->Init (theCtx, 2, aVerts.Length(), (GLfloat* )NULL)
|| !myVboEditor.Init (theCtx, aVertsVbo))
{
continue;
}
for (Standard_Integer aVertIter = 0; aVertIter < aVerts.Length(); ++aVertIter, myVboEditor.Next())
{
myVboEditor.Value() = aVerts.Value (aVertIter);
}
myVboEditor.Flush();
const NCollection_Vector<OpenGl_Vec2>& aTCrds = *aTCrdsPerTexture.Value (aTextureIter);
Handle(OpenGl_VertexBuffer)& aTCrdsVbo = theTCrdsPerTexture.ChangeValue (aTextureIter);
if (!aTCrdsVbo->Init (theCtx, 2, aVerts.Length(), (GLfloat* )NULL)
|| !myVboEditor.Init (theCtx, aTCrdsVbo))
{
continue;
}
for (Standard_Integer aVertIter = 0; aVertIter < aVerts.Length(); ++aVertIter, myVboEditor.Next())
{
myVboEditor.Value() = aTCrds.Value (aVertIter);
}
myVboEditor.Flush();
}
myVboEditor.Init (NULL, NULL);
}

View File

@@ -0,0 +1,62 @@
// Created on: 2015-06-18
// Created by: Ilya SEVRIKOV
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef OpenGl_TextBuilder_Header
#define OpenGl_TextBuilder_Header
#include <Font_TextFormatter.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Font.hxx>
#include <OpenGl_VertexBuffer.hxx>
#include <OpenGl_VertexBufferEditor.hxx>
#include <OpenGl_Vec.hxx>
#include <NCollection_Vector.hxx>
#include <NCollection_Handle.hxx>
//! This class generates primitive array required for rendering textured text using OpenGl_Font instance.
class OpenGl_TextBuilder
{
public:
//! Creates empty object.
OpenGl_TextBuilder();
//! Creates texture quads for the given text.
Standard_EXPORT void Perform (const Font_TextFormatter& theFormatter,
const Handle(OpenGl_Context)& theContext,
OpenGl_Font& theFont,
NCollection_Vector<GLuint>& theTextures,
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theVertsPerTexture,
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theTCrdsPerTexture);
protected: //! @name class auxillary methods
Standard_EXPORT void createGlyphs (const Font_TextFormatter& theFormatter,
const Handle(OpenGl_Context)& theCtx,
OpenGl_Font& theFont,
NCollection_Vector<GLuint>& theTextures,
NCollection_Vector< NCollection_Handle < NCollection_Vector <OpenGl_Vec2> > >& theVertsPerTexture,
NCollection_Vector< NCollection_Handle < NCollection_Vector <OpenGl_Vec2> > >& theTCrdsPerTexture);
protected: //! @name class auxillary fields
NCollection_Vector<OpenGl_Font::Tile> myTileRects;
OpenGl_VertexBufferEditor<OpenGl_Vec2> myVboEditor;
};
#endif // OpenGl_TextBuilder_Header

View File

@@ -22,7 +22,8 @@ uses
Pnt from gp,
Drawer from Prs3d,
TextAspect from Prs3d,
ExtendedString from TCollection
ExtendedString from TCollection,
Ax2 from gp
is
Draw(myclass; aPresentation: Presentation from Prs3d;
@@ -36,7 +37,14 @@ is
-- static void Draw (const Handle(Prs3d_Presentation)&
-- aPresentation, const Handle(Prs3d_TextAspect)&
-- anAspect, const TCollection_ExtendedString& aText,
-- const gp_Pnt& AttachmentPoint);
-- const gp_Pnt& AttachmentPoint);
Draw(myclass;
thePresentation : Presentation from Prs3d;
theAspect : TextAspect from Prs3d;
theText : ExtendedString from TCollection;
theOrientation : Ax2 from gp);
---Purpose: Defines the display of the text theText at the orientation 3d space.
Draw(myclass; aPresentation: Presentation from Prs3d;
anAspect: TextAspect from Prs3d;

View File

@@ -31,12 +31,9 @@ void Prs3d_Text::Draw (
Standard_Real x,y,z;
AttachmentPoint.Coord(x,y,z);
// POP Graphic3d_Grup accepte de l'extended
Prs3d_Root::CurrentGroup(aPresentation)->Text(
// TCollection_AsciiString(aText).ToCString(),
aText,
Graphic3d_Vertex(x,y,z),
aText,
Graphic3d_Vertex(x,y,z),
anAspect->Height(),
anAspect->Angle(),
anAspect->Orientation(),
@@ -54,3 +51,22 @@ void Prs3d_Text::Draw (
Prs3d_Text::Draw(aPresentation,aDrawer->TextAspect(),aText,AttachmentPoint);
}
// =======================================================================
// function : Draw
// purpose :
// =======================================================================
void Prs3d_Text::Draw (const Handle(Prs3d_Presentation)& thePresentation,
const Handle(Prs3d_TextAspect)& theAspect,
const TCollection_ExtendedString& theText,
const gp_Ax2& theOrientation)
{
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect(theAspect->Aspect());
Prs3d_Root::CurrentGroup (thePresentation)->Text(theText,
theOrientation,
theAspect->Height(),
theAspect->Angle(),
theAspect->Orientation(),
theAspect->HorizontalJustification(),
theAspect->VerticalJustification());
}

View File

@@ -66,10 +66,10 @@ is
SetVerticalJustification(me: mutable; aJustification: VerticalTextAlignment from Graphic3d);
--- Purpose: Sets the vertical alignment of text.
SetOrientation(me: mutable; anOrientation: TextPath from Graphic3d);
---Purpose: Sets the orientation of text.
---Purpose: Sets the orientation of text.
HorizontalJustification(me) returns HorizontalTextAlignment from Graphic3d;
--- Purpose: Returns the horizontal alignment of the text.
-- The range of values includes:
@@ -87,15 +87,15 @@ is
-- - half
-- - base
-- - bottom
Orientation(me) returns TextPath from Graphic3d;
--- Purpose: Returns the orientation of the text.
-- Text can be displayed in the following directions:
-- - up
-- - down
-- - left, or
-- - right
-- - right
Aspect(me) returns AspectText3d from Graphic3d;
---Purpose: Returns the purely textual attributes used in the display of text.
-- These include:
@@ -112,7 +112,7 @@ fields
myHeight: Real from Standard;
myHorizontalJustification: HorizontalTextAlignment from Graphic3d;
myVerticalJustification: VerticalTextAlignment from Graphic3d;
myOrientation: TextPath from Graphic3d;
myOrientation: TextPath from Graphic3d;
end TextAspect from Prs3d;

View File

@@ -23,7 +23,8 @@ Prs3d_TextAspect::Prs3d_TextAspect ()
myHeight(16.),
myHorizontalJustification(Graphic3d_HTA_LEFT),
myVerticalJustification(Graphic3d_VTA_BOTTOM),
myOrientation(Graphic3d_TP_RIGHT) {
myOrientation(Graphic3d_TP_RIGHT)
{
myTextAspect = new Graphic3d_AspectText3d (
Quantity_Color(Quantity_NOC_YELLOW),

View File

@@ -2024,10 +2024,10 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSe
Standard_Integer i;
for(i=1; i<=DGTLabels.Length(); i++) {
TDF_Label DatumL = DGTLabels.Value(i);
TDF_Label ShapeL;
TDF_LabelSequence ShapeL;
if(!DGTTool->GetRefShapeLabel(DatumL,ShapeL)) continue;
// find target shape
TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL);
TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1));
TopLoc_Location Loc;
TColStd_SequenceOfTransient seqRI;
FindEntities( FP, aShape, Loc, seqRI );
@@ -2105,10 +2105,10 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSe
if(DGTLabels.Length()<=0) return Standard_False;
for(i=1; i<=DGTLabels.Length(); i++) {
TDF_Label DimTolL = DGTLabels.Value(i);
TDF_Label ShapeL;
TDF_LabelSequence ShapeL;
if(!DGTTool->GetRefShapeLabel(DimTolL,ShapeL)) continue;
// find target shape
TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL);
TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1));
TopLoc_Location Loc;
TColStd_SequenceOfTransient seqRI;
FindEntities( FP, aShape, Loc, seqRI );
@@ -2248,7 +2248,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSe
else if(kind<50) { //tolerance
if(kind<35) { // tolerance with datum system
TDF_LabelSequence DatumLabels;
DGTTool->GetDatumTolerLabels(DimTolL,DatumLabels);
DGTTool->GetDatumOfTolerLabels(DimTolL,DatumLabels);
Standard_Integer NbDR = DatumLabels.Length();
Handle(StepDimTol_HArray1OfDatumReference) HADR = new StepDimTol_HArray1OfDatumReference(1,NbDR);
for(Standard_Integer j=1; j<=NbDR; j++) {

View File

@@ -776,7 +776,7 @@ Standard_Real SelectMgr_RectangularFrustum::DistToGeometryCenter (const gp_Pnt&
// =======================================================================
SelectMgr_Vec3 SelectMgr_RectangularFrustum::DetectedPoint (const Standard_Real theDepth) const
{
return myNearPickedPnt + myViewRayDir * theDepth;
return myNearPickedPnt + myViewRayDir.Normalized() * theDepth;
}
// =======================================================================

View File

@@ -1,3 +1,4 @@
XCAFApp
XCAFDimTolObjects
XCAFDoc
XCAFPrs

View File

@@ -2430,6 +2430,12 @@ static int VDrawText (Draw_Interpretor& theDI,
aTextPrs->SetText (aText);
Standard_Boolean aHasPlane = Standard_False;
gp_Dir aNormal;
gp_Dir aDirection;
gp_Pnt aPos;
for (; anArgIt < theArgsNb; ++anArgIt)
{
TCollection_AsciiString aParam (theArgVec[anArgIt]);
@@ -2448,7 +2454,6 @@ static int VDrawText (Draw_Interpretor& theDI,
return 1;
}
gp_Pnt aPos;
aPos.SetX (Draw::Atof (theArgVec[++anArgIt]));
aPos.SetY (Draw::Atof (theArgVec[++anArgIt]));
aPos.SetZ (Draw::Atof (theArgVec[++anArgIt]));
@@ -2616,6 +2621,26 @@ static int VDrawText (Draw_Interpretor& theDI,
aTextPrs->SetFont (theArgVec[anArgIt]);
}
else if (aParam == "-plane")
{
if (anArgIt + 6 >= theArgsNb)
{
std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
return 1;
}
Standard_Real aX = Draw::Atof (theArgVec[++anArgIt]);
Standard_Real aY = Draw::Atof (theArgVec[++anArgIt]);
Standard_Real aZ = Draw::Atof (theArgVec[++anArgIt]);
aNormal.SetCoord (aX, aY, aZ);
aX = Draw::Atof (theArgVec[++anArgIt]);
aY = Draw::Atof (theArgVec[++anArgIt]);
aZ = Draw::Atof (theArgVec[++anArgIt]);
aDirection.SetCoord (aX, aY, aZ);
aHasPlane = Standard_True;
}
else
{
std::cout << "Error: unknown argument '" << aParam << "'\n";
@@ -2623,6 +2648,11 @@ static int VDrawText (Draw_Interpretor& theDI,
}
}
if (aHasPlane)
{
aTextPrs->SetOrientation3D (gp_Ax2 (aPos, aNormal, aDirection));
}
ViewerTest::Display (aName, aTextPrs, Standard_False);
return 0;
}
@@ -6005,6 +6035,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
"\n\t\t: [-aspect {regular|bold|italic|bolditalic}=regular]"
"\n\t\t: [-font font=Times]"
"\n\t\t: [-noupdate]"
"\n\t\t: [-plane NormX NormY NormZ DirX DirY DirZ]"
"\n\t\t: Display text label at specified position.",
__FILE__, VDrawText, group);

View File

@@ -0,0 +1,291 @@
-- Created on: 2015-07-31
-- Created by: data exchange team
-- Copyright (c) 2000-2015 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
package XCAFDimTolObjects
---Purpose:
uses
TCollection,
TColStd,
TopoDS,
gp,
TColgp,
XCAFDoc,
TDocStd
is
enumeration DimensionType is
---Purpose: Defines types of dimension
DimensionType_Location_None,
DimensionType_Location_CurvedDistance,
DimensionType_Location_LinearDistance,
DimensionType_Location_LinearDistance_FromCenterToOuter,
DimensionType_Location_LinearDistance_FromCenterToInner,
DimensionType_Location_LinearDistance_FromOuterToCenter,
DimensionType_Location_LinearDistance_FromOuterToOuter,
DimensionType_Location_LinearDistance_FromOuterToInner,
DimensionType_Location_LinearDistance_FromInnerToCenter,
DimensionType_Location_LinearDistance_FromInnerToOuter,
DimensionType_Location_LinearDistance_FromInnerToInner,
DimensionType_Location_Angular,
DimensionType_Location_Oriented,
DimensionType_Location_WithPath,
DimensionType_Size_CurveLength,
DimensionType_Size_Diameter,
DimensionType_Size_SphericalDiameter,
DimensionType_Size_Radius,
DimensionType_Size_SphericalRadius,
DimensionType_Size_ToroidalMinorDiameter,
DimensionType_Size_ToroidalMajorDiameter,
DimensionType_Size_ToroidalMinorRadius,
DimensionType_Size_ToroidalMajorRadius,
DimensionType_Size_ToroidalHighMajorDiameter,
DimensionType_Size_ToroidalLowMajorDiameter,
DimensionType_Size_ToroidalHighMajorRadius,
DimensionType_Size_ToroidalLowMajorRadius,
DimensionType_Size_Thickness,
DimensionType_Size_Angular,
DimensionType_Size_WithPath
end DimensionType;
enumeration DimensionQualifier is
---Purpose: Defines types of qualifier
DimensionQualifier_None,
DimensionQualifier_Min,
DimensionQualifier_Max,
DimensionQualifier_Avg
end DimensionQualifier;
enumeration DimensionFormVariance is
---Purpose: Defines value of form variance
DimensionFormVariance_None,
DimensionFormVariance_A,
DimensionFormVariance_B,
DimensionFormVariance_C,
DimensionFormVariance_CD,
DimensionFormVariance_D,
DimensionFormVariance_E,
DimensionFormVariance_EF,
DimensionFormVariance_F,
DimensionFormVariance_FG,
DimensionFormVariance_G,
DimensionFormVariance_H,
DimensionFormVariance_JS,
DimensionFormVariance_J,
DimensionFormVariance_K,
DimensionFormVariance_M,
DimensionFormVariance_N,
DimensionFormVariance_P,
DimensionFormVariance_R,
DimensionFormVariance_S,
DimensionFormVariance_T,
DimensionFormVariance_U,
DimensionFormVariance_V,
DimensionFormVariance_X,
DimensionFormVariance_Y,
DimensionFormVariance_Z,
DimensionFormVariance_ZA,
DimensionFormVariance_ZB,
DimensionFormVariance_ZC
end DimensionFormVariance;
enumeration DimensionGrade is
---Purpose: Defines value of grade
DimensionGrade_IT01,
DimensionGrade_IT0,
DimensionGrade_IT1,
DimensionGrade_IT2,
DimensionGrade_IT3,
DimensionGrade_IT4,
DimensionGrade_IT5,
DimensionGrade_IT6,
DimensionGrade_IT7,
DimensionGrade_IT8,
DimensionGrade_IT9,
DimensionGrade_IT10,
DimensionGrade_IT11,
DimensionGrade_IT12,
DimensionGrade_IT13,
DimensionGrade_IT14,
DimensionGrade_IT15,
DimensionGrade_IT16,
DimensionGrade_IT17,
DimensionGrade_IT18
end DimensionGrade;
enumeration GeomToleranceType is
---Purpose: Defines types of geom tolerance
GeomToleranceType_None,
GeomToleranceType_Angularity,
GeomToleranceType_CircularRunout,
GeomToleranceType_CircularityOrRoundness,
GeomToleranceType_Coaxiality,
GeomToleranceType_Concentricity,
GeomToleranceType_Cylindricity,
GeomToleranceType_Flatness,
GeomToleranceType_Parallelism,
GeomToleranceType_Perpendicularity,
GeomToleranceType_Position,
GeomToleranceType_ProfileOfLine,
GeomToleranceType_ProfileOfSurface,
GeomToleranceType_Straightness,
GeomToleranceType_Symmetry,
GeomToleranceType_TotalRunout
end GeomToleranceType;
enumeration GeomToleranceTypeValue is
---Purpose: Defines types of value of tolerane
GeomToleranceTypeValue_None,
GeomToleranceTypeValue_Diameter,
GeomToleranceTypeValue_SphericalDiameter
end GeomToleranceTypeValue;
enumeration GeomToleranceMatReqModif is
---Purpose: Defines types of material requirement
GeomToleranceMatReqModif_None,
GeomToleranceMatReqModif_M,
GeomToleranceMatReqModif_L
end GeomToleranceMatReqModif;
enumeration GeomToleranceZoneModif is
---Purpose: Defines types of zone
GeomToleranceZoneModif_None,
GeomToleranceZoneModif_P,
GeomToleranceZoneModif_NonUniform
end GeomToleranceZoneModif;
enumeration DatumSingleModif is
---Purpose: Defines modifirs
DatumSingleModif_AnyCrossSection,
DatumSingleModif_Any_LongitudinalSection,
DatumSingleModif_Basic,
DatumSingleModif_ContactingFeature,
DatumSingleModif_DegreeOfFreedomConstraintU,
DatumSingleModif_DegreeOfFreedomConstraintV,
DatumSingleModif_DegreeOfFreedomConstraintW,
DatumSingleModif_DegreeOfFreedomConstraintX,
DatumSingleModif_DegreeOfFreedomConstraintY,
DatumSingleModif_DegreeOfFreedomConstraintZ,
DatumSingleModif_DistanceVariable,
DatumSingleModif_FreeState,
DatumSingleModif_LeastMaterialRequirement,
DatumSingleModif_Line,
DatumSingleModif_MajorDiameter,
DatumSingleModif_MaximumMaterialRequirement,
DatumSingleModif_MinorDiameter,
DatumSingleModif_Orientation,
DatumSingleModif_PitchDiameter,
DatumSingleModif_Plane,
DatumSingleModif_Point,
DatumSingleModif_Translation
end DatumSingleModif;
enumeration DatumModifWithValue is
---Purpose: Defines modifirs
DatumModifWithValue_None,
DatumModifWithValue_CircularOrCylindrical,
DatumModifWithValue_Distance,
DatumModifWithValue_Projected,
DatumModifWithValue_Spherical
end DatumModifWithValue;
enumeration DimensionModif is
---Purpose: Defines modifirs
DimensionModif_ControlledRadius,
DimensionModif_Square,
DimensionModif_StatisticalTolerance,
DimensionModif_ContinuousFeature,
DimensionModif_TwoPointSize,
DimensionModif_LocalSizeDefinedBySphere,
DimensionModif_LeastSquaresAssociationCriterion,
DimensionModif_MaximumInscribedAssociation,
DimensionModif_MinimumCircumscribedAssociation,
DimensionModif_CircumferenceDiameter,
DimensionModif_AreaDiameter,
DimensionModif_VolumeDiameter,
DimensionModif_MaximumSize,
DimensionModif_MinimumSize,
DimensionModif_AverageSize,
DimensionModif_MedianSize,
DimensionModif_MidRangeSize,
DimensionModif_RangeOfSizes,
DimensionModif_AnyRestrictedPortionOfFeature,
DimensionModif_AnyCrossSection,
DimensionModif_SpecificFixedCrossSection,
DimensionModif_CommonTolerance,
DimensionModif_FreeStateCondition,
DimensionModif_Between
end DimensionModif;
enumeration GeomToleranceModif is
---Purpose: Defines modifirs
GeomToleranceModif_Any_Cross_Section,
GeomToleranceModif_Common_Zone,
GeomToleranceModif_Each_Radial_Element,
GeomToleranceModif_Free_State,
GeomToleranceModif_Least_Material_Requirement,
GeomToleranceModif_Line_Element,
GeomToleranceModif_Major_Diameter,
GeomToleranceModif_Maximum_Material_Requirement,
GeomToleranceModif_Minor_Diameter,
GeomToleranceModif_Not_Convex,
GeomToleranceModif_Pitch_Diameter,
GeomToleranceModif_Reciprocity_Requirement,
GeomToleranceModif_Separate_Requirement,
GeomToleranceModif_Statistical_Tolerance,
GeomToleranceModif_Tangent_Plane
end GeomToleranceModif;
class DimensionObject;
class GeomToleranceObject;
class DatumObject;
class Tool;
class DimensionObjectSequence instantiates Sequence from TCollection
(DimensionObject from XCAFDimTolObjects);
---Purpose: class for containing Dimension.
class GeomToleranceObjectSequence instantiates Sequence from TCollection
(GeomToleranceObject from XCAFDimTolObjects);
---Purpose: class for containing GeomTolerances.
class DatumObjectSequence instantiates Sequence from TCollection
(DatumObject from XCAFDimTolObjects);
---Purpose: class for containing Datums.
class DimensionModifiersSequence instantiates Sequence from TCollection
(DimensionModif from XCAFDimTolObjects);
---Purpose: class for containing modifiers of Dimension.
class GeomToleranceModifiersSequence instantiates Sequence from TCollection
(GeomToleranceModif from XCAFDimTolObjects);
---Purpose: class for containing modifiers of GeomTolerances.
class DatumModifiersSequence instantiates Sequence from TCollection
(DatumSingleModif from XCAFDimTolObjects);
---Purpose: class for containing modifiers of Datums.
class DataMapOfToleranceDatum instantiates DataMap from TCollection
(GeomToleranceObject from XCAFDimTolObjects,DatumObject from XCAFDimTolObjects,MapTransientHasher from TColStd);
---Purpose:
end XCAFDimTolObjects;

View File

@@ -0,0 +1,63 @@
-- Created on: 2015-07-31
-- Created by: data exchange team
-- Copyright (c) 2000-2015 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class DatumObject from XCAFDimTolObjects inherits Transient from Standard
---Purpose: object to store datum
uses
HAsciiString from TCollection,
DatumModifWithValue from XCAFDimTolObjects,
DatumModifiersSequence from XCAFDimTolObjects,
DatumSingleModif from XCAFDimTolObjects,
Shape from TopoDS
is
Create returns DatumObject from XCAFDimTolObjects;
Create(theObj : DatumObject from XCAFDimTolObjects) returns DatumObject from XCAFDimTolObjects;
---Category: class methods
-- =============
GetName (me) returns HAsciiString from TCollection;
SetName (me : mutable; theTag : HAsciiString from TCollection);
GetModifiers (me) returns DatumModifiersSequence from XCAFDimTolObjects;
SetModifiers (me : mutable; theModifiers : DatumModifiersSequence from XCAFDimTolObjects);
GetModifierWithValue (me; theModifier : out DatumModifWithValue from XCAFDimTolObjects; theValue : out Real from Standard);
SetModifierWithValue (me : mutable; theModifier : DatumModifWithValue from XCAFDimTolObjects; theValue : Real from Standard);
AddModifier (me : mutable; theModifier : DatumSingleModif from XCAFDimTolObjects);
GetDatumTarget (me) returns Shape from TopoDS;
SetDatumTarget (me : mutable; theShape : Shape from TopoDS);
IsDatumTarget (me) returns Boolean from Standard;
fields
myName : HAsciiString from TCollection;
myModifiers : DatumModifiersSequence from XCAFDimTolObjects;
myModifierWithValue : DatumModifWithValue from XCAFDimTolObjects;
myValueOfModifier : Real from Standard;
myDatumTarget : Shape from TopoDS;
end DatumObject;

View File

@@ -0,0 +1,142 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <XCAFDimTolObjects_DatumObject.ixx>
//=======================================================================
//function : XCAFDimTolObjects_DatumObject
//purpose :
//=======================================================================
XCAFDimTolObjects_DatumObject::XCAFDimTolObjects_DatumObject()
{
}
//=======================================================================
//function : XCAFDimTolObjects_DatumObject
//purpose :
//=======================================================================
XCAFDimTolObjects_DatumObject::XCAFDimTolObjects_DatumObject(const Handle(XCAFDimTolObjects_DatumObject)& theObj)
{
myName = theObj->myName;
myModifiers = theObj->myModifiers;
myModifierWithValue = theObj->myModifierWithValue;
myValueOfModifier = theObj->myValueOfModifier;
myDatumTarget = theObj->myDatumTarget;
}
//=======================================================================
//function : GetName
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) XCAFDimTolObjects_DatumObject::GetName() const
{
if(myName.IsNull())
return new TCollection_HAsciiString();
return myName;
}
//=======================================================================
//function : SetName
//purpose :
//=======================================================================
void XCAFDimTolObjects_DatumObject::SetName(const Handle(TCollection_HAsciiString)& theName)
{
myName = theName;
}
//=======================================================================
//function : GetModifiers
//purpose :
//=======================================================================
XCAFDimTolObjects_DatumModifiersSequence XCAFDimTolObjects_DatumObject::GetModifiers() const
{
return myModifiers;
}
//=======================================================================
//function : SetModifiers
//purpose :
//=======================================================================
void XCAFDimTolObjects_DatumObject::SetModifiers(const XCAFDimTolObjects_DatumModifiersSequence& theModifiers)
{
myModifiers = theModifiers;
}
//=======================================================================
//function : SetModifierWithValue
//purpose :
//=======================================================================
void XCAFDimTolObjects_DatumObject::SetModifierWithValue(const XCAFDimTolObjects_DatumModifWithValue theModifier, const Standard_Real theValue)
{
myModifierWithValue = theModifier;
myValueOfModifier = theValue;
}
//=======================================================================
//function : GetModifierWithValue
//purpose :
//=======================================================================
void XCAFDimTolObjects_DatumObject::GetModifierWithValue(XCAFDimTolObjects_DatumModifWithValue& theModifier, Standard_Real& theValue) const
{
theModifier = myModifierWithValue;
theValue = myValueOfModifier;
}
//=======================================================================
//function : AddModifier
//purpose :
//=======================================================================
void XCAFDimTolObjects_DatumObject::AddModifier(const XCAFDimTolObjects_DatumSingleModif theModifier)
{
myModifiers.Append(theModifier);
}
//=======================================================================
//function : GetDatumTarget
//purpose :
//=======================================================================
TopoDS_Shape XCAFDimTolObjects_DatumObject::GetDatumTarget() const
{
return myDatumTarget;
}
//=======================================================================
//function : SetDatumTarget
//purpose :
//=======================================================================
void XCAFDimTolObjects_DatumObject::SetDatumTarget (const TopoDS_Shape& theShape)
{
myDatumTarget = theShape;
}
//=======================================================================
//function : IsDatumTarget
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DatumObject::IsDatumTarget() const
{
return !myDatumTarget.IsNull();
}

View File

@@ -0,0 +1,128 @@
-- Created on: 2015-07-31
-- Created by: data exchange team
-- Copyright (c) 2000-2015 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class DimensionObject from XCAFDimTolObjects inherits Transient from Standard
---Purpose: object to store dimension
uses
HArray1OfReal from TColStd,
DimensionQualifier from XCAFDimTolObjects,
DimensionType from XCAFDimTolObjects,
DimensionFormVariance from XCAFDimTolObjects,
DimensionGrade from XCAFDimTolObjects,
Edge from TopoDS,
Dir from gp,
HArray1OfPnt from TColgp,
DimensionModifiersSequence from XCAFDimTolObjects,
DimensionModif from XCAFDimTolObjects
is
Create returns DimensionObject from XCAFDimTolObjects;
Create(theObj : DimensionObject from XCAFDimTolObjects) returns DimensionObject from XCAFDimTolObjects;
---Category: class methods
-- =============
SetQualifier (me : mutable; theQualifier : DimensionQualifier from XCAFDimTolObjects);
GetQualifier (me) returns DimensionQualifier from XCAFDimTolObjects;
HasQualifier (me) returns Boolean;
SetType (me : mutable; theTyupe : DimensionType from XCAFDimTolObjects);
GetType (me) returns DimensionType from XCAFDimTolObjects;
GetValue (me) returns Real from Standard ;
GetValues (me) returns HArray1OfReal from TColStd ;
SetValue (me : mutable; theValue : Real from Standard );
SetValues (me : mutable; theValue : HArray1OfReal from TColStd );
IsDimWithRange (me) returns Boolean;
SetUpperBound(me : mutable; theUpperBound : Real from Standard);
SetLowerBound(me : mutable; theLowerBound : Real from Standard);
GetUpperBound(me) returns Real from Standard;
GetLowerBound(me) returns Real from Standard;
IsDimWithPlusMinusTolerance (me) returns Boolean;
SetUpperTolValue(me : mutable; theUperTolValue : Real from Standard) returns Boolean from Standard;
SetLowerTolValue(me : mutable; theLowerTolValue : Real from Standard) returns Boolean from Standard;
GetUpperTolValue(me) returns Real from Standard;
GetLowerTolValue(me) returns Real from Standard;
IsDimWithClassOfTolerance (me) returns Boolean;
SetClassOfTolerance(me : mutable; theHole : Boolean from Standard;
theFormVariance : DimensionFormVariance from XCAFDimTolObjects;
theGrade : DimensionGrade from XCAFDimTolObjects);
GetClassOfTolerance(me; theHole : out Boolean from Standard;
theFormVariance : out DimensionFormVariance from XCAFDimTolObjects;
theGrade : out DimensionGrade from XCAFDimTolObjects)
returns Boolean from Standard;
SetNbOfDecimalPlaces(me : mutable; theL : Integer from Standard;
theR : Integer from Standard);
GetNbOfDecimalPlaces(me; theL : out Integer from Standard;
theR : out Integer from Standard);
GetModifiers(me) returns DimensionModifiersSequence from XCAFDimTolObjects;
SetModifiers(me : mutable; theModifiers : DimensionModifiersSequence from XCAFDimTolObjects );
AddModifier(me : mutable; theModifier : DimensionModif from XCAFDimTolObjects);
GetPath(me) returns Edge from TopoDS;
SetPath(me : mutable; thePath : Edge from TopoDS);
GetDirection(me; theDir : out Dir from gp) returns Boolean from Standard;
SetDirection(me : mutable; theDir : Dir from gp)returns Boolean from Standard;
GetPoints(me) returns HArray1OfPnt from TColgp;
SetPoints(me : mutable; thePnts : HArray1OfPnt from TColgp);
fields
myType : DimensionType from XCAFDimTolObjects;
myVal : HArray1OfReal from TColStd;
myQualifier : DimensionQualifier from XCAFDimTolObjects;
myIsHole : Boolean from Standard;
myFormVariance : DimensionFormVariance from XCAFDimTolObjects;
myGrade : DimensionGrade from XCAFDimTolObjects;
myL : Integer from Standard;
myR : Integer from Standard;
myModifiers : DimensionModifiersSequence from XCAFDimTolObjects;
myPath : Edge from TopoDS;
myDir : Dir from gp;
myPnts : HArray1OfPnt from TColgp;
end DimensionObject;

View File

@@ -0,0 +1,430 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <XCAFDimTolObjects_DimensionObject.ixx>
#include <Precision.hxx>
#include <TColgp_HArray1OfPnt.hxx>
//=======================================================================
//function : XCAFDimTolObjects_DimensionObject
//purpose :
//=======================================================================
XCAFDimTolObjects_DimensionObject::XCAFDimTolObjects_DimensionObject()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
XCAFDimTolObjects_DimensionObject::XCAFDimTolObjects_DimensionObject(const Handle(XCAFDimTolObjects_DimensionObject)& theObj)
{
myType = theObj->myType;
myVal = theObj->myVal;
myQualifier = theObj->myQualifier;
myIsHole = theObj->myIsHole;
myFormVariance = theObj->myFormVariance;
myGrade = theObj->myGrade;
myL = theObj->myL;
myR = theObj->myR;
myModifiers = theObj->myModifiers;
myPath = theObj->myPath;
myDir = theObj->myDir;
myPnts = theObj->myPnts;
}
//=======================================================================
//function : SetQualifier
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetQualifier (const XCAFDimTolObjects_DimensionQualifier theQualifier)
{
myQualifier = theQualifier;
}
//=======================================================================
//function : GetQualifier
//purpose :
//=======================================================================
XCAFDimTolObjects_DimensionQualifier XCAFDimTolObjects_DimensionObject::GetQualifier() const
{
return myQualifier;
}
//=======================================================================
//function : HasQualifier
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DimensionObject::HasQualifier() const
{
return (myQualifier != XCAFDimTolObjects_DimensionQualifier_None);
}
//=======================================================================
//function : SetType
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetType (const XCAFDimTolObjects_DimensionType theType)
{
myType = theType;
}
//=======================================================================
//function : GetType
//purpose :
//=======================================================================
XCAFDimTolObjects_DimensionType XCAFDimTolObjects_DimensionObject::GetType() const
{
return myType;
}
//=======================================================================
//function : GetValue
//purpose :
//=======================================================================
Standard_Real XCAFDimTolObjects_DimensionObject::GetValue () const
{
if(!myVal.IsNull() && (myVal->Length() == 1 || myVal->Length() == 3))
{
return myVal->Value(1);
}
return 0;
}
//=======================================================================
//function : GetValues
//purpose :
//=======================================================================
Handle(TColStd_HArray1OfReal) XCAFDimTolObjects_DimensionObject::GetValues () const
{
return myVal;
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetValue (const Standard_Real theValue)
{
myVal = new TColStd_HArray1OfReal(1, 1);
myVal->SetValue(1,theValue);
}
//=======================================================================
//function : SetValues
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetValues (const Handle(TColStd_HArray1OfReal)& theValue)
{
myVal = theValue;
}
//=======================================================================
//function : IsDimWithRange
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DimensionObject::IsDimWithRange() const
{
if (!myVal.IsNull() && myVal->Length() == 2)
return Standard_True;
return Standard_False;
}
//=======================================================================
//function : SetUpperBound
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetUpperBound (const Standard_Real theUpperBound)
{
if(!myVal.IsNull() && myVal->Length() > 1)
myVal->SetValue(2, theUpperBound);
else
{
myVal = new TColStd_HArray1OfReal(1, 2);
myVal->SetValue(1, theUpperBound);
myVal->SetValue(2, theUpperBound);
}
}
//=======================================================================
//function : SetLowerBound
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetLowerBound (const Standard_Real theLowerBound)
{
if(!myVal.IsNull() && myVal->Length() > 1)
myVal->SetValue(1, theLowerBound);
else
{
myVal = new TColStd_HArray1OfReal(1, 2);
myVal->SetValue(2, theLowerBound);
myVal->SetValue(1, theLowerBound);
}
}
//=======================================================================
//function : GetUpperBound
//purpose :
//=======================================================================
Standard_Real XCAFDimTolObjects_DimensionObject::GetUpperBound () const
{
if(!myVal.IsNull() && myVal->Length() == 2)
{
return myVal->Value(2);
}
return 0;
}
//=======================================================================
//function : GetLowerBound
//purpose :
//=======================================================================
Standard_Real XCAFDimTolObjects_DimensionObject::GetLowerBound () const
{
if(!myVal.IsNull() && myVal->Length() == 2)
{
return myVal->Value(1);
}
return 0;
}
//=======================================================================
//function : IsDimWithPlusMinusTolerance
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DimensionObject::IsDimWithPlusMinusTolerance() const
{
return (!myVal.IsNull() && myVal->Length() == 3);
}
//=======================================================================
//function : SetUpperTolValue
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DimensionObject::SetUpperTolValue (const Standard_Real theUperTolValue)
{
if(!myVal.IsNull() && myVal->Length() == 3)
{
myVal->SetValue(3, theUperTolValue);
return Standard_True;
}
else if(!myVal.IsNull() && myVal->Length() == 1)
{
Standard_Real v = myVal->Value(1);
myVal = new TColStd_HArray1OfReal(1, 3);
myVal->SetValue(1, v);
myVal->SetValue(2, theUperTolValue);
myVal->SetValue(3, theUperTolValue);
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : SetLowerTolValue
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DimensionObject::SetLowerTolValue (const Standard_Real theLowerTolValue)
{
if(!myVal.IsNull() && myVal->Length() == 3)
{
myVal->SetValue(2, theLowerTolValue);
return Standard_True;
}
else if(!myVal.IsNull() && myVal->Length() == 1)
{
Standard_Real v = myVal->Value(1);
myVal = new TColStd_HArray1OfReal(1, 3);
myVal->SetValue(1, v);
myVal->SetValue(2, theLowerTolValue);
myVal->SetValue(3, theLowerTolValue);
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GetUpperTolValue
//purpose :
//=======================================================================
Standard_Real XCAFDimTolObjects_DimensionObject::GetUpperTolValue () const
{
if(!myVal.IsNull() && myVal->Length() == 3)
{
return myVal->Value(3);
}
return 0;
}
//=======================================================================
//function : GetLowerTolValue
//purpose :
//=======================================================================
Standard_Real XCAFDimTolObjects_DimensionObject::GetLowerTolValue () const
{
if(!myVal.IsNull() && myVal->Length() == 3)
{
return myVal->Value(2);
}
return 0;
}
//=======================================================================
//function : IsDimWithClassOfTolerance
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DimensionObject::IsDimWithClassOfTolerance() const
{
return (myFormVariance != XCAFDimTolObjects_DimensionFormVariance_None);
}
//=======================================================================
//function : SetClassOfTolerance
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetClassOfTolerance (const Standard_Boolean theHole,
const XCAFDimTolObjects_DimensionFormVariance theFormVariance,
const XCAFDimTolObjects_DimensionGrade theGrade)
{
myIsHole = theHole;
myFormVariance = theFormVariance;
myGrade = theGrade;
}
//=======================================================================
//function : GetClassOfTolerance
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DimensionObject::GetClassOfTolerance (Standard_Boolean& theHole,
XCAFDimTolObjects_DimensionFormVariance& theFormVariance,
XCAFDimTolObjects_DimensionGrade& theGrade) const
{
if(myFormVariance != XCAFDimTolObjects_DimensionFormVariance_None)
{
theHole = myIsHole;
theFormVariance = myFormVariance;
theGrade = myGrade;
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : SetNbOfDecimalPlaces
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetNbOfDecimalPlaces (const Standard_Integer theL, const Standard_Integer theR)
{
myL = theL;
myR = theR;
}
//=======================================================================
//function : GetNbOfDecimalPlaces
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::GetNbOfDecimalPlaces (Standard_Integer& theL, Standard_Integer& theR) const
{
theL = myL;
theR = myR;
}
//=======================================================================
//function : GetModifiers
//purpose :
//=======================================================================
XCAFDimTolObjects_DimensionModifiersSequence XCAFDimTolObjects_DimensionObject::GetModifiers () const
{
return myModifiers;
}
//=======================================================================
//function : SetModifiers
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetModifiers (const XCAFDimTolObjects_DimensionModifiersSequence& theModifiers)
{
myModifiers = theModifiers;
}
//=======================================================================
//function : AddModifier
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::AddModifier (const XCAFDimTolObjects_DimensionModif theModifier)
{
myModifiers.Append(theModifier);
}
//=======================================================================
//function : GetPath
//purpose :
//=======================================================================
TopoDS_Edge XCAFDimTolObjects_DimensionObject::GetPath () const
{
return myPath;
}
//=======================================================================
//function : SetPath
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetPath (const TopoDS_Edge& thePath)
{
if(!thePath.IsNull())
{
myPath = thePath;
}
}
//=======================================================================
//function : GetDirection
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DimensionObject::GetDirection (gp_Dir& theDir) const
{
theDir = myDir;
return Standard_True;
}
//=======================================================================
//function : SetDirection
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_DimensionObject::SetDirection (const gp_Dir& theDir)
{
myDir = theDir;
return Standard_True;
}
//=======================================================================
//function : GetPoints
//purpose :
//=======================================================================
Handle(TColgp_HArray1OfPnt) XCAFDimTolObjects_DimensionObject::GetPoints () const
{
return myPnts;
}
//=======================================================================
//function : SetPoints
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetPoints (const Handle(TColgp_HArray1OfPnt)& thePnts)
{
myPnts = thePnts;
}

View File

@@ -0,0 +1,84 @@
-- Created on: 2015-07-31
-- Created by: data exchange team
-- Copyright (c) 2000-2015 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class GeomToleranceObject from XCAFDimTolObjects inherits Transient from Standard
---Purpose: attribute to store dimension and tolerance
uses
HArray1OfReal from TColStd,
HAsciiString from TCollection,
GeomToleranceType from XCAFDimTolObjects,
GeomToleranceTypeValue from XCAFDimTolObjects,
GeomToleranceMatReqModif from XCAFDimTolObjects,
GeomToleranceZoneModif from XCAFDimTolObjects,
GeomToleranceModifiersSequence from XCAFDimTolObjects,
GeomToleranceModif from XCAFDimTolObjects
is
Create returns GeomToleranceObject from XCAFDimTolObjects;
Create(theObj : GeomToleranceObject from XCAFDimTolObjects) returns GeomToleranceObject from XCAFDimTolObjects;
---Category: class methods
-- =============
SetType (me : mutable; theType : GeomToleranceType from XCAFDimTolObjects);
GetType (me) returns GeomToleranceType from XCAFDimTolObjects;
SetTypeOfValue (me : mutable; theTypeOfValue : GeomToleranceTypeValue from XCAFDimTolObjects);
GetTypeOfValue (me) returns GeomToleranceTypeValue from XCAFDimTolObjects;
SetValue (me : mutable; theValue : Real from Standard);
GetValue (me) returns Real from Standard;
SetMaterialRequirementModifier (me : mutable; theGeomToleranceMatReqModif : GeomToleranceMatReqModif from XCAFDimTolObjects);
GetMaterialRequirementModifier (me) returns GeomToleranceMatReqModif from XCAFDimTolObjects;
SetZoneModifier (me : mutable; theGeomToleranceZoneModif : GeomToleranceZoneModif from XCAFDimTolObjects);
GetZoneModifier (me) returns GeomToleranceZoneModif from XCAFDimTolObjects;
SetValueOfZoneModifier (me : mutable; theValue : Real from Standard);
GetValueOfZoneModifier (me) returns Real from Standard;
SetModifiers (me : mutable; theModifiers : GeomToleranceModifiersSequence from XCAFDimTolObjects);
AddModifier (me : mutable; theModifier : GeomToleranceModif from XCAFDimTolObjects);
GetModifiers (me) returns GeomToleranceModifiersSequence from XCAFDimTolObjects;
SetMaxValueModifier (me : mutable; theModifier : Real from Standard);
GetMaxValueModifier (me) returns Real from Standard;
fields
myType : GeomToleranceType from XCAFDimTolObjects;
myTypeOfValue : GeomToleranceTypeValue from XCAFDimTolObjects ;
myValue : Real from Standard ;
myMatReqModif : GeomToleranceMatReqModif from XCAFDimTolObjects ;
myZoneModif : GeomToleranceZoneModif from XCAFDimTolObjects;
myValueOfZoneModif : Real from Standard;
myModifiers : GeomToleranceModifiersSequence from XCAFDimTolObjects;
myMaxValueModif : Real from Standard ;
end GeomToleranceObject;

View File

@@ -0,0 +1,210 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <XCAFDimTolObjects_GeomToleranceObject.ixx>
//=======================================================================
//function : XCAFDimTolObjects_GeomTolerance
//purpose :
//=======================================================================
XCAFDimTolObjects_GeomToleranceObject::XCAFDimTolObjects_GeomToleranceObject()
{
}
//=======================================================================
//function : XCAFDimTolObjects_GeomTolerance
//purpose :
//=======================================================================
XCAFDimTolObjects_GeomToleranceObject::XCAFDimTolObjects_GeomToleranceObject(const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObj)
{
myType = theObj->myType;
myTypeOfValue = theObj->myTypeOfValue;
myValue = theObj->myValue;
myMatReqModif = theObj->myMatReqModif;
myZoneModif = theObj->myZoneModif;
myValueOfZoneModif = theObj->myValueOfZoneModif;
myModifiers = theObj->myModifiers;
myMaxValueModif = theObj->myMaxValueModif;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::SetType (const XCAFDimTolObjects_GeomToleranceType theType)
{
myType = theType;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
XCAFDimTolObjects_GeomToleranceType XCAFDimTolObjects_GeomToleranceObject::GetType() const
{
return myType;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::SetTypeOfValue (const XCAFDimTolObjects_GeomToleranceTypeValue theTypeOfValue)
{
myTypeOfValue = theTypeOfValue;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
XCAFDimTolObjects_GeomToleranceTypeValue XCAFDimTolObjects_GeomToleranceObject::GetTypeOfValue() const
{
return myTypeOfValue;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::SetValue (const Standard_Real theValue)
{
myValue = theValue;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Real XCAFDimTolObjects_GeomToleranceObject::GetValue() const
{
return myValue;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::SetMaterialRequirementModifier (const XCAFDimTolObjects_GeomToleranceMatReqModif theMatReqModif)
{
myMatReqModif = theMatReqModif;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
XCAFDimTolObjects_GeomToleranceMatReqModif XCAFDimTolObjects_GeomToleranceObject::GetMaterialRequirementModifier() const
{
return myMatReqModif;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::SetZoneModifier (const XCAFDimTolObjects_GeomToleranceZoneModif theZoneModif)
{
myZoneModif = theZoneModif;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
XCAFDimTolObjects_GeomToleranceZoneModif XCAFDimTolObjects_GeomToleranceObject::GetZoneModifier() const
{
return myZoneModif;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::SetValueOfZoneModifier (const Standard_Real theValue)
{
myValueOfZoneModif = theValue;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Real XCAFDimTolObjects_GeomToleranceObject::GetValueOfZoneModifier() const
{
return myValueOfZoneModif;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::SetModifiers (const XCAFDimTolObjects_GeomToleranceModifiersSequence& theModifiers)
{
myModifiers = theModifiers;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::AddModifier (const XCAFDimTolObjects_GeomToleranceModif theModifier)
{
myModifiers.Append(theModifier);
}
//=======================================================================
//function :
//purpose :
//=======================================================================
XCAFDimTolObjects_GeomToleranceModifiersSequence XCAFDimTolObjects_GeomToleranceObject::GetModifiers() const
{
return myModifiers;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::SetMaxValueModifier (const Standard_Real theModifier)
{
myMaxValueModif = theModifier;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Real XCAFDimTolObjects_GeomToleranceObject::GetMaxValueModifier() const
{
return myMaxValueModif;
}

View File

@@ -0,0 +1,62 @@
-- Created on: 2004-01-09
-- Created by: Sergey KUUL
-- Copyright (c) 2004-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class Tool from XCAFDimTolObjects
---Purpose:
uses
Shape from TopoDS,
Document from TDocStd,
DimTolTool from XCAFDoc,
GeomToleranceObject from XCAFDimTolObjects,
DatumObject from XCAFDimTolObjects,
DimensionObject from XCAFDimTolObjects,
DimensionObjectSequence from XCAFDimTolObjects,
DatumObjectSequence from XCAFDimTolObjects,
GeomToleranceObjectSequence from XCAFDimTolObjects,
DataMapOfToleranceDatum from XCAFDimTolObjects
is
Create (theDoc : Document from TDocStd) returns Tool from XCAFDimTolObjects;
GetDimensions (me; theDimensionObjectSequence: out DimensionObjectSequence from XCAFDimTolObjects);
---Purpose: Returns a sequence of Dimensions currently stored
-- in the DGTtable
GetRefDimensions (me; theShape: Shape from TopoDS; theDimensions: out DimensionObjectSequence from XCAFDimTolObjects)
returns Boolean;
---Purpose: Returns all Dimensions defined for Shape
GetGeomTolerances (me; theGeomToleranceObjectSequence : out GeomToleranceObjectSequence from XCAFDimTolObjects;
theDatumObjectSequence : out DatumObjectSequence from XCAFDimTolObjects;
theMap : out DataMapOfToleranceDatum from XCAFDimTolObjects);
---Purpose: Returns a sequence of Tolerancess currently stored
-- in the DGTtable
GetRefGeomTolerances (me; theShape: Shape from TopoDS;
theGeomToleranceObjectSequence: out GeomToleranceObjectSequence from XCAFDimTolObjects;
theDatumObjectSequence : out DatumObjectSequence from XCAFDimTolObjects;
theMap : out DataMapOfToleranceDatum from XCAFDimTolObjects)
returns Boolean;
---Purpose: Returns all GeomTolerances defined for Shape
GetRefDatum (me; theShape: Shape from TopoDS; theDatum: out DatumObject from XCAFDimTolObjects)
returns Boolean;
---Purpose: Returns DatumObject defined for Shape
fields
myDimTolTool : DimTolTool from XCAFDoc;
end Tool;

View File

@@ -0,0 +1,187 @@
// Copyright (c) 1999-2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <XCAFDimTolObjects_Tool.hxx>
#include <XCAFDimTolObjects_DimensionObjectSequence.hxx>
#include <TDF_ChildIterator.hxx>
#include <XCAFDoc_DimTolTool.hxx>
#include <XCAFDoc_Dimension.hxx>
#include <XCAFDimTolObjects_GeomToleranceObjectSequence.hxx>
#include <XCAFDoc_GeomTolerance.hxx>
#include <XCAFDimTolObjects_DatumObjectSequence.hxx>
#include <XCAFDoc_Datum.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_Datum.hxx>
#include <TDF_Label.hxx>
#include <TDF_LabelSequence.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <TDocStd_Document.hxx>
#include <NCollection_DataMap.hxx>
#include <XCAFDimTolObjects_DataMapOfToleranceDatum.hxx>
//=======================================================================
//function : XCAFDimTolObjects_Tool
//purpose :
//=======================================================================
XCAFDimTolObjects_Tool::XCAFDimTolObjects_Tool(const Handle(TDocStd_Document)& theDoc)
{
myDimTolTool = XCAFDoc_DocumentTool::DimTolTool(theDoc->Main());
}
//=======================================================================
//function : GetDimensions
//purpose :
//=======================================================================
void XCAFDimTolObjects_Tool::GetDimensions(XCAFDimTolObjects_DimensionObjectSequence& theDimensionObjectSequence) const
{
theDimensionObjectSequence.Clear();
TDF_ChildIterator aChildIterator( myDimTolTool->Label() );
for (; aChildIterator.More(); aChildIterator.Next()) {
TDF_Label aL = aChildIterator.Value();
Handle(XCAFDoc_Dimension) aDimension;
if(aL.FindAttribute(XCAFDoc_Dimension::GetID(),aDimension)) {
theDimensionObjectSequence.Append(aDimension->GetObject());
}
}
}
//=======================================================================
//function : GetGeomTolerances
//purpose :
//=======================================================================
void XCAFDimTolObjects_Tool::GetGeomTolerances(XCAFDimTolObjects_GeomToleranceObjectSequence& theGeomToleranceObjectSequence,
XCAFDimTolObjects_DatumObjectSequence& theDatumSequence,
XCAFDimTolObjects_DataMapOfToleranceDatum& theMap) const
{
theGeomToleranceObjectSequence.Clear();
TDF_ChildIterator aChildIterator( myDimTolTool->Label() );
for (; aChildIterator.More(); aChildIterator.Next()) {
TDF_Label aL = aChildIterator.Value();
Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
if(aL.FindAttribute(XCAFDoc_GeomTolerance::GetID(),aGeomTolerance)) {
theGeomToleranceObjectSequence.Append(aGeomTolerance->GetObject());
TDF_LabelSequence aSeq;
if(myDimTolTool->GetDatumOfTolerLabels(aGeomTolerance->Label(), aSeq))
{
for(Standard_Integer i = 1; i <= aSeq.Length(); i++)
{
Handle(XCAFDoc_Datum) aDatum;
if(aSeq.Value(i).FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
{
theDatumSequence.Append(aDatum->GetObject());
theMap.Bind(theGeomToleranceObjectSequence.Last(), theDatumSequence.Last());
}
}
}
}
}
}
//=======================================================================
//function : GetRefDimensions
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_Tool::GetRefDimensions(const TopoDS_Shape& theShape,
XCAFDimTolObjects_DimensionObjectSequence& theDimensionObjectSequence) const
{
theDimensionObjectSequence.Clear();
TDF_Label aShapeL;
myDimTolTool->ShapeTool()->Search(theShape, aShapeL);
if(!aShapeL.IsNull())
{
TDF_LabelSequence aSeq;
if( myDimTolTool->GetRefDimensionLabels(aShapeL, aSeq) ) {
for(Standard_Integer i = 1; i <= aSeq.Length(); i++)
{
Handle(XCAFDoc_Dimension) aDimension;
if( aSeq.Value(i).FindAttribute(XCAFDoc_Dimension::GetID(),aDimension))
theDimensionObjectSequence.Append(aDimension->GetObject());
}
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : GetRefGeomTolerances
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_Tool::GetRefGeomTolerances(const TopoDS_Shape& theShape,
XCAFDimTolObjects_GeomToleranceObjectSequence& theGeomToleranceObjectSequence,
XCAFDimTolObjects_DatumObjectSequence& theDatumSequence,
XCAFDimTolObjects_DataMapOfToleranceDatum& theMap) const
{
theGeomToleranceObjectSequence.Clear();
TDF_Label aShapeL;
myDimTolTool->ShapeTool()->Search(theShape, aShapeL);
if(!aShapeL.IsNull())
{
TDF_LabelSequence aSeq;
if( myDimTolTool->GetRefGeomToleranceLabels(aShapeL, aSeq) ) {
for(Standard_Integer i = 1; i <= aSeq.Length(); i++)
{
Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
if( aSeq.Value(i).FindAttribute(XCAFDoc_GeomTolerance::GetID(),aGeomTolerance))
{
theGeomToleranceObjectSequence.Append(aGeomTolerance->GetObject());
TDF_LabelSequence aSeq;
if(myDimTolTool->GetDatumOfTolerLabels(aGeomTolerance->Label(), aSeq))
{
for(Standard_Integer i = 1; i <= aSeq.Length(); i++)
{
Handle(XCAFDoc_Datum) aDatum;
if(aSeq.Value(i).FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
{
theDatumSequence.Append(aDatum->GetObject());
theMap.Bind(theGeomToleranceObjectSequence.Last(), theDatumSequence.Last());
}
}
}
}
}
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : GetRefDatum
//purpose :
//=======================================================================
Standard_Boolean XCAFDimTolObjects_Tool::GetRefDatum(const TopoDS_Shape& theShape,
Handle(XCAFDimTolObjects_DatumObject)& theDatumObject) const
{
TDF_Label aShapeL;
myDimTolTool->ShapeTool()->Search(theShape, aShapeL);
if(!aShapeL.IsNull())
{
TDF_Label aDatumL;
if(myDimTolTool->GetRefDatumLabel(aShapeL, aDatumL))
{
Handle(XCAFDoc_Datum) aDatum;
if( aDatumL.FindAttribute(XCAFDoc_Datum::GetID(),aDatum)){
theDatumObject = aDatum->GetObject();
return Standard_True;
}
}
}
return Standard_False;
}

View File

@@ -34,12 +34,14 @@ uses
Quantity,
TCollection,
TColStd,
TColgp,
TopLoc,
TopoDS,
TopTools,
TDF,
TDocStd,
TDataStd,
XCAFDimTolObjects,
gp
is
@@ -56,7 +58,6 @@ is
ColorSurf, -- color of surfaces
ColorCurv -- color of curves
end ColorType;
class DocumentTool;
@@ -65,9 +66,13 @@ is
class Color;
class DimTol;
class Dimension;
class GeomTolerance;
class Datum;
class Material;
class Volume;
@@ -93,6 +98,7 @@ is
class GraphNodeSequence instantiates Sequence from TCollection
(GraphNode from XCAFDoc);
---Purpose: class for containing GraphNodes.
class DataMapOfShapeLabel instantiates
DataMap from TCollection (Shape from TopoDS,
@@ -113,9 +119,15 @@ is
DimTolRefGUID returns GUID from Standard;
---Purpose: Return GUIDs for TreeNode representing specified types of DGT
DimensionRefGUID returns GUID from Standard;
---Purpose: Return GUIDs for TreeNode representing specified types of Dimension
DatumRefGUID returns GUID from Standard;
---Purpose: Return GUIDs for TreeNode representing specified types of datum
GeomToleranceRefGUID returns GUID from Standard;
---Purpose: Return GUIDs for TreeNode representing specified types of GeomTolerance
DatumTolRefGUID returns GUID from Standard;
---Purpose: Return GUIDs for TreeNode representing connections Datum-Toler

View File

@@ -89,6 +89,27 @@ Standard_GUID XCAFDoc::DimTolRefGUID()
return ID;
}
//=======================================================================
//function : DimensionRefGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::DimensionRefGUID()
{
static Standard_GUID ID("efd212e3-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
//=======================================================================
//function : GeomToleranceRefGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::GeomToleranceRefGUID()
{
static Standard_GUID ID("efd213e3-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
//=======================================================================
//function : DatumRefGUID

View File

@@ -20,9 +20,11 @@ class Datum from XCAFDoc inherits Attribute from TDF
uses
Label from TDF,
RelocationTable from TDF,
HAsciiString from TCollection
HAsciiString from TCollection,
DatumObject from XCAFDimTolObjects
is
Create returns Datum from XCAFDoc;
---Category: class methods
@@ -38,16 +40,24 @@ is
anIdentification : HAsciiString from TCollection)
returns Datum from XCAFDoc;
Set (myclass; label : Label from TDF)
returns Datum from XCAFDoc;
Set (me : mutable; aName : HAsciiString from TCollection;
aDescription : HAsciiString from TCollection;
anIdentification : HAsciiString from TCollection);
GetName (me) returns HAsciiString from TCollection;
GetDescription (me) returns HAsciiString from TCollection;
GetIdentification (me) returns HAsciiString from TCollection;
GetObject (me) returns DatumObject from XCAFDimTolObjects;
SetObject (me : mutable; theObject : DatumObject from XCAFDimTolObjects);
ID (me)
---C++: return const &
returns GUID from Standard;

View File

@@ -14,7 +14,20 @@
#include <XCAFDoc_Datum.ixx>
#include <TDF_RelocationTable.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Real.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Builder.hxx>
enum ChildLab
{
ChildLab_Name = 1,
ChildLab_Modifiers,
ChildLab_ModifierWithValue,
ChildLab_DatumTarget
};
//=======================================================================
//function : XCAFDoc_Datum
@@ -25,7 +38,6 @@ XCAFDoc_Datum::XCAFDoc_Datum()
{
}
//=======================================================================
//function : GetID
//purpose :
@@ -45,18 +57,33 @@ const Standard_GUID& XCAFDoc_Datum::GetID()
//purpose :
//=======================================================================
Handle(XCAFDoc_Datum) XCAFDoc_Datum::Set(const TDF_Label& label,
const Handle(TCollection_HAsciiString)& aName,
const Handle(TCollection_HAsciiString)& aDescription,
const Handle(TCollection_HAsciiString)& anIdentification)
Handle(XCAFDoc_Datum) XCAFDoc_Datum::Set(const TDF_Label& theLabel,
const Handle(TCollection_HAsciiString)& theName,
const Handle(TCollection_HAsciiString)& theDescription,
const Handle(TCollection_HAsciiString)& theIdentification)
{
Handle(XCAFDoc_Datum) A;
if (!label.FindAttribute(XCAFDoc_Datum::GetID(), A)) {
A = new XCAFDoc_Datum();
label.AddAttribute(A);
Handle(XCAFDoc_Datum) aDatum;
if (!theLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum)) {
aDatum = new XCAFDoc_Datum();
theLabel.AddAttribute(aDatum);
}
A->Set(aName,aDescription,anIdentification);
return A;
aDatum->Set(theName,theDescription,theIdentification);
return aDatum;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(XCAFDoc_Datum) XCAFDoc_Datum::Set(const TDF_Label& theLabel)
{
Handle(XCAFDoc_Datum) aDatum;
if (!theLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum)) {
aDatum = new XCAFDoc_Datum();
theLabel.AddAttribute(aDatum);
}
return aDatum;
}
@@ -65,13 +92,14 @@ Handle(XCAFDoc_Datum) XCAFDoc_Datum::Set(const TDF_Label& label,
//purpose :
//=======================================================================
void XCAFDoc_Datum::Set(const Handle(TCollection_HAsciiString)& aName,
const Handle(TCollection_HAsciiString)& aDescription,
const Handle(TCollection_HAsciiString)& anIdentification)
void XCAFDoc_Datum::Set(const Handle(TCollection_HAsciiString)& theName,
const Handle(TCollection_HAsciiString)& theDescription,
const Handle(TCollection_HAsciiString)& theIdentification)
{
myName = aName;
myDescription = aDescription;
myIdentification = anIdentification;
Backup();
myName = theName;
myDescription = theDescription;
myIdentification = theIdentification;
}
@@ -82,12 +110,13 @@ void XCAFDoc_Datum::Set(const Handle(TCollection_HAsciiString)& aName,
Handle(TCollection_HAsciiString) XCAFDoc_Datum::GetName() const
{
if(myName.IsNull())
return new TCollection_HAsciiString();
return myName;
}
//=======================================================================
//function : GetDescription
//function : GetDescriptio7n
//purpose :
//=======================================================================
@@ -107,6 +136,127 @@ Handle(TCollection_HAsciiString) XCAFDoc_Datum::GetIdentification() const
return myIdentification;
}
//=======================================================================
//function : SetObject
//purpose :
//=======================================================================
void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theObject)
{
Backup();
if (!theObject->GetName().IsNull())
{
Handle(TDataStd_AsciiString) anAttName;
if(!Label().FindChild(ChildLab_Name).FindAttribute(TDataStd_AsciiString::GetID(), anAttName))
{
anAttName = new TDataStd_AsciiString();
Label().FindChild(ChildLab_Name).AddAttribute(anAttName);
}
anAttName->Set(theObject->GetName()->String());
}
else
{
Label().FindChild(ChildLab_Name).ForgetAllAttributes();
}
if(theObject->GetModifiers().Length() == 0)
{
Label().FindChild(ChildLab_Modifiers).ForgetAllAttributes();
}
else
{
Handle(TDataStd_IntegerArray) aModifiers;
if(!Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers))
{
aModifiers = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
}
Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1,theObject->GetModifiers().Length());
for(Standard_Integer i = 1; i <= theObject->GetModifiers().Length(); i++)
anArr->SetValue(i,theObject->GetModifiers().Value(i));
aModifiers->ChangeArray(anArr);
}
XCAFDimTolObjects_DatumModifWithValue aM;
Standard_Real aV;
theObject->GetModifierWithValue(aM, aV);
if(aM != XCAFDimTolObjects_DatumModifWithValue_None)
{
Handle(TDataStd_Integer) aModifierWithValueM;
if(!Label().FindChild(ChildLab_ModifierWithValue).FindAttribute(TDataStd_Integer::GetID(), aModifierWithValueM))
{
aModifierWithValueM = new TDataStd_Integer();
Label().FindChild(ChildLab_ModifierWithValue).AddAttribute(aModifierWithValueM);
}
Handle(TDataStd_Real) aModifierWithValueV;
if(!Label().FindChild(ChildLab_ModifierWithValue).FindAttribute(TDataStd_Real::GetID(), aModifierWithValueV))
{
aModifierWithValueV = new TDataStd_Real();
Label().FindChild(ChildLab_ModifierWithValue).AddAttribute(aModifierWithValueV);
}
aModifierWithValueM->Set(aM);
aModifierWithValueV->Set(aV);
}
else
{
Label().FindChild(ChildLab_ModifierWithValue).ForgetAllAttributes();
}
if(!theObject->GetDatumTarget().IsNull())
{
TNaming_Builder tnBuild(Label().FindChild(ChildLab_DatumTarget));
tnBuild.Generated(theObject->GetDatumTarget());
}
else
{
Label().FindChild(ChildLab_DatumTarget).ForgetAllAttributes();
}
}
//=======================================================================
//function : GetObject
//purpose :
//=======================================================================
Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
{
Handle(XCAFDimTolObjects_DatumObject) anObj = new XCAFDimTolObjects_DatumObject();
Handle(TDataStd_AsciiString) anAttName;
if(Label().FindChild(ChildLab_Name).FindAttribute(TDataStd_AsciiString::GetID(), anAttName))
{
Handle(TCollection_HAsciiString) aStr = new TCollection_HAsciiString(anAttName->Get());
anObj->SetName(aStr);
}
Handle(TDataStd_IntegerArray) anArr;
if(Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), anArr)
&& !anArr->Array().IsNull())
{
XCAFDimTolObjects_DatumModifiersSequence aModifiers;
for(Standard_Integer i = 1; i <= anArr->Length(); i++)
aModifiers.Append((XCAFDimTolObjects_DatumSingleModif)anArr->Value(i));
anObj->SetModifiers(aModifiers);
}
Handle(TDataStd_Integer) aModifierWithValueM;
if(Label().FindChild(ChildLab_ModifierWithValue).FindAttribute(TDataStd_Integer::GetID(), aModifierWithValueM))
{
Handle(TDataStd_Real) aModifierWithValueV;
if(Label().FindChild(ChildLab_ModifierWithValue).FindAttribute(TDataStd_Real::GetID(), aModifierWithValueV))
{
anObj->SetModifierWithValue((XCAFDimTolObjects_DatumModifWithValue)aModifierWithValueM->Get(),aModifierWithValueV->Get());
}
}
Handle(TNaming_NamedShape) aDatumTarget;
if(Label().FindChild(ChildLab_DatumTarget).FindAttribute(TNaming_NamedShape::GetID(), aDatumTarget))
{
anObj->SetDatumTarget(aDatumTarget->Get());
}
return anObj;
}
//=======================================================================
//function : ID
@@ -124,11 +274,11 @@ const Standard_GUID& XCAFDoc_Datum::ID() const
//purpose :
//=======================================================================
void XCAFDoc_Datum::Restore(const Handle(TDF_Attribute)& With)
void XCAFDoc_Datum::Restore(const Handle(TDF_Attribute)& theWith)
{
myName = Handle(XCAFDoc_Datum)::DownCast(With)->GetName();
myDescription = Handle(XCAFDoc_Datum)::DownCast(With)->GetDescription();
myIdentification = Handle(XCAFDoc_Datum)::DownCast(With)->GetIdentification();
myName = Handle(XCAFDoc_Datum)::DownCast(theWith)->GetName();
myDescription = Handle(XCAFDoc_Datum)::DownCast(theWith)->GetDescription();
myIdentification = Handle(XCAFDoc_Datum)::DownCast(theWith)->GetIdentification();
}
@@ -148,9 +298,9 @@ Handle(TDF_Attribute) XCAFDoc_Datum::NewEmpty() const
//purpose :
//=======================================================================
void XCAFDoc_Datum::Paste(const Handle(TDF_Attribute)& Into,
void XCAFDoc_Datum::Paste(const Handle(TDF_Attribute)& theInto,
const Handle(TDF_RelocationTable)& /*RT*/) const
{
Handle(XCAFDoc_Datum)::DownCast(Into)->Set(myName,myDescription,myIdentification);
Handle(XCAFDoc_Datum)::DownCast(theInto)->Set(myName,myDescription,myIdentification);
}

View File

@@ -71,6 +71,7 @@ void XCAFDoc_DimTol::Set(const Standard_Integer kind,
const Handle(TCollection_HAsciiString)& aName,
const Handle(TCollection_HAsciiString)& aDescription)
{
Backup();
myKind = kind;
myVal = aVal;
myName = aName;

View File

@@ -27,6 +27,9 @@ uses
LabelSequence from TDF,
Document from TDocStd,
ShapeTool from XCAFDoc,
GeomTolerance from XCAFDoc,
Datum from XCAFDoc,
Dimension from XCAFDoc,
RelocationTable from TDF,
HArray1OfReal from TColStd,
HAsciiString from TCollection
@@ -53,6 +56,61 @@ is
---C++: return const &
-- Methods for Dimension:
IsDimension (me; theLab: Label from TDF) returns Boolean;
---Purpose: Returns True if label belongs to a dimtoltable and
-- is a Dimension definition
GetDimensionLabels (me; theLabels: out LabelSequence from TDF);
---Purpose: Returns a sequence of Dimensions labels currently stored
-- in the DGTtable
SetDimension (me; theFirstL: Label from TDF;
theSecondL: Label from TDF;
theDimTolL: Label from TDF);
---Purpose: Sets a link with GUID
SetDimension (me; theL: Label from TDF;
theDimTolL: Label from TDF);
---Purpose: Sets a link with GUID
GetRefDimensionLabels (me; theShapeL: Label from TDF; theDimensions: out LabelSequence from TDF)
returns Boolean;
---Purpose: Returns all Dimension labels defined for label ShapeL
AddDimension (me : mutable)
returns Label from TDF;
---Purpose: Adds a dimension definition to a DGTtable and returns its label
-- Methods for GeomTolerance:
IsGeomTolerance (me; theLab: Label from TDF) returns Boolean;
---Purpose: Returns True if label belongs to a dimtoltable and
-- is a DimTol definition
GetGeomToleranceLabels (me; theLabels: out LabelSequence from TDF);
---Purpose: Returns a sequence of Tolerance labels currently stored
-- in the DGTtable
SetGeomTolerance (me; theL: Label from TDF;
theDimTolL: Label from TDF);
---Purpose: Sets a link with GUID
GetRefGeomToleranceLabels (me; theShapeL: Label from TDF; theDimTols: out LabelSequence from TDF)
returns Boolean;
---Purpose: Returns all GeomTolerance labels defined for label ShapeL
AddGeomTolerance (me : mutable)
returns Label from TDF;
---Purpose: Adds a GeomTolerance definition to a DGTtable and returns its label
-- Methods for DimTol:
IsDimTol (me; lab: Label from TDF) returns Boolean;
@@ -98,12 +156,12 @@ is
---Purpose: Sets a link with GUID
-- Adds a DimTol as necessary
GetRefShapeLabel (me; DimTolL: Label from TDF; ShapeL: out Label from TDF)
GetRefShapeLabel (me; theDimTolL: Label from TDF; theShapeL: out LabelSequence from TDF)
returns Boolean;
---Purpose: Returns ShapeL defined for label DimTolL
-- Returns False if the DimTolL is not in DGTtable
GetRefDGTLabels (me; ShapeL: Label from TDF; DimTols: out LabelSequence from TDF)
GetRefDGTLabels (me; theShapeL: Label from TDF; theDimTols: out LabelSequence from TDF)
returns Boolean;
---Purpose: Returns all DimTol labels defined for label ShapeL
@@ -117,14 +175,14 @@ is
-- Methods for Datum:
IsDatum (me; lab: Label from TDF) returns Boolean;
IsDatum (me; theLab: Label from TDF) returns Boolean;
---Purpose: Returns True if label belongs to a dimtoltable and
-- is a Datum definition
GetDatumLabels (me; Labels: out LabelSequence from TDF);
---Purpose: Returns a sequence of Datumss currently stored
GetDatumLabels (me; theLabels: out LabelSequence from TDF);
---Purpose: Returns a sequence of Datum labels currently stored
-- in the DGTtable
FindDatum (me; aName : HAsciiString from TCollection;
aDescription : HAsciiString from TCollection;
anIdentification : HAsciiString from TCollection;
@@ -138,8 +196,12 @@ is
returns Label from TDF;
---Purpose: Adds a datum definition to a DGTtable and returns its label
SetDatum (me; L: Label from TDF;
DatumL: Label from TDF);
AddDatum (me : mutable)
returns Label from TDF;
---Purpose: Adds a datum definition to a DGTtable and returns its label
SetDatum (me; theL: Label from TDF;
theDatumL: Label from TDF);
---Purpose: Sets a link with GUID
SetDatum (me; L: Label from TDF; TolerL: Label from TDF;
@@ -149,6 +211,11 @@ is
---Purpose: Sets a link with GUID for Datum
-- Adds a Datum as necessary
-- Sets connection between Datum and Tolerance
SetDatumToGeomTol (me; theL: Label from TDF; theTolerL: Label from TDF);
---Purpose: Sets a link with GUID for Datum
-- Sets connection between Datum and Tolerance
GetDatum (me; DatumL: Label from TDF;
aName : out HAsciiString from TCollection;
@@ -157,10 +224,21 @@ is
---Purpose: Returns datum assigned to <DatumL>
-- Returns False if no such datum is assigned
GetDatumTolerLabels (me; DimTolL: Label from TDF; Datums: out LabelSequence from TDF)
GetDatumOfTolerLabels (me; theDimTolL: Label from TDF; theDatums: out LabelSequence from TDF)
returns Boolean;
---Purpose: Returns all Datum labels defined for label DimTolL
GetTolerOfDatumLabels (me; theDatumL: Label from TDF; theTols: out LabelSequence from TDF)
returns Boolean;
---Purpose: Returns all GeomToleranses labels defined for label DatumL
GetRefDatumLabel (me; theShapeL: Label from TDF; theDatum: out Label from TDF)
returns Boolean;
---Purpose: Returns Datum label defined for label ShapeL
GetRefDatum (me; theShape: Shape from TopoDS; theDatum: out Datum from XCAFDoc)
returns Boolean;
---Purpose: Returns Datum label defined for label Shape
ID (me)
---C++: return const &

View File

@@ -15,6 +15,8 @@
#include <XCAFDoc.hxx>
#include <XCAFDoc_DimTol.hxx>
#include <XCAFDoc_Dimension.hxx>
#include <XCAFDoc_GeomTolerance.hxx>
#include <XCAFDoc_Datum.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_GraphNode.hxx>
@@ -92,31 +94,87 @@ const Handle(XCAFDoc_ShapeTool)& XCAFDoc_DimTolTool::ShapeTool()
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::IsDimTol(const TDF_Label& DimTolL) const
Standard_Boolean XCAFDoc_DimTolTool::IsDimTol(const TDF_Label& theDimTolL) const
{
Handle(XCAFDoc_DimTol) DimTolAttr;
if(DimTolL.FindAttribute(XCAFDoc_DimTol::GetID(),DimTolAttr)) {
Handle(XCAFDoc_DimTol) aDimTolAttr;
if(theDimTolL.FindAttribute(XCAFDoc_DimTol::GetID(),aDimTolAttr)) {
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : IsDimension
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::IsDimension(const TDF_Label& theDimTolL) const
{
Handle(XCAFDoc_Dimension) aDimTolAttr;
if(theDimTolL.FindAttribute(XCAFDoc_Dimension::GetID(),aDimTolAttr)) {
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : IsGeomTolerance
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::IsGeomTolerance(const TDF_Label& theDimTolL) const
{
Handle(XCAFDoc_GeomTolerance) aDimTolAttr;
if(theDimTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(),aDimTolAttr)) {
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GetDimTolLabels
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::GetDimTolLabels(TDF_LabelSequence& Labels) const
void XCAFDoc_DimTolTool::GetDimTolLabels(TDF_LabelSequence& theLabels) const
{
Labels.Clear();
TDF_ChildIterator ChildIterator( Label() );
for (; ChildIterator.More(); ChildIterator.Next()) {
TDF_Label L = ChildIterator.Value();
if ( IsDimTol(L)) Labels.Append(L);
theLabels.Clear();
TDF_ChildIterator aChildIterator( Label() );
for (; aChildIterator.More(); aChildIterator.Next()) {
TDF_Label aL = aChildIterator.Value();
if ( IsDimTol(aL)) theLabels.Append(aL);
}
}
//=======================================================================
//function : GetDimensionLabels
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::GetDimensionLabels(TDF_LabelSequence& theLabels) const
{
theLabels.Clear();
TDF_ChildIterator aChildIterator( Label() );
for (; aChildIterator.More(); aChildIterator.Next()) {
TDF_Label aL = aChildIterator.Value();
if ( IsDimension(aL)) theLabels.Append(aL);
}
}
//=======================================================================
//function : GetGeomToleranceLabels
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::GetGeomToleranceLabels(TDF_LabelSequence& theLabels) const
{
theLabels.Clear();
TDF_ChildIterator aChildIterator( Label() );
for (; aChildIterator.More(); aChildIterator.Next()) {
TDF_Label aL = aChildIterator.Value();
if ( IsGeomTolerance(aL)) theLabels.Append(aL);
}
}
//=======================================================================
//function : FindDimTol
@@ -198,21 +256,129 @@ TDF_Label XCAFDoc_DimTolTool::AddDimTol(const Standard_Integer kind,
return DimTolL;
}
//=======================================================================
//function : AddDimension
//purpose :
//=======================================================================
TDF_Label XCAFDoc_DimTolTool::AddDimension()
{
TDF_Label aDimTolL;
TDF_TagSource aTag;
aDimTolL = aTag.NewChild ( Label() );
Handle(XCAFDoc_Dimension) aDim = XCAFDoc_Dimension::Set(aDimTolL);
TCollection_AsciiString aStr = "DGT:Dimension";
TDataStd_Name::Set(aDimTolL,aStr);
return aDimTolL;
}
//=======================================================================
//function : AddGeomTolerance
//purpose :
//=======================================================================
TDF_Label XCAFDoc_DimTolTool::AddGeomTolerance()
{
TDF_Label aDimTolL;
TDF_TagSource aTag;
aDimTolL = aTag.NewChild ( Label() );
Handle(XCAFDoc_GeomTolerance) aTol = XCAFDoc_GeomTolerance::Set(aDimTolL);
TCollection_AsciiString aStr = "DGT:Tolerance";
TDataStd_Name::Set(aDimTolL,aStr);
return aDimTolL;
}
//=======================================================================
//function : SetDimension
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::SetDimension(const TDF_Label& theL,
const TDF_Label& theDimTolL) const
{
TDF_Label nullLab;
SetDimension(theL, nullLab, theDimTolL);
}
//=======================================================================
//function : SetDimension
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::SetDimension(const TDF_Label& theFirstL,
const TDF_Label& theSecondL,
const TDF_Label& theDimTolL) const
{
Handle(XCAFDoc_GraphNode) aChGNode;
Handle(XCAFDoc_GraphNode) aFGNode;
Handle(XCAFDoc_GraphNode) aSecondFGNode;
//Handle(XCAFDoc_GraphNode) ChGNode, FGNode;
if ( theDimTolL.FindAttribute (XCAFDoc::DimensionRefGUID(), aChGNode) ) {
while (aChGNode->NbFathers() > 0) {
aFGNode = aChGNode->GetFather(1);
aFGNode->UnSetChild(aChGNode);
}
theDimTolL.ForgetAttribute ( XCAFDoc::DimTolRefGUID() );
}
if(!IsDimension(theDimTolL))
{
return;
}
if (!theDimTolL.FindAttribute(XCAFDoc::DimensionRefGUID(), aChGNode) ) {
aChGNode = new XCAFDoc_GraphNode;
aChGNode = XCAFDoc_GraphNode::Set(theDimTolL);
}
if (!theFirstL.FindAttribute(XCAFDoc::DimensionRefGUID(), aFGNode) ) {
aFGNode = new XCAFDoc_GraphNode;
aFGNode = XCAFDoc_GraphNode::Set(theFirstL);
}
aFGNode->SetGraphID(XCAFDoc::DimensionRefGUID());
aChGNode->SetGraphID(XCAFDoc::DimensionRefGUID());
aFGNode->SetChild(aChGNode);
aChGNode->SetFather(aFGNode);
if (!theSecondL.IsNull()){
if(!theSecondL.FindAttribute(XCAFDoc::DimensionRefGUID(), aSecondFGNode) ) {
aSecondFGNode = new XCAFDoc_GraphNode;
aSecondFGNode = XCAFDoc_GraphNode::Set(theSecondL);
}
aSecondFGNode->SetGraphID(XCAFDoc::DimensionRefGUID());
aSecondFGNode->SetChild(aChGNode);
aChGNode->SetFather(aSecondFGNode);
}
}
//=======================================================================
//function : SetGeomTolerance
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::SetGeomTolerance(const TDF_Label& theL,
const TDF_Label& theDimTolL) const
{
// set reference
Handle(TDataStd_TreeNode) refNode, mainNode;
refNode = TDataStd_TreeNode::Set ( theDimTolL, XCAFDoc::GeomToleranceRefGUID() );
mainNode = TDataStd_TreeNode::Set ( theL, XCAFDoc::GeomToleranceRefGUID() );
refNode->Remove(); // abv: fix against bug in TreeNode::Append()
mainNode->Append(refNode);
}
//=======================================================================
//function : SetDimTol
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::SetDimTol(const TDF_Label& L,
const TDF_Label& DimTolL) const
void XCAFDoc_DimTolTool::SetDimTol(const TDF_Label& theL,
const TDF_Label& theDimTolL) const
{
// set reference
Handle(TDataStd_TreeNode) refNode, mainNode;
// mainNode = TDataStd_TreeNode::Set ( DimTolL, XCAFDoc::DimTolRefGUID() );
// refNode = TDataStd_TreeNode::Set ( L, XCAFDoc::DimTolRefGUID() );
refNode = TDataStd_TreeNode::Set ( DimTolL, XCAFDoc::DimTolRefGUID() );
mainNode = TDataStd_TreeNode::Set ( L, XCAFDoc::DimTolRefGUID() );
refNode = TDataStd_TreeNode::Set ( theDimTolL, XCAFDoc::DimTolRefGUID() );
mainNode = TDataStd_TreeNode::Set (theL, XCAFDoc::DimTolRefGUID() );
refNode->Remove(); // abv: fix against bug in TreeNode::Append()
mainNode->Append(refNode);
}
@@ -240,42 +406,88 @@ TDF_Label XCAFDoc_DimTolTool::SetDimTol(const TDF_Label& L,
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetRefShapeLabel(const TDF_Label& L,
TDF_Label& ShapeL) const
Standard_Boolean XCAFDoc_DimTolTool::GetRefShapeLabel(const TDF_Label& theL,
TDF_LabelSequence& theShapeL) const
{
Handle(TDataStd_TreeNode) Node;
if( !L.FindAttribute(XCAFDoc::DimTolRefGUID(),Node) || !Node->HasFather() ) {
if( !L.FindAttribute(XCAFDoc::DatumRefGUID(),Node) || !Node->HasFather() ) {
return Standard_False;
theShapeL.Clear();
Handle(TDataStd_TreeNode) aNode;
if( !theL.FindAttribute(XCAFDoc::DimTolRefGUID(),aNode) || !aNode->HasFather() ) {
if( !theL.FindAttribute(XCAFDoc::DatumRefGUID(),aNode) || !aNode->HasFather() ) {
if( !theL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aNode) || !aNode->HasFather() ) {
Handle(XCAFDoc_GraphNode) aGNode;
if( theL.FindAttribute(XCAFDoc::DimensionRefGUID(),aGNode) && aGNode->NbFathers() > 0 ) {
for(Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
{
theShapeL.Append(aGNode->GetFather(i)->Label());
}
return Standard_True;
}
return Standard_False;
}
}
}
ShapeL = Node->Father()->Label();
theShapeL.Append(aNode->Father()->Label());
return Standard_True;
}
//=======================================================================
//function : GetRefDGTLabels
//function : GetRefDimensionLabels
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetRefDGTLabels(const TDF_Label& ShapeL,
TDF_LabelSequence &DimTols) const
Standard_Boolean XCAFDoc_DimTolTool::GetRefDimensionLabels(const TDF_Label& theShapeL,
TDF_LabelSequence& theDimTols) const
{
Handle(TDataStd_TreeNode) Node;
if( !ShapeL.FindAttribute(XCAFDoc::DimTolRefGUID(),Node) ||
!Node->HasFirst() ) {
Handle(XCAFDoc_GraphNode) aGNode;
if( theShapeL.FindAttribute(XCAFDoc::DimensionRefGUID(),aGNode) && aGNode->NbChildren() > 0 ) {
for(Standard_Integer i = 1; i <= aGNode->NbChildren(); i++)
{
theDimTols.Append(aGNode->GetChild(i)->Label());
}
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GetRefGeomToleranceLabels
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetRefGeomToleranceLabels(const TDF_Label& theShapeL,
TDF_LabelSequence& theDimTols) const
{
Handle(TDataStd_TreeNode) aNode;
if( !theShapeL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aNode) ||
!aNode->HasFirst() ) {
return Standard_False;
}
Handle(TDataStd_TreeNode) Last = Node->First();
DimTols.Append(Last->Label());
while(Last->HasNext()) {
Last = Last->Next();
DimTols.Append(Last->Label());
Handle(TDataStd_TreeNode) aLast = aNode->First();
theDimTols.Append(aLast->Label());
while(aLast->HasNext()) {
aLast = aLast->Next();
theDimTols.Append(aLast->Label());
}
return Standard_True;
}
//=======================================================================
//function : GetRefDatumLabel
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetRefDatumLabel(const TDF_Label& theShapeL,
TDF_Label& theDatum) const
{
Handle(TDataStd_TreeNode) aNode;
if( !theShapeL.FindAttribute(XCAFDoc::DatumRefGUID(),aNode) ||
!aNode->HasFirst() ) {
return Standard_False;
}
Handle(TDataStd_TreeNode) aLast = aNode->First();
theDatum = aLast->Label();
return Standard_True;
}
//=======================================================================
//function : GetDimTol
@@ -306,10 +518,10 @@ Standard_Boolean XCAFDoc_DimTolTool::GetDimTol(const TDF_Label& DimTolL,
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::IsDatum(const TDF_Label& DimTolL) const
Standard_Boolean XCAFDoc_DimTolTool::IsDatum(const TDF_Label& theDimTolL) const
{
Handle(XCAFDoc_Datum) DatumAttr;
if(DimTolL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) {
Handle(XCAFDoc_Datum) aDatumAttr;
if(theDimTolL.FindAttribute(XCAFDoc_Datum::GetID(),aDatumAttr)) {
return Standard_True;
}
return Standard_False;
@@ -321,17 +533,16 @@ Standard_Boolean XCAFDoc_DimTolTool::IsDatum(const TDF_Label& DimTolL) const
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::GetDatumLabels(TDF_LabelSequence& Labels) const
void XCAFDoc_DimTolTool::GetDatumLabels(TDF_LabelSequence& theLabels) const
{
Labels.Clear();
TDF_ChildIterator ChildIterator( Label() );
for (; ChildIterator.More(); ChildIterator.Next()) {
TDF_Label L = ChildIterator.Value();
if ( IsDatum(L)) Labels.Append(L);
theLabels.Clear();
TDF_ChildIterator aChildIterator( Label() );
for (; aChildIterator.More(); aChildIterator.Next()) {
TDF_Label L = aChildIterator.Value();
if ( IsDatum(L)) theLabels.Append(L);
}
}
//=======================================================================
//function : FindDatum
//purpose :
@@ -375,24 +586,37 @@ TDF_Label XCAFDoc_DimTolTool::AddDatum(const Handle(TCollection_HAsciiString)& a
return DatumL;
}
//=======================================================================
//function : AddDatum
//purpose :
//=======================================================================
TDF_Label XCAFDoc_DimTolTool::AddDatum()
{
TDF_Label aDatumL;
TDF_TagSource aTag;
aDatumL = aTag.NewChild ( Label() );
Handle(XCAFDoc_Datum) aDat = XCAFDoc_Datum::Set(aDatumL);
TDataStd_Name::Set(aDatumL,"DGT:Datum");
return aDatumL;
}
//=======================================================================
//function : SetDatum
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::SetDatum(const TDF_Label& L,
const TDF_Label& DatumL) const
void XCAFDoc_DimTolTool::SetDatum(const TDF_Label& theL,
const TDF_Label& theDatumL) const
{
// set reference
Handle(TDataStd_TreeNode) refNode, mainNode;
refNode = TDataStd_TreeNode::Set ( DatumL, XCAFDoc::DatumRefGUID() );
mainNode = TDataStd_TreeNode::Set ( L, XCAFDoc::DatumRefGUID() );
refNode = TDataStd_TreeNode::Set ( theDatumL, XCAFDoc::DatumRefGUID() );
mainNode = TDataStd_TreeNode::Set ( theL, XCAFDoc::DatumRefGUID() );
refNode->Remove();
mainNode->Append(refNode);
}
//=======================================================================
//function : SetDatum
//purpose :
@@ -425,6 +649,31 @@ void XCAFDoc_DimTolTool::SetDatum(const TDF_Label& L,
ChGNode->SetFather(FGNode);
}
//=======================================================================
//function : SetDatumToGeomTol
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::SetDatumToGeomTol(const TDF_Label& theDatumL,
const TDF_Label& theTolerL) const
{
// set reference
Handle(XCAFDoc_GraphNode) aFGNode;
Handle(XCAFDoc_GraphNode) aChGNode;
if (! theTolerL.FindAttribute( XCAFDoc::DatumTolRefGUID(), aFGNode) ) {
aFGNode = new XCAFDoc_GraphNode;
aFGNode = XCAFDoc_GraphNode::Set(theTolerL);
}
if (! theDatumL.FindAttribute( XCAFDoc::DatumTolRefGUID(), aChGNode) ) {
aChGNode = new XCAFDoc_GraphNode;
aChGNode = XCAFDoc_GraphNode::Set(theDatumL);
}
aFGNode->SetGraphID( XCAFDoc::DatumTolRefGUID() );
aChGNode->SetGraphID( XCAFDoc::DatumTolRefGUID() );
aFGNode->SetChild(aChGNode);
aChGNode->SetFather(aFGNode);
}
//=======================================================================
//function : GetDatum
//purpose :
@@ -451,15 +700,33 @@ Standard_Boolean XCAFDoc_DimTolTool::GetDatum(const TDF_Label& theDatumL,
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetDatumTolerLabels(const TDF_Label& DimTolL,
TDF_LabelSequence &Datums) const
Standard_Boolean XCAFDoc_DimTolTool::GetDatumOfTolerLabels(const TDF_Label& theDimTolL,
TDF_LabelSequence& theDatums) const
{
Handle(XCAFDoc_GraphNode) Node;
if( !DimTolL.FindAttribute(XCAFDoc::DatumTolRefGUID(),Node) )
Handle(XCAFDoc_GraphNode) aNode;
if( !theDimTolL.FindAttribute(XCAFDoc::DatumTolRefGUID(),aNode) )
return Standard_False;
for(Standard_Integer i=1; i<=Node->NbChildren(); i++) {
Handle(XCAFDoc_GraphNode) DatumNode = Node->GetChild(i);
Datums.Append(DatumNode->Label());
for(Standard_Integer i=1; i<=aNode->NbChildren(); i++) {
Handle(XCAFDoc_GraphNode) aDatumNode = aNode->GetChild(i);
theDatums.Append(aDatumNode->Label());
}
return Standard_True;
}
//=======================================================================
//function : GetTolerDatumLabels
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetTolerOfDatumLabels(const TDF_Label& theDatumL,
TDF_LabelSequence& theTols) const
{
Handle(XCAFDoc_GraphNode) aNode;
if( !theDatumL.FindAttribute(XCAFDoc::DatumTolRefGUID(),aNode) )
return Standard_False;
for(Standard_Integer i=1; i<=aNode->NbFathers(); i++) {
Handle(XCAFDoc_GraphNode) aDatumNode = aNode->GetFather(i);
theTols.Append(aDatumNode->Label());
}
return Standard_True;
}
@@ -505,5 +772,4 @@ Handle(TDF_Attribute) XCAFDoc_DimTolTool::NewEmpty() const
void XCAFDoc_DimTolTool::Paste(const Handle(TDF_Attribute)& /*into*/,
const Handle(TDF_RelocationTable)& /*RT*/) const
{
}
}

View File

@@ -0,0 +1,55 @@
-- Created on: 2004-01-09
-- Created by: Sergey KUUL
-- Copyright (c) 2004-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class Dimension from XCAFDoc inherits Attribute from TDF
---Purpose: attribute to store dimension
uses
Label from TDF,
RelocationTable from TDF,
DimensionObject from XCAFDimTolObjects
is
Create returns Dimension from XCAFDoc;
---Category: class methods
-- =============
GetID (myclass)
---C++: return const &
returns GUID from Standard;
Set (myclass; theLabel : Label from TDF)
returns Dimension from XCAFDoc;
ID (me)
---C++: return const &
returns GUID from Standard;
Restore (me: mutable; With : Attribute from TDF);
NewEmpty (me)
returns Attribute from TDF;
Paste (me; Into : Attribute from TDF;
RT : RelocationTable from TDF);
SetObject (me : mutable; theDimensionObject : DimensionObject from XCAFDimTolObjects);
GetObject (me) returns DimensionObject from XCAFDimTolObjects;
end Dimension;

View File

@@ -0,0 +1,329 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <XCAFDoc_Dimension.ixx>
#include <TDF_RelocationTable.hxx>
#include <XCAFDoc.hxx>
#include <TDataStd_TreeNode.hxx>
#include <Precision.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_RealArray.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TopoDS.hxx>
enum ChildLab
{
ChildLab_Type = 1,
ChildLab_Value,
ChildLab_Qualifier,
ChildLab_Class,
ChildLab_Dec,
ChildLab_Modifiers,
ChildLab_Path,
ChildLab_Dir,
ChildLab_Pnts
};
//=======================================================================
//function : XCAFDoc_Dimension
//purpose :
//=======================================================================
XCAFDoc_Dimension::XCAFDoc_Dimension()
{
}
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& XCAFDoc_Dimension::GetID()
{
static Standard_GUID DGTID ("58ed092c-44de-11d8-8776-001083004c77");
//static Standard_GUID ID("efd212e9-6dfd-11d4-b9c8-0060b0ee281b");
return DGTID;
//return ID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(XCAFDoc_Dimension) XCAFDoc_Dimension::Set(const TDF_Label& theLabel)
{
Handle(XCAFDoc_Dimension) A;
if (!theLabel.FindAttribute(XCAFDoc_Dimension::GetID(), A)) {
A = new XCAFDoc_Dimension();
theLabel.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : SetObject
//purpose :
//=======================================================================
void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObject)& theObject)
{
Backup();
Handle(TDataStd_Integer) aType;
if(!Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
{
aType = new TDataStd_Integer();
Label().FindChild(ChildLab_Type).AddAttribute(aType);
}
aType->Set(theObject->GetType());
if(theObject->GetValues().IsNull())
{
Label().FindChild(ChildLab_Value).ForgetAllAttributes();
}
else
{
Handle(TDataStd_RealArray) aVal;
if(!Label().FindChild(ChildLab_Value).FindAttribute(TDataStd_RealArray::GetID(), aVal))
{
aVal = new TDataStd_RealArray();
Label().FindChild(ChildLab_Value).AddAttribute(aVal);
}
aVal->ChangeArray(theObject->GetValues());
}
Handle(TDataStd_Integer) aQualifier;
if(!Label().FindChild(ChildLab_Qualifier).FindAttribute(TDataStd_Integer::GetID(), aQualifier))
{
aQualifier = new TDataStd_Integer();
Label().FindChild(ChildLab_Qualifier).AddAttribute(aQualifier);
}
aQualifier->Set(theObject->GetQualifier());
Standard_Boolean aH;
XCAFDimTolObjects_DimensionFormVariance aF;
XCAFDimTolObjects_DimensionGrade aG;
theObject->GetClassOfTolerance(aH,aF,aG);
Handle(TDataStd_IntegerArray) aClass;
if(!Label().FindChild(ChildLab_Class).FindAttribute(TDataStd_IntegerArray::GetID(), aClass))
{
aClass = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Class).AddAttribute(aClass);
}
Handle(TColStd_HArray1OfInteger) anArrI = new TColStd_HArray1OfInteger(1,3);
anArrI->SetValue(1,aH);
anArrI->SetValue(2,aF);
anArrI->SetValue(3,aG);
aClass->ChangeArray(anArrI);
Standard_Integer aL, aR;
theObject->GetNbOfDecimalPlaces(aL, aR);
Handle(TDataStd_IntegerArray) aDec;
if(!Label().FindChild(ChildLab_Dec).FindAttribute(TDataStd_IntegerArray::GetID(), aDec))
{
aDec = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Dec).AddAttribute(aDec);
}
anArrI = new TColStd_HArray1OfInteger(1,2);
anArrI->SetValue(1,aL);
anArrI->SetValue(2,aR);
aDec->ChangeArray(anArrI);
if(theObject->GetModifiers().Length() == 0)
{
Label().FindChild(ChildLab_Modifiers).ForgetAllAttributes();
}
else
{
Handle(TDataStd_IntegerArray) aModifiers;
if(!Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers))
{
aModifiers = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
}
anArrI = new TColStd_HArray1OfInteger(1,theObject->GetModifiers().Length());
for(Standard_Integer i = 1; i <= theObject->GetModifiers().Length(); i++)
anArrI->SetValue(i,theObject->GetModifiers().Value(i));
aModifiers->ChangeArray(anArrI);
}
if(!theObject->GetPath().IsNull())
{
TNaming_Builder tnBuild(Label().FindChild(ChildLab_Path));
tnBuild.Generated(theObject->GetPath());
}
else
{
Label().FindChild(ChildLab_Path).ForgetAllAttributes();
}
Handle(TDataStd_RealArray) aDir;
if(!Label().FindChild(ChildLab_Dir).FindAttribute(TDataStd_RealArray::GetID(), aDir))
{
aDir = new TDataStd_RealArray();
Label().FindChild(ChildLab_Dir).AddAttribute(aDir);
}
gp_Dir aD;
theObject->GetDirection(aD);
Handle(TColStd_HArray1OfReal) anArrR = new TColStd_HArray1OfReal(1,3);
anArrR->SetValue(1,aD.X());
anArrR->SetValue(2,aD.Y());
anArrR->SetValue(3,aD.Z());
aDir->ChangeArray(anArrR);
Handle(TDataStd_RealArray) aPnts;
if(!Label().FindChild(ChildLab_Pnts).FindAttribute(TDataStd_RealArray::GetID(), aPnts))
{
aPnts = new TDataStd_RealArray();
Label().FindChild(ChildLab_Pnts).AddAttribute(aPnts);
}
Handle(TColgp_HArray1OfPnt) aP = theObject->GetPoints();
if(!aP.IsNull() && aP->Length() > 0)
{
anArrR = new TColStd_HArray1OfReal(1,6);
anArrR->SetValue(1,aP->Value(1).X());
anArrR->SetValue(2,aP->Value(1).Y());
anArrR->SetValue(3,aP->Value(1).Z());
anArrR->SetValue(4,aP->Value(2).X());
anArrR->SetValue(5,aP->Value(2).Y());
anArrR->SetValue(6,aP->Value(2).Z());
aPnts->ChangeArray(anArrR);
}
}
//=======================================================================
//function : GetObject
//purpose :
//=======================================================================
Handle(XCAFDimTolObjects_DimensionObject) XCAFDoc_Dimension::GetObject() const
{
Handle(XCAFDimTolObjects_DimensionObject) anObj = new XCAFDimTolObjects_DimensionObject();
Handle(TDataStd_Integer) aType;
if(Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
{
anObj->SetType((XCAFDimTolObjects_DimensionType)aType->Get());
}
Handle(TDataStd_RealArray) aVal;
if(Label().FindChild(ChildLab_Value).FindAttribute(TDataStd_RealArray::GetID(), aVal)
&& !aVal->Array().IsNull())
{
anObj->SetValues(aVal->Array());
}
Handle(TDataStd_Integer) aQualifier;
if(Label().FindChild(ChildLab_Qualifier).FindAttribute(TDataStd_Integer::GetID(), aQualifier))
{
anObj->SetQualifier((XCAFDimTolObjects_DimensionQualifier)aQualifier->Get());
}
Handle(TDataStd_IntegerArray) aClass;
if(Label().FindChild(ChildLab_Class).FindAttribute(TDataStd_IntegerArray::GetID(), aClass)
&& !aClass->Array().IsNull() && aClass->Array()->Length() > 0)
{
anObj->SetClassOfTolerance(aClass->Array()->Value(1), (XCAFDimTolObjects_DimensionFormVariance)aClass->Array()->Value(2), (XCAFDimTolObjects_DimensionGrade)aClass->Array()->Value(3));
}
Handle(TDataStd_IntegerArray) aDec;
if(Label().FindChild(ChildLab_Dec).FindAttribute(TDataStd_IntegerArray::GetID(), aDec)
&& !aDec->Array().IsNull() && aDec->Array()->Length() > 0)
{
anObj->SetNbOfDecimalPlaces(aDec->Array()->Value(1), aDec->Array()->Value(2));
}
Handle(TDataStd_IntegerArray) aModifiers;
if(Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers)
&& !aModifiers->Array().IsNull())
{
XCAFDimTolObjects_DimensionModifiersSequence aM;
for(Standard_Integer i = 1; i <= aModifiers->Array()->Length(); i++)
aM.Append((XCAFDimTolObjects_DimensionModif)aModifiers->Array()->Value(i));
anObj->SetModifiers(aM);
}
Handle(TNaming_NamedShape) aShape;
if(Label().FindChild(ChildLab_Path).FindAttribute(TNaming_NamedShape::GetID(), aShape)
&& !aShape.IsNull())
{
anObj->SetPath(TopoDS::Edge(aShape->Get()));
}
Handle(TDataStd_RealArray) aDir;
if(Label().FindChild(ChildLab_Dir).FindAttribute(TDataStd_RealArray::GetID(), aDir)
&& !aDir->Array().IsNull() && aDir->Array()->Length() > 0)
{
gp_Dir aD(aDir->Array()->Value(1), aDir->Array()->Value(2), aDir->Array()->Value(3));
anObj->SetDirection(aD);
}
Handle(TDataStd_RealArray) aPnts;
if(Label().FindChild(ChildLab_Pnts).FindAttribute(TDataStd_RealArray::GetID(), aPnts)
&& !aPnts->Array().IsNull() && aPnts->Array()->Length() > 0)
{
Handle(TColgp_HArray1OfPnt) aP = new TColgp_HArray1OfPnt(1,2);
aP->SetValue(1, gp_Pnt(aPnts->Array()->Value(1), aPnts->Array()->Value(2), aPnts->Array()->Value(3)));
aP->SetValue(2, gp_Pnt(aPnts->Array()->Value(4), aPnts->Array()->Value(5), aPnts->Array()->Value(6)));
anObj->SetPoints(aP);
}
return anObj;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& XCAFDoc_Dimension::ID() const
{
return GetID();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void XCAFDoc_Dimension::Restore(const Handle(TDF_Attribute)& /*With*/)
{
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) XCAFDoc_Dimension::NewEmpty() const
{
return new XCAFDoc_Dimension();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void XCAFDoc_Dimension::Paste(const Handle(TDF_Attribute)& /*Into*/,
const Handle(TDF_RelocationTable)& /*RT*/) const
{
}

View File

@@ -0,0 +1,58 @@
-- Created on: 2004-01-09
-- Created by: Sergey KUUL
-- Copyright (c) 2004-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class GeomTolerance from XCAFDoc inherits Attribute from TDF
---Purpose: attribute to store dimension and tolerance
uses
Label from TDF,
RelocationTable from TDF,
GeomToleranceObject from XCAFDimTolObjects
is
Create returns GeomTolerance from XCAFDoc;
Create(theObj : GeomTolerance from XCAFDoc) returns GeomTolerance from XCAFDoc;
---Category: class methods
-- =============
GetID (myclass)
---C++: return const &
returns GUID from Standard;
Set (myclass; theLabel : Label from TDF)
returns GeomTolerance from XCAFDoc;
SetObject (me : mutable; theObject : GeomToleranceObject from XCAFDimTolObjects);
GetObject (me) returns GeomToleranceObject from XCAFDimTolObjects;
ID (me)
---C++: return const &
returns GUID from Standard;
Restore (me: mutable; With : Attribute from TDF);
NewEmpty (me)
returns Attribute from TDF;
Paste (me; Into : Attribute from TDF;
RT : RelocationTable from TDF);
end GeomTolerance;

View File

@@ -0,0 +1,261 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <XCAFDoc_GeomTolerance.ixx>
#include <TDF_RelocationTable.hxx>
#include <XCAFDoc.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_Real.hxx>
enum ChildLab
{
ChildLab_Type = 1,
ChildLab_TypeOfValue,
ChildLab_Value,
ChildLab_MatReqModif,
ChildLab_ZoneModif,
ChildLab_ValueOfZoneModif,
ChildLab_Modifiers,
ChildLab_aMaxValueModif
};
//=======================================================================
//function : XCAFDoc_GeomTolerance
//purpose :
//=======================================================================
XCAFDoc_GeomTolerance::XCAFDoc_GeomTolerance()
{
}
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& XCAFDoc_GeomTolerance::GetID()
{
static Standard_GUID DGTID ("58ed092f-44de-11d8-8776-001083004c77");
//static Standard_GUID ID("efd212e9-6dfd-11d4-b9c8-0060b0ee281b");
return DGTID;
//return ID;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(XCAFDoc_GeomTolerance) XCAFDoc_GeomTolerance::Set (const TDF_Label& theLabel)
{
Handle(XCAFDoc_GeomTolerance) A;
if (!theLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), A)) {
A = new XCAFDoc_GeomTolerance();
theLabel.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : SetObject
//purpose :
//=======================================================================
void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObject)
{
Backup();
Handle(TDataStd_Integer) aType;
if(!Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
{
aType = new TDataStd_Integer();
Label().FindChild(ChildLab_Type).AddAttribute(aType);
}
aType->Set(theObject->GetType());
Handle(TDataStd_Integer) aTypeOfValue;
if(!Label().FindChild(ChildLab_TypeOfValue).FindAttribute(TDataStd_Integer::GetID(), aTypeOfValue))
{
aTypeOfValue = new TDataStd_Integer();
Label().FindChild(ChildLab_TypeOfValue).AddAttribute(aTypeOfValue);
}
aTypeOfValue->Set(theObject->GetTypeOfValue());
Handle(TDataStd_Real) aValue;
if(!Label().FindChild(ChildLab_Value).FindAttribute(TDataStd_Real::GetID(), aValue))
{
aValue = new TDataStd_Real();
Label().FindChild(ChildLab_Value).AddAttribute(aValue);
}
aValue->Set(theObject->GetValue());
Handle(TDataStd_Integer) aMatReqModif;
if(!Label().FindChild(ChildLab_MatReqModif).FindAttribute(TDataStd_Integer::GetID(), aMatReqModif))
{
aMatReqModif = new TDataStd_Integer();
Label().FindChild(ChildLab_MatReqModif).AddAttribute(aMatReqModif);
}
aMatReqModif->Set(theObject->GetMaterialRequirementModifier());
Handle(TDataStd_Integer) aZoneModif;
if(!Label().FindChild(ChildLab_ZoneModif).FindAttribute(TDataStd_Integer::GetID(), aZoneModif))
{
aZoneModif = new TDataStd_Integer();
Label().FindChild(ChildLab_ZoneModif).AddAttribute(aZoneModif);
}
aZoneModif->Set(theObject->GetZoneModifier());
Handle(TDataStd_Real) aValueOfZoneModif;
if(!Label().FindChild(ChildLab_ValueOfZoneModif).FindAttribute(TDataStd_Real::GetID(), aValueOfZoneModif))
{
aValueOfZoneModif = new TDataStd_Real();
Label().FindChild(ChildLab_ValueOfZoneModif).AddAttribute(aValueOfZoneModif);
}
aValueOfZoneModif->Set(theObject->GetValueOfZoneModifier());
if(theObject->GetModifiers().Length() == 0)
{
Label().FindChild(ChildLab_Modifiers).ForgetAllAttributes();
}
else
{
Handle(TDataStd_IntegerArray) aModifiers;
if(!Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers)
|| theObject->GetModifiers().Length() == 0)
{
aModifiers = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
}
Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1,theObject->GetModifiers().Length());
for(Standard_Integer i = 1; i <= theObject->GetModifiers().Length(); i++)
anArr->SetValue(i,theObject->GetModifiers().Value(i));
aModifiers->ChangeArray(anArr);
}
Handle(TDataStd_Real) aMaxValueModif;
if(!Label().FindChild(ChildLab_aMaxValueModif).FindAttribute(TDataStd_Real::GetID(), aMaxValueModif))
{
aMaxValueModif = new TDataStd_Real();
Label().FindChild(ChildLab_aMaxValueModif).AddAttribute(aMaxValueModif);
}
aMaxValueModif->Set(theObject->GetMaxValueModifier());
}
//=======================================================================
//function :GetObject
//purpose :
//=======================================================================
Handle(XCAFDimTolObjects_GeomToleranceObject) XCAFDoc_GeomTolerance::GetObject() const
{
Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = new XCAFDimTolObjects_GeomToleranceObject();
Handle(TDataStd_Integer) aType;
if(Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
{
anObj->SetType((XCAFDimTolObjects_GeomToleranceType)aType->Get());
}
Handle(TDataStd_Integer) aTypeOfValue;
if(Label().FindChild(ChildLab_TypeOfValue).FindAttribute(TDataStd_Integer::GetID(), aTypeOfValue))
{
anObj->SetTypeOfValue((XCAFDimTolObjects_GeomToleranceTypeValue)aTypeOfValue->Get());
}
Handle(TDataStd_Real) aValue;
if(Label().FindChild(ChildLab_Value).FindAttribute(TDataStd_Real::GetID(), aValue))
{
anObj->SetValue(aValue->Get());
}
Handle(TDataStd_Integer) aMatReqModif;
if(Label().FindChild(ChildLab_MatReqModif).FindAttribute(TDataStd_Integer::GetID(), aMatReqModif))
{
anObj->SetMaterialRequirementModifier((XCAFDimTolObjects_GeomToleranceMatReqModif)aMatReqModif->Get());
}
Handle(TDataStd_Integer) aZoneModif;
if(Label().FindChild(ChildLab_ZoneModif).FindAttribute(TDataStd_Integer::GetID(), aZoneModif))
{
anObj->SetZoneModifier((XCAFDimTolObjects_GeomToleranceZoneModif)aZoneModif->Get());
}
Handle(TDataStd_Real) aValueOfZoneModif;
if(Label().FindChild(ChildLab_ValueOfZoneModif).FindAttribute(TDataStd_Real::GetID(), aValueOfZoneModif))
{
anObj->SetValueOfZoneModifier(aValueOfZoneModif->Get());
}
Handle(TDataStd_IntegerArray) anArr;
if(Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), anArr)
&& !anArr->Array().IsNull())
{
XCAFDimTolObjects_GeomToleranceModifiersSequence aModifiers;
for(Standard_Integer i = 1; i <= anArr->Length(); i++)
aModifiers.Append((XCAFDimTolObjects_GeomToleranceModif)anArr->Value(i));
anObj->SetModifiers(aModifiers);
}
Handle(TDataStd_Real) aMaxValueModif;
if(Label().FindChild(ChildLab_aMaxValueModif).FindAttribute(TDataStd_Real::GetID(), aMaxValueModif))
{
anObj->SetMaxValueModifier(aMaxValueModif->Get());
}
return anObj;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& XCAFDoc_GeomTolerance::ID() const
{
return GetID();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void XCAFDoc_GeomTolerance::Restore(const Handle(TDF_Attribute)& /*With*/)
{
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) XCAFDoc_GeomTolerance::NewEmpty() const
{
return new XCAFDoc_GeomTolerance();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void XCAFDoc_GeomTolerance::Paste(const Handle(TDF_Attribute)& /*Into*/,
const Handle(TDF_RelocationTable)& /*RT*/) const
{
}

View File

@@ -28,6 +28,8 @@ is
class Layers;
class GDTs;
class Props;
class Common;

View File

@@ -75,6 +75,7 @@
#include <XDEDRAW_Shapes.hxx>
#include <XDEDRAW_Colors.hxx>
#include <XDEDRAW_GDTs.hxx>
#include <XDEDRAW_Layers.hxx>
#include <XDEDRAW_Props.hxx>
#include <XDEDRAW_Common.hxx>
@@ -600,8 +601,6 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer
else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorGen) ) type = "Generic Color Link";
else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorSurf) ) type = "Surface Color Link";
else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorCurv) ) type = "Curve Color Link";
else if ( att->ID() == XCAFDoc::DimTolRefGUID() ) type = "DGT Link";
else if ( att->ID() == XCAFDoc::DatumRefGUID() ) type = "Datum Link";
else if ( att->ID() == XCAFDoc::MaterialRefGUID() ) type = "Material Link";
Handle(TDataStd_TreeNode) TN = Handle(TDataStd_TreeNode)::DownCast(att);
TCollection_AsciiString ref;
@@ -768,6 +767,12 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer
else if ( att->ID() == XCAFDoc::DatumTolRefGUID() ) {
type = "DatumToler Link";
}
else if ( att->ID() == XCAFDoc::DimTolRefGUID() ){
type = "DGT Link";
}
else if ( att->ID() == XCAFDoc::DatumRefGUID() ){
type = "Datum Link";
}
else return 0;
Handle(XCAFDoc_GraphNode) DETGN = Handle(XCAFDoc_GraphNode)::DownCast(att);
@@ -1140,6 +1145,7 @@ void XDEDRAW::Init(Draw_Interpretor& di)
XDEDRAW_Colors::InitCommands ( di );
XDEDRAW_Layers::InitCommands ( di );
XDEDRAW_Props::InitCommands ( di );
XDEDRAW_GDTs::InitCommands ( di );
XDEDRAW_Common::InitCommands ( di );//moved from EXE
}

View File

@@ -0,0 +1,27 @@
-- Created on: 2015-06-18
-- Created by: Ilya Novikov
-- Copyright (c) 2000-2015 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class GDTs from XDEDRAW
---Purpose: Contains commands to work with G&DTs
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
end GDTs;

2209
src/XDEDRAW/XDEDRAW_GDTs.cxx Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,3 @@
001 export
002 fonts
003 text3d

28
tests/3rdparty/text3d/A1 vendored Normal file
View File

@@ -0,0 +1,28 @@
puts "==========="
puts "0026149: "
puts ""
puts "==========="
pload ALL
vinit View1
vclear
vaxo
set x 10
set y 50
set z 30
box b $x $y $z
vdisplay b
vtrihedron tri0
vdrawtext t0 "Top text in plane yOz" -pos $x 0 $z -color green -height 20 -plane 1 0 0 0 1 0 -valign top
vdrawtext t1 "Bottom text in plane yOz" -pos 0 $y 0 -color green -height 20 -plane -1 0 0 0 -1 0 -valign bottom
vdrawtext t2 "Some text on the top face" -pos $x/2 $y/2 $z -color red -height 20 -plane 0 0 1 0 1 0 -valign center -halign center
vdrawtext t3 "First line\nSecond line" -pos $x/2 0 $z/2 -color 0.0 0.0 1.0 -height 20 -plane 0 -1 0 0 0 1 -valign center -halign center
vfit
vdump ${imagedir}/${casename}.png

46
tests/bugs/vis/bug26304 Normal file
View File

@@ -0,0 +1,46 @@
puts "============"
puts "CR26304"
puts "============"
puts ""
##########################################################################################
puts "Visualization - wrong calculation of point in SelectMgr_RectangularFrustum::DetectedPoint"
##########################################################################################
proc findPoint {theInfoString} {
puts $theInfoString
set aStringArr [split $theInfoString " "]
set aSize [llength $aStringArr]
for {set aIdx 0} {$aIdx < $aSize} {incr aIdx} {
set aItem [lindex $theInfoString $aIdx]
if {[string compare $aItem "Point:"] == 0} {
set aX [string trim [lindex $theInfoString [expr $aIdx + 1]]]
set aY [string trim [lindex $theInfoString [expr $aIdx + 2]]]
set aZ [string trim [lindex $theInfoString [expr $aIdx + 3]]]
return [list $aX $aY $aZ]
}
}
}
pload VISUALIZATION MODELING
vinit View1
vsetdispmode 1
box b 100 100 100
vdisplay b
vfit
vselect 48 258
set anOut [split [vstate -entities] "\n"]
set aPnt [findPoint [lindex $anOut 1]]
vpoint p {*}$aPnt
vfit
vviewparams -scale 22.3 -proj 0.576 -0.78 0.24 -up -0.21 0.136 0.967
vviewparams -at 10.887 16.807 36.2306 -eye 111.071 -118.34 77.44
if {[vreadpixel 103 293 name] != "YELLOW 1"} {
puts "ERROR: Wrong point calculated"
}
vdump ${imagedir}/${casename}.png

2
tests/gdt/begin Normal file
View File

@@ -0,0 +1,2 @@
cpulimit 1000
pload ALL

14
tests/gdt/dimensions/A1 Normal file
View File

@@ -0,0 +1,14 @@
box b 10 10 10
explode b
explode b_1
NewDocument D
XAddShape D b
XAddDimension D b_1_1
#0:1:4:1
XSetDimensionType D 0:1:4:1 14
XSetDimensionValue D 0:1:4:1 1.5
set c_value "1.5"
set c_type "Size_CurveLength"

16
tests/gdt/dimensions/A2 Normal file
View File

@@ -0,0 +1,16 @@
box b 10 10 10
explode b
explode b_1
NewDocument D
XAddShape D b
XAddDimension D b_1_1
#0:1:4:1
XSetDimensionType D 0:1:4:1 15
XSetDimensionValue D 0:1:4:1 2.5
XSetDimensionQualifier D 0:1:4:1 2
set c_value "2.5"
set c_type "Size_Diameter"
set c_qalif "Max"

15
tests/gdt/dimensions/A3 Normal file
View File

@@ -0,0 +1,15 @@
box b 10 10 10
explode b
explode b_1
NewDocument D
XAddShape D b
XAddDimension D b_1_1
#0:1:4:1
XSetDimensionType D 0:1:4:1 14
XSetDimensionRange D 0:1:4:1 1.5 2.5
set c_range "lower 1.5 upper 2.5"
set c_type "Size_CurveLength"

20
tests/gdt/dimensions/A4 Normal file
View File

@@ -0,0 +1,20 @@
box b 10 10 10
explode b
explode b_1
NewDocument D
XAddShape D b
XAddDimension D b_1_1
#0:1:4:1
XSetDimensionType D 0:1:4:1 15
XSetDimensionValue D 0:1:4:1 2.5
XSetDimensionClassOfTol D 0:1:4:1 1 8 7
XSetDimensionNbOfDecimalPlaces D 0:1:4:1 3 3
XAddDimensionModifiers D 0:1:4:1 14 0
set c_value "2.5"
set c_type "Size_Diameter"
set c_class "f6"
set c_d "3.3"
set c_mod "AverageSize, ControlledRadius"

24
tests/gdt/dimensions/A5 Normal file
View File

@@ -0,0 +1,24 @@
box b 10 10 10
box b1 20 20 20 30 30 30
explode b
explode b_1
explode b1
explode b1_1
NewDocument D
XAddShape D b
XAddShape D b1
XAddDimension D b_1_1 b1_1_1
#0:1:4:1
XSetDimensionType D 0:1:4:1 2
XSetDimensionValue D 0:1:4:1 6
XSetDimensionPlusMinusTol D 0:1:4:1 -0.001 0.002
vertex v1 10 10 10
vertex v2 20 20 20
XSetDimensionPoints D 0:1:4:1 v1 v2
set c_value "6"
set c_type "Location_LinearDistance"
set c_pnts "10;10;10 20;20;20"
set c_plusminus "lower -0.001 upper 0.002"

22
tests/gdt/dimensions/A6 Normal file
View File

@@ -0,0 +1,22 @@
box b 10 10 10
box b1 20 20 20 30 30 30
explode b
explode b_1
explode b1
explode b1_1
NewDocument D
XAddShape D b
XAddShape D b1
XAddDimension D b_1_1 b1_1_1
#0:1:4:1
XSetDimensionType D 0:1:4:1 2
XSetDimensionValue D 0:1:4:1 6
XSetDimensionPlusMinusTol D 0:1:4:1 -0.001 0.002
XSetDimensionDir D 0:1:4:1 1 1 0
set c_value "6"
set c_type "Location_LinearDistance"
set c_plusminus "lower -0.001 upper 0.002"
set c_dir "0.70710678118654757;0.70710678118654757;0"

View File

@@ -0,0 +1,12 @@
set c_type 0
set c_value 0
set c_qalif 0
set c_classtol 0
set c_d 0
set c_modif 0
set c_dir 0
set c_pnts 0
set c_range 0
set c_mod 0
set c_plusminus 0
set c_dump 0

57
tests/gdt/dimensions/end Normal file
View File

@@ -0,0 +1,57 @@
set value [XGetDimensionValue D 0:1:4:1]
set type [XGetDimensionType D 0:1:4:1]
set qualif [XGetDimensionQualifier D 0:1:4:1]
set range [XGetDimensionRange D 0:1:4:1]
set classtol [XGetDimensionClassOfTol D 0:1:4:1]
set d [XGetDimensionNbOfDecimalPlaces D 0:1:4:1]
set dir [XGetDimensionDir D 0:1:4:1]
set pnts [XGetDimensionPoints D 0:1:4:1]
set mod [XGetDimensionModifiers D 0:1:4:1]
set plusminus [XGetDimensionPlusMinusTol D 0:1:4:1]
set dump [XDumpDGTs D all]
if { $c_value != 0 && $value != $c_value} {
puts "Error wrong value"
} else {
if { $c_type != 0 && [string compare $type $c_type] != 0} {
puts "Error wrong type"
} else {
if { $c_qalif != 0 && [string compare $qualif $c_qalif] != 0} {
puts "Error wrong qualifier"
} else {
if { $c_classtol != 0 && $classtol != $c_classtol} {
puts "Error wrong class of tolerance"
} else {
if { $c_d != 0 && $d != $c_d} {
puts "Error wrong nbdigit"
} else {
if { $c_modif != 0 && [string compare $modif $c_modif] != 0} {
puts "Error wrong modifiers"
} else {
if { $c_dir != 0 && [string compare $dir $c_dir] != 0} {
puts "Error wrong direction"
} else {
if { $c_pnts != 0 && [string compare $pnts $c_pnts] != 0} {
puts "Error wrong points"
} else {
if { $c_range != 0 && [string compare $range $c_range] != 0} {
puts "Error wrong range"
} else {
if { $c_mod != 0 && [string compare $mod $c_mod] != 0} {
puts "Error wrong modifiers"
} else {
if { $c_plusminus != 0 && [string compare $plusminus $c_plusminus] != 0} {
puts "Error wrong modifiers"
} else {
puts "TEST COMPLETED"
}
}
}
}
}
}
}
}
}
}
}

0
tests/gdt/end Normal file
View File

2
tests/gdt/grids.list Normal file
View File

@@ -0,0 +1,2 @@
001 dimensions
002 tolerances

34
tests/gdt/tolerances/A1 Normal file
View File

@@ -0,0 +1,34 @@
box b 10 10 10
explode b
explode b_1
NewDocument D
XAddShape D b
XAddGeomTolerance D b_1_1
XAddDatum D b_1_2
#0:1:4:1
#0:1:4:2
XSetDatumName D 0:1:4:2 A
XAddDatumModifier D 0:1:4:2 10
XSetDatum D 0:1:4:2 0:1:4:1
XSetToleranceValue D 0:1:4:1 0.5
XSetTypeOfTolerance D 0:1:4:1 1
XSetTypeOfToleranceValue D 0:1:4:1 1
XSetTolMaterialReq D 0:1:4:1 1
XSetTolZoneMod D 0:1:4:1 1
XSetTolZoneModValue D 0:1:4:1 1
XAddTolModifier D 0:1:4:1 6 1
XSetTolMaxValue D 0:1:4:1 1.5
set c_dname "A"
set c_dmod "DistanceVariable"
set c_val "0.5"
set c_type "Angularity"
set c_typev "Diameter"
set c_mat "M"
set c_zone "P"
set c_zonev "1"
set c_mod "Major_Diameter, Common_Zone"
set c_max "1.5"

26
tests/gdt/tolerances/A2 Normal file
View File

@@ -0,0 +1,26 @@
box b 10 10 10
explode b
explode b_1
NewDocument D
XAddShape D b
XAddGeomTolerance D b_1_1
XAddDatum D b_1_2
XAddDatum D b_1_3
#0:1:4:1
#0:1:4:2
#0:1:4:3
XSetDatumName D 0:1:4:2 A
XSetDatumName D 0:1:4:3 B
XAddDatumModifier D 0:1:4:2 10
XSetDatum D 0:1:4:2 0:1:4:1
XSetDatum D 0:1:4:3 0:1:4:1
XSetToleranceValue D 0:1:4:1 0.5
set c_dname "A"
set c_dmod "DistanceVariable"
set c_val "0.5"

View File

@@ -0,0 +1,11 @@
set c_dmod 0
set c_dname 0
set c_val 0
set c_type 0
set c_typev 0
set c_mat 0
set c_zone 0
set c_zonev 0
set c_mod 0
set c_max 0
set c_dump 0

54
tests/gdt/tolerances/end Normal file
View File

@@ -0,0 +1,54 @@
set dmod [XGetDatumModifiers D 0:1:4:2]
set dname [XGetDatumName D 0:1:4:2]
set type [XGetTypeOfTolerance D 0:1:4:1]
set typev [XGetTypeOfToleranceValue D 0:1:4:1]
set val [XGetToleranceValue D 0:1:4:1]
set mat [XGetTolMaterialReq D 0:1:4:1]
set zone [XGetTolZoneMod D 0:1:4:1]
set zonev [XGetTolZoneModValue D 0:1:4:1]
set mod [XGetTolModifier D 0:1:4:1]
set max [XGetTolMaxValue D 0:1:4:1]
set dump [XDumpDGTs D all]
if { $c_dmod != 0 && [string compare $dmod $c_dmod] != 0} {
puts "Error wrong datum modif"
} else {
if { $c_dname != 0 && [string compare $dname $c_dname] != 0} {
puts "Error wrong datum name"
} else {
if { $c_type != 0 && [string compare $type $c_type] != 0} {
puts "Error wrong type"
} else {
if { $c_typev != 0 && [string compare $typev $c_typev] != 0} {
puts "Error wrong type of value"
} else {
if { $c_mat != 0 && [string compare $mat $c_mat] != 0} {
puts "Error wrong mat"
} else {
if { $c_zone != 0 && [string compare $zone $c_zone] != 0} {
puts "Error wrong zone"
} else {
if { $c_zonev != 0 && $zonev != $c_zonev } {
puts "Error wrong zome value"
} else {
if { $c_mod != 0 && [string compare $mod $c_mod] != 0} {
puts "Error wrong modifiers"
} else {
if { $c_max != 0 && $max != $c_max } {
puts "Error wrong maxvalue"
} else {
if { $c_val != 0 && $val != $c_val } {
puts "Error wrong value"
} else {
puts "TEST COMPLETED"
}
}
}
}
}
}
}
}
}
}