Product : Engine, Version : 5.1.1.1038, ArticleID : 41024156

HowTo : How to use IntersectWith method in VC++ .NET and how to perform type casting

Article41024156
TypeHowTo
ProductEngine
Version5.1.1.1038
Date Added11/25/2005
Submitted byMassimo Schinardi
Keywords

Subject

How to use IntersectWith method in VC++ .NET and how to perform type casting

Summary

Perform IntersectWith and retrieve the intersection point with type casting.

Solution

    
    vdxyz *pt1,*pt2;
    
    pt1 = __try_cast(m_vdraw->CreateInstance(VdConstObjectType::OBJ_XYZ));
    pt1->SetValueEx(-2,0,0);
    pt2 = __try_cast(m_vdraw->CreateInstance(VdConstObjectType::OBJ_XYZ));
    pt2->SetValueEx(2,0,0);
    System::Double p1[] = {pt1->x,pt1->y,pt1->z}; 
    System::Double p2[] = {pt2->x,pt2->y,pt2->z}; 
        
    vdLine *line;
    line= m_vdraw->ActiveDocument->Entities->AddLine(p1,p2);
    
    pt1->SetValueEx(3,-1,0);
    pt2->SetValueEx(3,1,0);
 
    System::Double p3[] = {pt1->x,pt1->y,pt1->z}; 
    System::Double p4[] = {pt2->x,pt2->y,pt2->z}; 
    
    vdLine *line2;
    line2= m_vdraw->ActiveDocument->Entities->AddLine(p3,p4);
 
    Object *objTmp=line2->IntersectWith(line,VdConstInters::VdIntExtendBoth);
 
    System::Double a[,]=__try_cast (objTmp);
 
    m_vdraw->Redraw ();