MeshVS_TextPrsBuilder

I used  "meshtext”command in Draw, doesn't it work?  

Are there special requirements for this command "

 

Exampe:

pload ALL

vinit

meshfromstl  m *.stl

vsetdispmode m 2

meshtext m      

 

Kirill Gavrilov's picture

Probably you need using another display mode.

pload VISUALIZATION XSDRAW
vinit View1
meshfromstl m [locate_data_file shape.stl]
vfit
meshtext m
vsetdispmode m 34 
Hello World's picture

Dear !

     Thank you very much for your reply!

     The method you provided is valid in draw.

      I tried to add the import STL file function to the ImportExoprt (in Examples) project,implemented it through MeshVS_Mesh.

      How do I make the nodes selectable, how do I get the nodes that the user chooses

Best!

void CImportExport::ReadSTL(const Handle(AIS_InteractiveContext)& anInteractiveContext)

{

//Handle(MeshVS_Mesh) aMeshVS_Mesh;

//CImportExport::ReadSTL(aMeshVS_Mesh);

//anInteractiveContext->Display(aMeshVS_Mesh,true);

//anInteractiveContext->UpdateCurrentViewer();

CFileDialog dlg(TRUE,

NULL,

NULL,

OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,

L"STL Files (*.stl)|*.stl; *.stl|All Files (*.*)|*.*||",

NULL);

CString SHAREPATHValue;

SHAREPATHValue.GetEnvironmentVariable(L"CSF_OCCTDataPath");

CString initdir = (SHAREPATHValue + "\\stl");

dlg.m_ofn.lpstrInitialDir = initdir;

if (dlg.DoModal() == IDOK)

{

SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));

TCollection_AsciiString aFileName((const wchar_t*)dlg.GetPathName());

const Handle_Poly_Triangulation aSTLMesh = RWStl::ReadFile(

OSD_Path(aFileName));

Handle(XSDRAWSTLVRML_DataSource) aDS = new XSDRAWSTLVRML_DataSource(aSTLMesh);

Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh();

aMesh->SetDataSource(aDS);

aMesh->SetDisplayMode(MeshVS_DMF_Shading);

aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True);

Quantity_Color cor = Quantity_Color(Quantity_NOC_BLUE1);

// Prepare triangle labels

MeshVS_DataMapOfIntegerAsciiString aLabels;

Standard_Integer aLen = aMesh->GetDataSource()->GetAllElements().Extent();

for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++) 

{

aLabels.Bind(anIndex, TCollection_AsciiString(anIndex));

}

Handle(MeshVS_TextPrsBuilder) aTextBuilder = new MeshVS_TextPrsBuilder(aMesh.operator->(), 20., Quantity_NOC_YELLOW, MeshVS_DMF_TextDataPrs,aDS);

aTextBuilder->SetTexts(Standard_True, aLabels);

aMesh->AddBuilder(aTextBuilder);

aMesh->GetDrawer()->SetColor(MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW);

// Hide all nodes by default

Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();

Standard_Integer aNodeLen = aSTLMesh->Nodes().Length();

for (Standard_Integer anIndex = 1; anIndex <= aNodeLen; anIndex++)

aNodes->ChangeMap().Add(anIndex);

//aMesh->SetHiddenNodes(aNodes);

aMesh->SetSelectableNodes(aNodes);

aMesh->SetMeshSelMethod(MeshVS_MSM_NODES);

AIS_SelectionModesConcurrency aSelModeConcurrency = AIS_SelectionModesConcurrency_Multiple;

//anInteractiveContext->SetSelectionModeActive(aMesh, 8, 1, aSelModeConcurrency);

//anInteractiveContext->SetSelectionModeActive(aMesh, 0, 0, aSelModeConcurrency);

anInteractiveContext->SetSelectionModeActive(aMesh, 1, 1, aSelModeConcurrency);

anInteractiveContext->Display(aMesh,true);

////Display Text Object

//for (Standard_Integer anIndex = 1; anIndex <= aNodeLen; anIndex++)

//{

// TCollection_AsciiString string;

// string = anIndex ;

// Handle(AIS_TextLabel) aLabel = new AIS_TextLabel();

// aLabel->SetText(string);

// aLabel->SetPosition(aSTLMesh->Node(anIndex));

// anInteractiveContext->Display(aLabel,false);

//}

//

anInteractiveContext->SetDisplayMode((Handle(AIS_InteractiveObject))aMesh, 1,1);

anInteractiveContext->UpdateCurrentViewer();

}

SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));

}

Kirill Gavrilov's picture

In Draw, it is just vselmode m 1 1 and vstate to see selection state.

pload VISUALIZATION XSDRAW
vinit View1
meshfromstl m [locate_data_file shape.stl]
vfit
meshtext m
vsetdispmode m 34 
#vselmode m 8 1
vselmode m 1 1
vselect 0 0 200 200
vstate -entities