Back to index

salome-geom  6.5.0
Defines | Typedefs | Functions | Variables
GEOM_Engine.cxx File Reference
#include "GEOM_Engine.hxx"
#include "GEOM_Solver.hxx"
#include "GEOM_Function.hxx"
#include "GEOM_ISubShape.hxx"
#include "GEOM_SubShapeDriver.hxx"
#include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx"
#include "GEOM_PythonDump.hxx"
#include <Basics_OCCTVersion.hxx>
#include "utilities.h"
#include <Basics_Utils.hxx>
#include <TDF_Tool.hxx>
#include <TDF_Data.hxx>
#include <TDF_Reference.hxx>
#include <TDF_LabelSequence.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_ChildNodeIterator.hxx>
#include <TFunction_Driver.hxx>
#include <TFunction_DriverTable.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDataStd_UAttribute.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDataStd_Comment.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <TColStd_MapOfTransient.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
#include <TDataStd_HArray1OfByte.hxx>
#include <Interface_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
#include <set>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>

Go to the source code of this file.

Defines

#define COMMA   ','
#define O_BRACKET   '('
#define C_BRACKET   ')'
#define O_SQR_BRACKET   '['
#define C_SQR_BRACKET   ']'
#define PY_NULL   "None"
#define TEXTURE_LABEL_ID   1
#define TEXTURE_LABEL_FILE   2
#define TEXTURE_LABEL_WIDTH   3
#define TEXTURE_LABEL_HEIGHT   4
#define TEXTURE_LABEL_DATA   5

Typedefs

typedef std::map
< TCollection_AsciiString,
TCollection_AsciiString > 
TSting2StringMap
typedef std::map
< TCollection_AsciiString,
TObjectData
TSting2ObjDataMap
typedef std::map
< TCollection_AsciiString,
TObjectData * > 
TSting2ObjDataPtrMap

Functions

static TCollection_AsciiString BuildIDFromObject (Handle(GEOM_Object)&theObject)
static TCollection_AsciiString BuildID (Standard_Integer theDocID, char *theEntry)
static Standard_Integer ExtractDocID (TCollection_AsciiString &theID)
bool ProcessFunction (Handle(GEOM_Function)&theFunction, TCollection_AsciiString &theScript, TCollection_AsciiString &theAfterScript, const TVariablesList &theVariables, const bool theIsPublished, TDF_LabelMap &theProcessed, std::set< TCollection_AsciiString > &theIgnoreObjs, bool &theIsDumpCollected)
 ProcessFunction: Dump fucntion description into script.
void ReplaceVariables (TCollection_AsciiString &theCommand, const TVariablesList &theVariables)
 ReplaceVariables: Replace parameters of the function by variales from Notebook if need.
 Handle (TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString &theString)
 FindEntries: Returns a sequence of start/end positions of entries in the string.
void ReplaceEntriesByNames (TCollection_AsciiString &theScript, TSting2ObjDataMap &aEntry2ObjData, const bool theIsPublished, TColStd_SequenceOfAsciiString &theObjListToPublish, Standard_Integer &objectCounter, Resource_DataMapOfAsciiStringAsciiString &aNameToEntry)
 ReplaceEntriesByNames: Replace object entries by their names.
void AddObjectColors (int theDocID, TCollection_AsciiString &theScript, const TSting2ObjDataMap &theEntry2ObjData)
 AddObjectColors: Add color to objects.
void AddTextures (int theDocID, TCollection_AsciiString &theScript)
void PublishObject (TObjectData &theObjectData, TSting2ObjDataMap &theEntry2ObjData, const TSting2ObjDataPtrMap &theStEntry2ObjDataPtr, Resource_DataMapOfAsciiStringAsciiString &theNameToEntry, std::map< int, TCollection_AsciiString > &theEntryToCmdMap, std::set< TCollection_AsciiString > &theIgnoreMap)
 PublishObject: publish object in study script.
 Handle (TDocStd_Document) GEOM_Engine
 GetDocument.
 Handle (GEOM_Object) GEOM_Engine
 GetObject.
 Handle (TColStd_HSequenceOfAsciiString) GEOM_Engine
 Handle (TDataStd_HArray1OfByte) GEOM_Engine
static TCollection_AsciiString pack_data (const Handle(TDataStd_HArray1OfByte)&aData)

Variables

static int MYDEBUG = 0
static GEOM_EngineTheEngine = NULL

Define Documentation

#define C_BRACKET   ')'

Definition at line 81 of file GEOM_Engine.cxx.

#define C_SQR_BRACKET   ']'

Definition at line 83 of file GEOM_Engine.cxx.

#define COMMA   ','

Definition at line 79 of file GEOM_Engine.cxx.

#define O_BRACKET   '('

Definition at line 80 of file GEOM_Engine.cxx.

#define O_SQR_BRACKET   '['

Definition at line 82 of file GEOM_Engine.cxx.

#define PY_NULL   "None"

Definition at line 84 of file GEOM_Engine.cxx.

#define TEXTURE_LABEL_DATA   5

Definition at line 827 of file GEOM_Engine.cxx.

#define TEXTURE_LABEL_FILE   2

Definition at line 824 of file GEOM_Engine.cxx.

#define TEXTURE_LABEL_HEIGHT   4

Definition at line 826 of file GEOM_Engine.cxx.

#define TEXTURE_LABEL_ID   1

Definition at line 823 of file GEOM_Engine.cxx.

#define TEXTURE_LABEL_WIDTH   3

Definition at line 825 of file GEOM_Engine.cxx.


Typedef Documentation

