LVectorObject::ExplodeObject

#include "ltwrappr.h"

L_INT LVectorObject::ExplodeObject(dwFlags)

L_UINT32 dwFlags;

/* flag that indicates how to explode the object */

Explodes a vector object or objects to smaller parts. This function is available in the LEADTOOLS Vector Imaging Pro Toolkit.

Parameter

Description

dwFlags

Flag that indicates which objects to explode. Possible values are:

 

Value

Meaning

 

0

Explode all objects.

 

VECTOR_FLAGS_EXPLODE_TO_LINES

Explode objects into lines.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

If the VECTOR_FLAGS_EXPLODE_TO_LINES flag is not specified, then not all objects can be exploded, for example an attempt to explode a VECTOR_LINE has no effect and returns SUCCESS.

Below is a list of object types and the objects into which they explode:

Object type

After LVectorObject::ExplodeObject

VECTOR_ARC

Same.

VECTOR_CHORD

Same.

VECTOR_CIRCLE

Same.

VECTOR_ELLIPSE

Same.

VECTOR_ELLIPTICALARC

Same.

VECTOR_LINE

Same.

VECTOR_PIE

Same.

VECTOR_POLYBEZIER

Same.

VECTOR_POLYDRAW

Same.

VECTOR_POLYGON

Same.

VECTOR_POLYLINE

nPointCount of VECTOR_LINE's.

VECTOR_RASTER

Same.

VECTOR_RECTANGLE

4 VECTOR_LINE's.

VECTOR_TEXT

Same.

VECTOR_VERTEX

Same.

 

Note that exploding an object can convert the object into a different type. For example, exploding a VECTOR_RECTANGLE will result in four VECTOR_LINE objects. The original vector object no longer exists. Therefore, exploding a valid LVectorRectangle object invalidates the LVectorRectangle object.

To deteremine the validity of an object, call LVectorObject::IsValid.

Required DLLs and Libraries

LVKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LVectorObject::IsValid

Topics:

Working with Vector Objects

Example

This example will

1. Create new image of one polyline

2. Explode the polyline

3. Enumerate the new objects

class LMyVectorLayer2: public LVectorLayer
{
public:
   LVectorBase *m_pVectorDst;
public:
   LMyVectorLayer2() {};
   virtual ~LMyVectorLayer2(){};
   virtual L_INT EnumObjectsCallBack(pVECTORHANDLE pVector, pVECTOROBJECT pObject);
};
L_INT LMyVectorLayer2::EnumObjectsCallBack(pVECTORHANDLE pVector, pVECTOROBJECT pObject)
{
   UNREFERENCED_PARAMETER(pVector);
   L_TCHAR *pszMsg = TEXT("");
   switch (pObject->nType)
   {
   case VECTOR_LINE:
      pszMsg = TEXT("Vector Line");
      break;
   case VECTOR_RECTANGLE :
      pszMsg = TEXT("Vector Rectangle");
      break;
      
   case VECTOR_POLYLINE:
      pszMsg = TEXT("Vector Polyline");
      break;
   }
   MessageBox(NULL, pszMsg, TEXT(""), MB_OK);
   return SUCCESS ;
}
//LVectorObject::ExplodeObject()
//LVectorObject::IsValid()
//
//Example81
// This example will 
// 1. Create new image of one polyline
// 2. Explode the polyline
// 3. Enumerate the new objects
L_INT LVectorObject__ExplodeObjectExample(HWND hWnd, LVectorBase *pVector)
{
   UNREFERENCED_PARAMETER(hWnd);
   L_INT             nRet;
   LMyVectorLayer2   VectorLayer;
   VECTORLAYERDESC   LayerDesc;
   //Create and add a new layer
   nRet = VectorLayer.GetLayerDesc(&LayerDesc);
   if(nRet != SUCCESS)
      return nRet;
   lstrcpy(LayerDesc.szName, TEXT("Layer One"));
   nRet = VectorLayer.SetLayerDesc(&LayerDesc);
   if(nRet != SUCCESS)
      return nRet;
   nRet = pVector->AddLayer(&VectorLayer);
   if(nRet != SUCCESS)
      return nRet;
   //Create a polyline object
   VECTORPOLYLINE     PolyLine;
   VECTORPOINT        Points[4] = { 50,  50, 0, 0,
                                    80,  50, 0, 0,
                                    80,  80, 0, 0,
                                    50,  80, 0, 0
                                 };
   PolyLine.nPointCount = 4;
   PolyLine.Point = Points;
   PolyLine.Pen.nSize = sizeof( VECTORPEN );
   PolyLine.Pen.bExtPen = FALSE;
   PolyLine.Pen.NewPen.LogPen.lopnStyle = PS_SOLID;
   PolyLine.Pen.NewPen.LogPen.lopnWidth.x = 10;
   PolyLine.Pen.NewPen.LogPen.lopnWidth.y = 10;
   PolyLine.Pen.NewPen.LogPen.lopnColor = RGB(0,255,0);
   LVectorPolyLine VectorPolyLine(&PolyLine);
   //Add polyline to layer
   nRet = VectorLayer.AddObject(&VectorPolyLine);
   if(nRet != SUCCESS)
      return nRet;
   //Enumerate objects--should get one polyline
   nRet = VectorLayer.EnumObjects();
   if(nRet != SUCCESS)
      return nRet;
   //Enumerate objects--should get three lines
   nRet = VectorLayer.EnumObjects();
   if(nRet != SUCCESS)
      return nRet;
   return SUCCESS;
}