## The Ultimate Resource for TurboCAD Knowledge

Be sure your post is relevant to the current discussion.  Create a new topic within the appropriate board if you are unsure.

Create surface faster
February 03, 2010, 04:52:04 PM
Below is how I create a surface faset or triangle.
I need to call it 100000 time and it take an hour.
Is there a better faster way to do it?

HRESULT CreateQuad( Facets* pFacetsCol, Nodes* pNodesCol, SPoint& p0, SPoint& p1, SPoint& p2, SPoint& p3, long* id )
{
if (pFacetsCol==NULL) return E_POINTER;
if (pNodesCol==NULL) return E_POINTER;

#if !defined(_DEBUG)
static HRESULT hRes;
#else
HRESULT hRes;
#endif

hRes = S_OK;

try
{
static const long int numOfNodes = 4;
#if !defined(_DEBUG)
static long int k;
static long int pIndex[4];
static long int StartIndex=-1L;
static INode *pINode = NULL;
static IFacet *pIFacet = NULL;
static long index;
static long L;
#else
long int k;
long int pIndex[4];
long int StartIndex=-1L;
INode *pINode = NULL;
IFacet *pIFacet = NULL;
long index;
long L;
#endif
pINode = NULL;
pIFacet = NULL;
hRes = pNodesCol->get_Count(&StartIndex);
if (SUCCEEDED(hRes))
{
TRACE("Facet %d\n",StartIndex);
&varOptional, &varOptional, &varOptional, &varOptional, &varOptional, &pINode);
if (SUCCEEDED(hRes))
{
pINode->Release();
&varOptional, &varOptional, &varOptional, &varOptional, &varOptional, &pINode);
if (SUCCEEDED(hRes))
{
pINode->Release();
&varOptional, &varOptional, &varOptional, &varOptional, &varOptional, &pINode);
if (SUCCEEDED(hRes))
{
pINode->Release();
&varOptional, &varOptional, &varOptional, &varOptional, &varOptional, &pINode);
if (SUCCEEDED(hRes))
{
pINode->Release();
for(k = 0; k < numOfNodes; k++ ) pIndex[k] = StartIndex + k;
if (FacetInd.vt==VT_EMPTY) FacetInd.CreateOneDim(VT_I4, numOfNodes, (void*)&pIndex[0]);
//                     if (FacetInd.vt==VT_EMPTY) FacetInd.CreateOneDim(VT_I4, numOfNodes);
for(k = 0; k < numOfNodes; k++ )
{
index = k;
L = StartIndex + k;
FacetInd.PutElement(&index,(void*)&L);
}
hRes = pFacetsCol->Add(FacetInd, &varOptional, &varOptional, &varOptional, &varOptional, &pIFacet);
if (SUCCEEDED(hRes))
{
//                        pIFacet->get_ID(id);
pIFacet->Release();
//                        TRACE("Facet %d\n",StartIndex);
}
else
{
TRACE("could not add faset to facet collection\n");
}
//                     FacetInd.Clear();
}
else
{
TRACE("could not add fourth note to node collection\n");
}
}
else
{
TRACE("could not add third note to node collection\n");
}
}
else
{
TRACE("could not add second note to node collection\n");
}
}
else
{
TRACE("could not add first note to node collection\n");
}
}
else
{
TRACE("could not get start index from node collection\n");
}
}
catch(COleException e)
{
return E_FAIL;
}
catch(CException e)
{
return E_FAIL;
}
catch(...)
{