typedef std::map< TCollection_AsciiString, TObjectData > TSting2ObjDataMap

Definition at line 93 of file GEOM_Engine.cxx.

typedef std::map< TCollection_AsciiString, TObjectData* > TSting2ObjDataPtrMap

Definition at line 94 of file GEOM_Engine.cxx.

typedef std::map< TCollection_AsciiString, TCollection_AsciiString > TSting2StringMap

Definition at line 92 of file GEOM_Engine.cxx.


Function Documentation

void AddObjectColors ( int  theDocID,
TCollection_AsciiString &  theScript,
const TSting2ObjDataMap theEntry2ObjData 
)

AddObjectColors: Add color to objects.

Definition at line 1403 of file GEOM_Engine.cxx.

{
  GEOM_Engine* engine = GEOM_Engine::GetEngine();
  Handle(TDocStd_Document) aDoc = engine->GetDocument(theDocID);

  TSting2ObjDataMap::const_iterator anEntryToNameIt;
  for (anEntryToNameIt = theEntry2ObjData.begin();
       anEntryToNameIt!= theEntry2ObjData.end();
       ++anEntryToNameIt)
  {
    const TCollection_AsciiString& aEntry = anEntryToNameIt->first;
    const TCollection_AsciiString& aName = anEntryToNameIt->second._pyName;

    TDF_Label L;
    TDF_Tool::Label( aDoc->GetData(), aEntry, L );
    if ( L.IsNull() )
      continue;

    Handle(GEOM_Object) obj = GEOM_Object::GetObject( L );
    if ( obj.IsNull() )
      continue;

    bool anAutoColor = obj->GetAutoColor();
    if ( anAutoColor )
    {
      TCollection_AsciiString aCommand( "\n\t" );
      aCommand += aName + ".SetAutoColor(1)";
      theScript += aCommand.ToCString();
    }

    GEOM_Object::Color aColor = obj->GetColor();
    if ( aColor.R >= 0 && aColor.G >= 0 && aColor.B >= 0 )
    {
      TCollection_AsciiString aCommand( "\n\t" );
      aCommand += aName + ".SetColor(SALOMEDS.Color(" + aColor.R + "," + aColor.G + "," + aColor.B + "))";
      theScript += aCommand.ToCString();
    }

    Aspect_TypeOfMarker aMarkerType = obj->GetMarkerType();
    if (aMarkerType >= Aspect_TOM_POINT && aMarkerType < Aspect_TOM_USERDEFINED) {
      TCollection_AsciiString aCommand( "\n\t" );
      aCommand += aName + ".SetMarkerStd(";
      switch (aMarkerType) {
      case Aspect_TOM_POINT:   aCommand += "GEOM.MT_POINT";   break;
      case Aspect_TOM_PLUS:    aCommand += "GEOM.MT_PLUS";    break;
      case Aspect_TOM_STAR:    aCommand += "GEOM.MT_STAR";    break;
      case Aspect_TOM_O:       aCommand += "GEOM.MT_O";       break;
      case Aspect_TOM_X:       aCommand += "GEOM.MT_X";       break;
      case Aspect_TOM_O_POINT: aCommand += "GEOM.MT_O_POINT"; break;
      case Aspect_TOM_O_PLUS:  aCommand += "GEOM.MT_O_PLUS";  break;
      case Aspect_TOM_O_STAR:  aCommand += "GEOM.MT_O_STAR";  break;
      case Aspect_TOM_O_X:     aCommand += "GEOM.MT_O_X";     break;
      case Aspect_TOM_BALL:    aCommand += "GEOM.MT_BALL";    break;
      case Aspect_TOM_RING1:   aCommand += "GEOM.MT_RING1";   break;
      case Aspect_TOM_RING2:   aCommand += "GEOM.MT_RING2";   break;
      case Aspect_TOM_RING3:   aCommand += "GEOM.MT_RING3";   break;
      default:                 aCommand += "GEOM.MT_NONE";    break; // just for completeness, should not get here
      }
      aCommand += ", ";
      int aSize = (int)( obj->GetMarkerSize()/0.5 ) - 1;
      switch (aSize) {
      case  1: aCommand += "GEOM.MS_10";   break;
      case  2: aCommand += "GEOM.MS_15";   break;
      case  3: aCommand += "GEOM.MS_20";   break;
      case  4: aCommand += "GEOM.MS_25";   break;
      case  5: aCommand += "GEOM.MS_30";   break;
      case  6: aCommand += "GEOM.MS_35";   break;
      case  7: aCommand += "GEOM.MS_40";   break;
      case  8: aCommand += "GEOM.MS_45";   break;
      case  9: aCommand += "GEOM.MS_50";   break;
      case 10: aCommand += "GEOM.MS_55";   break;
      case 11: aCommand += "GEOM.MS_60";   break;
      case 12: aCommand += "GEOM.MS_65";   break;
      case 13: aCommand += "GEOM.MS_70";   break;
      default: aCommand += "GEOM.MS_NONE"; break;
      }
      aCommand += ")";
      theScript += aCommand.ToCString();
    }
    else if (aMarkerType == Aspect_TOM_USERDEFINED) {
      int aMarkerTextureID = obj->GetMarkerTexture();
      if (aMarkerTextureID >= 0) {
        TCollection_AsciiString aCommand( "\n\t" );
        aCommand += aName + ".SetMarkerTexture(texture_map[";
        aCommand += aMarkerTextureID;
        aCommand += "])";
        theScript += aCommand.ToCString();
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AddTextures ( int  theDocID,
TCollection_AsciiString &  theScript 
)

Definition at line 1516 of file GEOM_Engine.cxx.

{
  GEOM_Engine* engine = GEOM_Engine::GetEngine();
  std::list<int> allTextures = engine->getAllTextures(theDocID);
  std::list<int>::const_iterator it;

  if (allTextures.size() > 0) {
    theScript += "\n\ttexture_map = {}\n";

    for (it = allTextures.begin(); it != allTextures.end(); ++it) {
      if (*it <= 0) continue;
      Standard_Integer aWidth, aHeight;
      TCollection_AsciiString aFileName;
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
      Handle(TColStd_HArray1OfByte) aTexture =
#else
      Handle(TDataStd_HArray1OfByte) aTexture =
#endif
        engine->getTexture(theDocID, *it, aWidth, aHeight, aFileName);
      if (aWidth > 0 && aHeight > 0 && !aTexture.IsNull() && aTexture->Length() > 0 ) {
        TCollection_AsciiString aCommand = "\n\t";
        aCommand += "texture_map["; aCommand += *it; aCommand += "] = ";
        if (aFileName != "" ) {
          aCommand += "geompy.LoadTexture(\"";
          aCommand += aFileName.ToCString();
          aCommand += "\")";
        }
        else {
          aCommand += "geompy.AddTexture(";
          aCommand += aWidth; aCommand += ", "; aCommand += aHeight; aCommand += ", \"";
          aCommand += pack_data(aTexture);
          aCommand += "\")";
        }
        theScript += aCommand;
      }
    }
    theScript += "\n";
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static TCollection_AsciiString BuildID ( Standard_Integer  theDocID,
char *  theEntry 
) [static]

Definition at line 107 of file GEOM_Engine.cxx.

{
  TCollection_AsciiString anID(theDocID);
  anID+=(TCollection_AsciiString("_")+theEntry);
  return anID;
}

Here is the caller graph for this function:

static TCollection_AsciiString BuildIDFromObject ( Handle(GEOM_Object)&  theObject) [static]

Definition at line 99 of file GEOM_Engine.cxx.

{
  TCollection_AsciiString anID(theObject->GetDocID()), anEntry;
  TDF_Tool::Entry(theObject->GetEntry(), anEntry);
  anID+=(TCollection_AsciiString("_")+anEntry);
  return anID;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Standard_Integer ExtractDocID ( TCollection_AsciiString &  theID) [static]

Definition at line 114 of file GEOM_Engine.cxx.

{
  TCollection_AsciiString aDocID = theID.Token("_");
  if(aDocID.Length() < 1) return -1;
  return aDocID.IntegerValue();
}

Here is the caller graph for this function:

Handle ( TColStd_HSequenceOfInteger  )

FindEntries: Returns a sequence of start/end positions of entries in the string.

Find IDs of sub-shapes complying with given status about quadrangle.

GetShapesOnSphereIDs.

GetShapesOnCylinderWithLocationIDs.

GetShapesOnCylinderIDs.

GetShapesOnPlaneWithLocationIDs.

GetShapesOnPlaneIDs.

Find sub-shapes complying with given status about surface.

Find IDs of sub-shapes complying with given status about surface.

GetFreeFacesIDs.

Parameters:
theBox- the box to check state of sub-shapes against
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theState- required state
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes
Parameters:
theCheckShape- the shape to check state of sub-shapes against
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theState- required state
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes
Parameters:
theSurface- the surface to check state of sub-shapes against
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theState- required state
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes
Parameters:
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theTopLeftPoint- top left quadrangle corner
theTopRigthPoint- top right quadrangle corner
theBottomLeftPoint- bottom left quadrangle corner
theBottomRigthPoint- bottom right quadrangle corner
theState- required state
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes

Definition at line 1054 of file GEOM_Engine.cxx.

{
  Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
  Standard_Integer aLen = theString.Length();
  Standard_Boolean isFound = Standard_False;

  const char* arr = theString.ToCString();
  Standard_Integer i = 0, j;

  while(i < aLen) {
    int c = (int)arr[i];
    j = i+1;
    if(c >= 48 && c <= 57) { //Is digit?

      isFound = Standard_False;
      while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry
        c = (int)arr[j++];
        if(c == 58) isFound = Standard_True;
      }

      if(isFound && arr[j-2] != 58) { // last char should be a diggit
        aSeq->Append(i+1); // +1 because AsciiString starts from 1
        aSeq->Append(j-1);
      }
    }

    i = j;
  }

  return aSeq;
}

Here is the call graph for this function:

Handle ( TDocStd_Document  )

GetDocument.

Definition at line 258 of file GEOM_Engine.cxx.

{
  Handle(TDocStd_Document) aDoc;
  if(_mapIDDocument.IsBound(theDocID)) {
    aDoc = Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID));
  }
  else if (force) {
    _OCAFApp->NewDocument("SALOME_GEOM", aDoc);
    aDoc->SetUndoLimit(_UndoLimit);
    _mapIDDocument.Bind(theDocID, aDoc);
    TDataStd_Integer::Set(aDoc->Main(), theDocID);
  }
  return aDoc;
}

Here is the call graph for this function:

GetObject.

TransformLikeOtherCopy.

RotateThreePointsCopy.

RotateThreePoints.

Rotate2D.

Rotate1D.

Rotate.

PositionAlongPath.

PositionShapeCopy.

PositionShape.

ScaleShapeAlongAxes.

ScaleShapeCopy.

ScaleShape.

ProjectShapeCopy.

OffsetShapeCopy.

OffsetShape.

MirrorAxisCopy.

MirrorAxis.

MirrorPointCopy.

MirrorPoint.

MirrorPlaneCopy.

TranslateShape1D.

Translate2D.

Translate1D.

TranslateVectorDistance.

TranslateVectorCopy.

TranslateVector.

TranslateDXDYDZCopy.

TranslateTwoPointsCopy.

TranslateDXDYDZ.

case GetInPlaceOld: default:

case GetInPlace: default:

ReverseShape.

GetSubShape.

MakeGlueEdgesByList.

MakeGlueEdges.

GetGlueFaces.

MakeGlueFaces.

MakeShape.

MakeCompound.

MakeSolidShells.

MakeShell.

MakeFaceWires.

MakeFace.

MakeWire.

MakeEdgeWire.

MakeEdgeOnCurveByLength.

GetNormal.

GetVertexByIndex.

Archimede.

MakeChamferEdgesAD.

MakeChamferEdges.

MakeChamferFacesAD.

MakeChamferFaces.

MakeChamferEdgeAD.

MakeChamferEdge.

MakeChamferAll.

MakeFillet1D.

MakeFillet2D.

MakeFilletFaces R1 R2.

MakeFilletFaces.

MakeFilletEdges R1 R2.

MakeFilletEdges.

Import.

LimitTolerance.

ChangeOrientationCopy.

ChangeOrientation.

DivideEdge.

Sew.

FillHoles.

RemoveIntWires.

CloseContour.

SuppressFaces.

GetMainShape.

MakeSketcherOnPlane.

Make3DSketcher.

MakeSketcher.

MakeCurveParametric.

MakeSplineInterpolation.

MakeSplineBezier.

MakePolyline.

MakeArcOfEllipse.

MakeArcCenter.

MakeArc.

MakeEllipse.

MakeCirclePntVecR.

MakeCircleCenter2Pnt.

MakeHalfPartition.

MakePartition.

MakeMultiTransformation2D.

MakeMultiTransformation1D.

GetBlockByParts.

GetBlockNearPoint.

CheckAndImprove.

RemoveExtraEdges.

GetShapesNearPoint.

GetFaceByNormale.

GetFaceNearPoint.

GetOppositeFace.

GetFaceByEdges.

GetFaceByPoints.

GetEdgeNearPoint.

GetEdge.

GetVertexNearPoint.

GetPoint.

MakeBlockCompound.

MakeHexa2Faces.

MakeHexa.

MakeQuad4Vertices.

MakeQuad2Edges.

MakeTangentPlaneOnFace.

MakeMarkerPntTwoVec.

MakeMarkerFromShape.

MakeMarker.

MakePlaneLCS.

MakePlane2Vec.

MakePlaneFace.

MakePlanePntVec.

MakePlaneThreePnt.

MakeLineTwoFaces.

MakeLineTwoPnt.

MakeLine.

MakeVectorTwoPnt.

MakeVectorDXDYDZ.

MakeTangentOnCurve.

MakePointOnLinesIntersection.

MakePointOnSurfaceByCoord.

MakePointOnSurface.

MakePointOnCurveByLength.

MakePointOnCurveByCoord.

MakePointOnCurve.

makePointOnGeom

MakePointWithReference.

MakePipeBiNormalAlongVector.

MakePipeShellsWithoutPath.

MakePipeWithShellSections.

MakePipeWithDifferentSections.

MakeThruSections.

MakeFilling.

MakeRevolutionAxisAngle2Ways.

MakeRevolutionAxisAngle.

MakePipe.

MakeDraftPrism.

MakePrismDXDYDZ_2WAYS.

MakePrismDXDYDZ.

MakePrismTwoPnt2Ways.

MakePrismTwoPnt.

MakePrismVecH2Ways.

MakePrismVecH.

MakeTorusPntVecRR.

MakeTorusRR.

MakeSpherePntR.

MakeSphereR.

MakeConePntVecR1R2H.

MakeConeR1R2H.

MakeCylinderPntVecRH.

MakeCylinderRH.

MakeDiskR.

MakeDiskThreePnt.

MakeDiskPntVecR.

MakeFaceObjHW.

MakeFaceHW.

MakeBoxTwoPnt.

GetReferencedObject.

AddSubShape.

AddObject.

MakeGlueFacesByList

TranslateShape2D

MirrorPlane

Definition at line 297 of file GEOM_Engine.cxx.

{
  Handle(GEOM_Object) anObject;

  TCollection_AsciiString anID = BuildID(theDocID, theEntry);

  if (_objects.IsBound(anID)) {
    anObject = Handle(GEOM_Object)::DownCast(_objects(anID));
  }
  else if (force) {
    Handle(TDocStd_Document) aDoc = GetDocument(theDocID, force);
    if ( !aDoc.IsNull()) {
      TDF_Label aLabel;
      TDF_Tool::Label(aDoc->Main().Data(), theEntry, aLabel, Standard_True);
      anObject = new GEOM_Object(aLabel);
      _objects.Bind(anID, anObject);
    }
  }

  return anObject;
}
Handle ( TColStd_HSequenceOfAsciiString  )

Definition at line 811 of file GEOM_Engine.cxx.

{
  Handle(TColStd_HSequenceOfAsciiString) aRetSeq = new TColStd_HSequenceOfAsciiString;

  Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString it (_studyEntry2NameMap);
  for (; it.More(); it.Next()) {
    aRetSeq->Append(it.Value());
  }

  return aRetSeq;
}

Here is the call graph for this function:

Handle ( TDataStd_HArray1OfByte  )

Definition at line 882 of file GEOM_Engine.cxx.

{
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
  Handle(TColStd_HArray1OfByte) anArray;
#else
  Handle(TDataStd_HArray1OfByte) anArray;
#endif
  theWidth = theHeight = 0;

  Handle(TDocStd_Document) aDoc = GetDocument(theDocID);

  TDF_ChildIterator anIterator(aDoc->Main(), Standard_True);
  bool found = false;
  for (; anIterator.More() && !found; anIterator.Next()) {
    TDF_Label aTextureLabel = anIterator.Value();
    if (aTextureLabel.IsAttribute( GetTextureGUID())) {
      TDF_Label anIDLabel = aTextureLabel.FindChild(TEXTURE_LABEL_ID, Standard_False);
      Handle(TDataStd_Integer) anIdAttr;
      if(!anIDLabel.IsNull() && anIDLabel.FindAttribute(TDataStd_Integer::GetID(), anIdAttr) &&
         anIdAttr->Get() == theTextureID) {
        TDF_Label aFileLabel   = aTextureLabel.FindChild(TEXTURE_LABEL_FILE,    Standard_False);
        TDF_Label aWidthLabel  = aTextureLabel.FindChild(TEXTURE_LABEL_WIDTH,   Standard_False);
        TDF_Label aHeightLabel = aTextureLabel.FindChild(TEXTURE_LABEL_HEIGHT,  Standard_False);
        TDF_Label aDataLabel   = aTextureLabel.FindChild(TEXTURE_LABEL_DATA,    Standard_False);
        Handle(TDataStd_Integer) aWidthAttr, aHeightAttr;
        Handle(TDataStd_ByteArray) aTextureAttr;
        Handle(TDataStd_Comment) aFileAttr;
        if (!aWidthLabel.IsNull()  && aWidthLabel.FindAttribute(TDataStd_Integer::GetID(),  aWidthAttr) &&
            !aHeightLabel.IsNull() && aHeightLabel.FindAttribute(TDataStd_Integer::GetID(), aHeightAttr) &&
            !aDataLabel.IsNull()   && aDataLabel.FindAttribute(TDataStd_ByteArray::GetID(), aTextureAttr)) {
          theWidth = aWidthAttr->Get();
          theHeight = aHeightAttr->Get();
          anArray = aTextureAttr->InternalArray();
        }
        if (!aFileLabel.IsNull() && aFileLabel.FindAttribute(TDataStd_Comment::GetID(), aFileAttr))
          theFileName = aFileAttr->Get();
        found = true;
      }
    }
  }
  return anArray;
}

Here is the call graph for this function:

static TCollection_AsciiString pack_data ( const Handle(TDataStd_HArray1OfByte)&  aData) [static]

Definition at line 1500 of file GEOM_Engine.cxx.

{
  TCollection_AsciiString stream;
  if (!aData.IsNull()) {
    for (Standard_Integer i = aData->Lower(); i <= aData->Upper(); i++) {
      Standard_Byte byte = aData->Value(i);
      TCollection_AsciiString strByte = "";
      for (int j = 0; j < 8; j++)
        strByte.Prepend((byte & (1<<j)) ? "1" : "0");
      stream += strByte;
    }
  }
  return stream;
}

Here is the caller graph for this function:

bool ProcessFunction ( Handle(GEOM_Function)&  theFunction,
TCollection_AsciiString &  theScript,
TCollection_AsciiString &  theAfterScript,
const TVariablesList theVariables,
const bool  theIsPublished,
TDF_LabelMap &  theProcessed,
std::set< TCollection_AsciiString > &  theIgnoreObjs,
bool &  theIsDumpCollected 
)

ProcessFunction: Dump fucntion description into script.

Definition at line 956 of file GEOM_Engine.cxx.

{
  theIsDumpCollected = false;
  if (theFunction.IsNull()) return false;

  if (theProcessed.Contains(theFunction->GetEntry())) return false;

  // pass functions, that depends on nonexisting ones
  bool doNotProcess = false;
  TDF_LabelSequence aSeq;
  theFunction->GetDependency(aSeq);
  Standard_Integer aLen = aSeq.Length();
  for (Standard_Integer i = 1; i <= aLen && !doNotProcess; i++) {
    TDF_Label aRefLabel = aSeq.Value(i);
    Handle(TDF_Reference) aRef;
    if (!aRefLabel.FindAttribute(TDF_Reference::GetID(), aRef)) {
      doNotProcess = true;
    }
    else {
      if (aRef.IsNull() || aRef->Get().IsNull()) {
        doNotProcess = true;
      }
      else {
        Handle(TDataStd_TreeNode) aT;
        if (!TDataStd_TreeNode::Find(aRef->Get(), aT)) {
          doNotProcess = true;
        }
        else {
          TDF_Label aDepLabel = aT->Label();
          Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(aDepLabel);

          if (aFunction.IsNull()) doNotProcess = true;
          else if (!theProcessed.Contains(aDepLabel)) doNotProcess = true;
        }
      }
    }
  }

  if (doNotProcess) {
    TCollection_AsciiString anObjEntry;
    TDF_Tool::Entry(theFunction->GetOwnerEntry(), anObjEntry);
    theIgnoreObjs.insert(anObjEntry);
    return false;
  }
  theProcessed.Add(theFunction->GetEntry());

  TCollection_AsciiString aDescr = theFunction->GetDescription();
  if(aDescr.Length() == 0) return false;

  //Check if its internal function which doesn't requires dumping
  if(aDescr == "None") return false;

  // 0020001 PTv, check for critical functions, which require dump of objects
  if (theIsPublished)
  {
    // currently, there is only one function "RestoreGivenSubShapes",
    // later this check could be replaced by iterations on list of such functions
    if (aDescr.Search( "RestoreGivenSubShapes" ) != -1)
      theIsDumpCollected = true;
    else if (aDescr.Search( "RestoreSubShapes" ) != -1)
      theIsDumpCollected = true;
  }

  //Replace parameter by notebook variables
  ReplaceVariables(aDescr,theVariables);
  if ( theIsDumpCollected ) {
    int i = 1;
    bool isBefore = true;
    TCollection_AsciiString aSubStr = aDescr.Token("\n\t", i++);
    while (!aSubStr.IsEmpty()) {
      if (isBefore &&
          aSubStr.Search( "RestoreGivenSubShapes" ) == -1 &&
          aSubStr.Search( "RestoreSubShapes" ) == -1)
        theScript += TCollection_AsciiString("\n\t") + aSubStr;
      else
        theAfterScript += TCollection_AsciiString("\n\t") + aSubStr;
      aSubStr = aDescr.Token("\n\t", i++);
    }
  }
  else {
    theScript += "\n\t";
    theScript += aDescr;
  }
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PublishObject ( TObjectData theObjectData,
TSting2ObjDataMap theEntry2ObjData,
const TSting2ObjDataPtrMap theStEntry2ObjDataPtr,
Resource_DataMapOfAsciiStringAsciiString &  theNameToEntry,
std::map< int, TCollection_AsciiString > &  theEntryToCmdMap,
std::set< TCollection_AsciiString > &  theMapOfPublished 
)

PublishObject: publish object in study script.

Definition at line 1561 of file GEOM_Engine.cxx.

{
  if ( theObjectData._studyEntry.IsEmpty() )
    return; // was not published
  if ( theIgnoreMap.count( theObjectData._entry ) )
    return; // not to publish

  TCollection_AsciiString aCommand("\n\tgeompy.");

  // find a father entry
  TObjectData* aFatherData = 0;
  TCollection_AsciiString aFatherStudyEntry =
    theObjectData._studyEntry.SubString( 1, theObjectData._studyEntry.SearchFromEnd(":") - 1 );
  TSting2ObjDataPtrMap::const_iterator stEntry2DataPtr =
    theStEntry2ObjDataPtr.find( aFatherStudyEntry );
  if ( stEntry2DataPtr != theStEntry2ObjDataPtr.end() )
    aFatherData = stEntry2DataPtr->second;

  const int geomObjDepth = 3;

  // treat multiply published object
  if ( theObjectData._pyName.IsEmpty() )
  {
    TObjectData& data0 = theEntry2ObjData[ theObjectData._entry ];
    if ( data0._pyName.IsEmpty() ) return; // something wrong

    theObjectData._pyName = theObjectData._name;
    healPyName( theObjectData._pyName, theObjectData._entry, theNameToEntry);

    TCollection_AsciiString aCreationCommand("\n\t");
    aCreationCommand += theObjectData._pyName + " = " + data0._pyName;

    // store aCreationCommand before publishing commands
    int tag = theObjectData._entry.Token( ":", geomObjDepth ).IntegerValue();
    theEntryToCmdMap.insert( std::make_pair( tag + 2*theEntry2ObjData.size(), aCreationCommand ));
  }

  // make a command
  if ( aFatherData && !aFatherData->_pyName.IsEmpty() ) {
    aCommand += "addToStudyInFather( ";
    aCommand += aFatherData->_pyName + ", ";
  }
  else {
    aCommand += "addToStudy( ";
  }
  aCommand += theObjectData._pyName + ", '" + theObjectData._name + "' )";

  // bind a command to the study entry
  int tag = theObjectData._entry.Token( ":", geomObjDepth ).IntegerValue();
  theEntryToCmdMap.insert( std::make_pair( tag, aCommand ));

  theObjectData._studyEntry.Clear(); // not to publish any more
}

Here is the caller graph for this function:

void ReplaceEntriesByNames ( TCollection_AsciiString &  theScript,
TSting2ObjDataMap aEntry2ObjData,
const bool  theIsPublished,
TColStd_SequenceOfAsciiString &  theObjListToPublish,
Standard_Integer &  objectCounter,
Resource_DataMapOfAsciiStringAsciiString &  aNameToEntry 
)

ReplaceEntriesByNames: Replace object entries by their names.

Definition at line 1352 of file GEOM_Engine.cxx.

{
  Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(theScript);
  Standard_Integer aLen = aSeq->Length(), aStart = 1, aScriptLength = theScript.Length();

  //Replace entries by the names
  TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("geomObj_"),
    allowedChars ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_");
  if (aLen == 0) anUpdatedScript = theScript;

  for (Standard_Integer i = 1; i <= aLen; i+=2) {
    anUpdatedScript += theScript.SubString(aStart, aSeq->Value(i)-1);
    anEntry = theScript.SubString(aSeq->Value(i), aSeq->Value(i+1));
    theObjListToPublish.Append( anEntry );
    
    TObjectData& data = aEntry2ObjData[ anEntry ];
    if ( data._pyName.IsEmpty() ) { // encounted for the 1st time
      if ( !data._name.IsEmpty() ) { // published object
        data._pyName = data._name;
        healPyName( data._pyName, anEntry, aNameToEntry);
      }
      else {
        do {
          data._pyName = aBaseName + TCollection_AsciiString(++objectCounter);
        } while(aNameToEntry.IsBound(data._pyName));
      }
    }
    
    aNameToEntry.Bind(data._pyName, anEntry); // to detect same name of diff objects
    
    anUpdatedScript += data._pyName;
    aStart = aSeq->Value(i+1) + 1;
  }
  
  //Add final part of the script
  if (aLen && aSeq->Value(aLen) < aScriptLength)
    anUpdatedScript += theScript.SubString(aSeq->Value(aLen)+1, aScriptLength); // mkr : IPAL11865
  
  theScript = anUpdatedScript;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ReplaceVariables ( TCollection_AsciiString &  theCommand,
const TVariablesList theVariables 
)

ReplaceVariables: Replace parameters of the function by variales from Notebook if need.

Definition at line 1092 of file GEOM_Engine.cxx.

{
  if (MYDEBUG)
    cout<<"Command : "<<theCommand<<endl;

  if (MYDEBUG) {
    cout<<"All Entries:"<<endl;
    TVariablesList::const_iterator it = theVariables.begin();
    for(;it != theVariables.end();it++)
      cout<<"\t'"<<(*it).first<<"'"<<endl;
  }

  //Additional case - multi-row commands
  int aCommandIndex = 1;
  while( aCommandIndex < 10 ) { // tmp check
    TCollection_AsciiString aCommand = theCommand.Token("\n",aCommandIndex);
    if( aCommand.Length() == 0 )
      break;

    if (MYDEBUG)
      cout<<"Sub-command : "<<aCommand<<endl;

    Standard_Integer aStartCommandPos = theCommand.Location(aCommand,1,theCommand.Length());
    Standard_Integer aEndCommandPos = aStartCommandPos + aCommand.Length();

    //Get Entry of the result object
    TCollection_AsciiString anEntry;
    if( aCommand.Search("=") != -1 ) // command returns an object
      anEntry = aCommand.Token("=",1);
    else { // command modifies the object
      if (int aStartEntryPos = aCommand.Location(1,'(',1,aCommand.Length()))
        if (int aEndEntryPos = aCommand.Location(1,',',aStartEntryPos,aCommand.Length()))
          anEntry = aCommand.SubString(aStartEntryPos+1, aEndEntryPos-1);
    }
    //Remove white spaces
    anEntry.RightAdjust();
    anEntry.LeftAdjust();
    if(MYDEBUG)
      cout<<"Result entry : '" <<anEntry<<"'"<<endl;

    if ( anEntry.IsEmpty() ) {
      aCommandIndex++;
      continue;
    }

    //Check if result is list of entries - enough to get the first entry in this case
    int aNbEntries = 1;
    if( anEntry.Value( 1 ) == O_SQR_BRACKET && anEntry.Value( anEntry.Length() ) == C_SQR_BRACKET ) {
      while(anEntry.Location(aNbEntries,COMMA,1,anEntry.Length()))
        aNbEntries++;
      TCollection_AsciiString aSeparator(COMMA);
      anEntry = anEntry.Token(aSeparator.ToCString(),1);
      anEntry.Remove( 1, 1 );
      anEntry.RightAdjust();
      anEntry.LeftAdjust();
      if(MYDEBUG)
        cout<<"Sub-entry : '" <<anEntry<<"'"<<endl;
    }

    //Find variables used for object construction
    ObjectStates* aStates = 0;
    TVariablesList::const_iterator it = theVariables.find(anEntry);
    if( it != theVariables.end() )
      aStates = (*it).second;

    if(!aStates) {
      if(MYDEBUG)
        cout<<"Valiables list empty!!!"<<endl;
      aCommandIndex++;
      continue;
    }

    TState aVariables = aStates->GetCurrectState();

    if(MYDEBUG) {
      cout<<"Variables from SObject:"<<endl;
      for (int i = 0; i < aVariables.size();i++)
        cout<<"\t Variable["<<i<<"] = "<<aVariables[i].myVariable<<endl;
    }

    //Calculate total number of parameters
    Standard_Integer aTotalNbParams = 1;
    while(aCommand.Location(aTotalNbParams,COMMA,1,aCommand.Length()))
      aTotalNbParams++;

    if(MYDEBUG)
      cout<<"aTotalNbParams = "<<aTotalNbParams<<endl;

    Standard_Integer aFirstParam = aNbEntries;

    //Replace parameters by variables
    Standard_Integer aStartPos = 0;
    Standard_Integer aEndPos = 0;
    int iVar = 0;
    TCollection_AsciiString aVar, aReplacedVar;
    for(Standard_Integer i=aFirstParam;i <= aTotalNbParams;i++) {
      //Replace first parameter (bettwen '(' character and first ',' character)
      if(i == aFirstParam)
      {
        aStartPos = aCommand.Location(O_BRACKET, 1, aCommand.Length()) + 1;
        if(aTotalNbParams - aNbEntries > 0 )
          aEndPos = aCommand.Location(aFirstParam, COMMA, 1, aCommand.Length());
        else
          aEndPos = aCommand.Location(C_BRACKET, 1, aCommand.Length());
      }
      //Replace last parameter (bettwen ',' character and ')' character)
      else if(i == aTotalNbParams)
      {
        aStartPos = aCommand.Location(i-1, COMMA, 1, aCommand.Length()) + 2;
        aEndPos = aCommand.Location(C_BRACKET, aStartPos , aCommand.Length());
      }
      //Replace other parameters (bettwen two ',' characters)
      else if(i != aFirstParam && i != aTotalNbParams )
      {
        aStartPos = aCommand.Location(i-1, COMMA, 1, aCommand.Length()) + 2;
        aEndPos = aCommand.Location(i, COMMA, 1, aCommand.Length());
      }

      if( aCommand.Value( aStartPos ) == O_SQR_BRACKET )
        aStartPos++;
      if( aCommand.Value( aEndPos-1 ) == C_SQR_BRACKET )
        aEndPos--;
      if ( aStartPos == aEndPos )
        continue; // PAL20889: for "[]"

      if(MYDEBUG)
        cout<<"aStartPos = "<<aStartPos<<", aEndPos = "<<aEndPos<<endl;

      aVar = aCommand.SubString(aStartPos, aEndPos-1);
      aVar.RightAdjust();
      aVar.LeftAdjust();

      if(MYDEBUG)
        cout<<"Variable: '"<< aVar <<"'"<<endl;

      // specific case for sketcher
      if(aVar.Location( TCollection_AsciiString("Sketcher:"), 1, aVar.Length() ) != 0) {
        Standard_Integer aNbSections = 1;
        while( aVar.Location( aNbSections, ':', 1, aVar.Length() ) )
          aNbSections++;
        aNbSections--;

        int aStartSectionPos = 0, aEndSectionPos = 0;
        TCollection_AsciiString aSection, aReplacedSection;
        for(Standard_Integer aSectionIndex = 1; aSectionIndex <= aNbSections; aSectionIndex++) {
          aStartSectionPos = aVar.Location( aSectionIndex, ':', 1, aVar.Length() ) + 1;
          if( aSectionIndex != aNbSections )
            aEndSectionPos = aVar.Location( aSectionIndex + 1, ':', 1, aVar.Length() );
          else
            aEndSectionPos = aVar.Length();

          aSection = aVar.SubString(aStartSectionPos, aEndSectionPos-1);
          if(MYDEBUG)
            cout<<"aSection: "<<aSection<<endl;

          Standard_Integer aNbParams = 1;
          while( aSection.Location( aNbParams, ' ', 1, aSection.Length() ) )
            aNbParams++;
          aNbParams--;

          int aStartParamPos = 0, aEndParamPos = 0;
          TCollection_AsciiString aParameter, aReplacedParameter;
          for(Standard_Integer aParamIndex = 1; aParamIndex <= aNbParams; aParamIndex++) {
            aStartParamPos = aSection.Location( aParamIndex, ' ', 1, aSection.Length() ) + 1;
            if( aParamIndex != aNbParams )
              aEndParamPos = aSection.Location( aParamIndex + 1, ' ', 1, aSection.Length() );
            else
              aEndParamPos = aSection.Length() + 1;

            if(MYDEBUG)
              cout<<"aParamIndex: "<<aParamIndex<<" aStartParamPos: " <<aStartParamPos<<" aEndParamPos: "<<aEndParamPos<<endl;

           if ( aStartParamPos == aEndParamPos)
             continue;

            aParameter = aSection.SubString(aStartParamPos, aEndParamPos-1);
            if(MYDEBUG)
              cout<<"aParameter: "<<aParameter<<endl;

            if(iVar >= aVariables.size())
              continue;

            aReplacedParameter = aVariables[iVar].myVariable;
            if(aReplacedParameter.IsEmpty()) {
              iVar++;
              continue;
            }

            if(aVariables[iVar].isVariable) {
              aReplacedParameter.InsertBefore(1,"'");
              aReplacedParameter.InsertAfter(aReplacedParameter.Length(),"'");
            }

            if(MYDEBUG)
              cout<<"aSection before : "<<aSection<<endl;
            aSection.Remove(aStartParamPos, aEndParamPos - aStartParamPos);
            aSection.Insert(aStartParamPos, aReplacedParameter);
            if(MYDEBUG)
              cout<<"aSection after  : "<<aSection<<endl<<endl;
            iVar++;
          }
          if(MYDEBUG)
            cout<<"aVar before : "<<aVar<<endl;
          aVar.Remove(aStartSectionPos, aEndSectionPos - aStartSectionPos);
          aVar.Insert(aStartSectionPos, aSection);
          if(MYDEBUG)
            cout<<"aVar after  : "<<aVar<<endl<<endl;
        }

        if(MYDEBUG)
          cout<<"aCommand before : "<<aCommand<<endl;
        aCommand.Remove(aStartPos, aEndPos - aStartPos);
        aCommand.Insert(aStartPos, aVar);
        if(MYDEBUG)
          cout<<"aCommand after  : "<<aCommand<<endl;

        break;
      } // end of specific case for sketcher

      //If parameter is entry or 'None', skip it
      if(theVariables.find(aVar) != theVariables.end() || aVar.Search(":") != -1 || aVar == PY_NULL)
        continue;

      if(iVar >= aVariables.size())
        continue;

      aReplacedVar = aVariables[iVar].myVariable;
      if(aReplacedVar.IsEmpty()) {
        iVar++;
        continue;
      }

      if(aVariables[iVar].isVariable) {
        aReplacedVar.InsertBefore(1,"\"");
        aReplacedVar.InsertAfter(aReplacedVar.Length(),"\"");
      }

      aCommand.Remove(aStartPos, aEndPos - aStartPos);
      aCommand.Insert(aStartPos, aReplacedVar);
      iVar++;
    }

    theCommand.Remove(aStartCommandPos, aEndCommandPos - aStartCommandPos);
    theCommand.Insert(aStartCommandPos, aCommand);

    aCommandIndex++;

    aStates->IncrementState();
  }

  if (MYDEBUG)
    cout<<"Command : "<<theCommand<<endl;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int MYDEBUG = 0 [static]

Definition at line 89 of file GEOM_Engine.cxx.

GEOM_Engine* TheEngine = NULL [static]

Definition at line 96 of file GEOM_Engine.cxx.