void InteriorPointsConstructor::printFirstInteriorPoints(int color, bool flag)
{
	int i = 1;
	int j = 0;
		
		
		AcGePoint3dArray ptArr;
		ptArr.setLogicalLength(_interiorArray[i].length()+1);
		
		
		while (j < _interiorArray[i].length())
		{
			
			ptArr[j].set(_interiorArray[i][j].x, _interiorArray[i][j].y, _interiorArray[i][j].z);
			
			
		
			j++;
		}
		ptArr[j].set(_interiorArray[0][0].x, _interiorArray[0][0].y, _interiorArray[0][0].z);
			

		AcDb3dPolyline *pNewPline = new AcDb3dPolyline(AcDb::k3dSimplePoly , ptArr, Adesk::kFalse);
		
		pNewPline->setColorIndex(color);

		AcDbBlockTable *pBlockTable;
		AcDbBlockTableRecord *pBlockTableRecord;


		acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);

		
		
		pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);


		AcDbObjectId plineObjId;
		pBlockTableRecord->appendAcDbEntity(plineObjId, pNewPline);
		
		pBlockTable->close();
		pBlockTableRecord->close();

		//pNewPline->setLayer(_T("0"));
		//pNewPline->setClosed(Adesk::kFalse);
		pNewPline->close();
		//}
		//delete pNewPline;
		
	
	
}
Example #2
0
AcBr::ErrorStatus
meshDisplay(const AcBrMesh2d& mesh)
{ 
    AcBr::ErrorStatus returnValue = AcBr::eOk;

	// make a global element traverser
	AcBrMesh2dElement2dTraverser meshElemTrav;
	returnValue = meshElemTrav.setMesh(mesh);
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in AcBrMesh2dElement2dTraverser::setMesh:");
		errorReport(returnValue);
		return returnValue;
	}

	// display the elements
	while (!meshElemTrav.done() && (returnValue == AcBr::eOk) && !acedUsrBrk()) {
    	// convert the nodes into a 3d point array for AcDbPolyline
        AcGePoint3dArray pts;

		AcBrElement2dNodeTraverser elemNodeTrav;
		returnValue = elemNodeTrav.setElement(meshElemTrav);
		if (returnValue != AcBr::eOk) {
			acutPrintf("\n Error in AcBrElement2dNodeTraverser::setElement:"); 
			errorReport(returnValue);
			return returnValue;
		} 
		
		while (!elemNodeTrav.done() && (returnValue == AcBr::eOk)) { 
			AcBrNode node;
			returnValue = elemNodeTrav.getNode(node);
		     if (returnValue != AcBr::eOk) {	
			    acutPrintf("\n Error in AcBrElement2dNodeTraverser::getNode:"); 
			    errorReport(returnValue);
			    return returnValue;
		    }

			// add the node geometry data to the lightweight polyline point array
			returnValue = nodeDisplay(node, pts);
	    	if (returnValue != AcBr::eOk) {
				acutPrintf("\n Error in nodeDisplay:");
			    errorReport(returnValue);
			    return returnValue;
		    }

			returnValue = elemNodeTrav.next();
	    	if (returnValue != AcBr::eOk) {
		    	acutPrintf("\n Error in AcBrElement2dNodeTraverser::next:");
			    errorReport(returnValue);
			    return returnValue;
		    }
		} // end element while

        // create a simple, closed polygon from the element node list
        AcDb3dPolyline* pline = new AcDb3dPolyline(AcDb::k3dSimplePoly, pts, Adesk::kTrue);
        if (pline == NULL) {
            returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
            acutPrintf("\n Unable to allocate memory for polyline");
            return returnValue;
		}

		// post the polyline to the database (this should display the element)
        AcDbObjectId objId;
        if (addToDatabase(pline, objId) != AcBr::eOk) {
            acutPrintf("\n addToDatabase failed");
            return returnValue;
        }

        // close the database object
        if (pline->close() != AcBr::eOk) {
            acutPrintf("\n AcDb3dPolyline::close() failed");
            return returnValue;
        }

		returnValue = meshElemTrav.next();
		if (returnValue != AcBr::eOk) {
			acutPrintf("\n Error in AcBrMesh2dElement2dTraverser::next:");  
			errorReport(returnValue);
			return returnValue;
		}

	}  // end mesh while

    return returnValue;
}
void InteriorPointsConstructor::printInteriorPoints(int color, bool flag)
{
	int i = 0;

	

	while (i < _contourArray->length()/2 + 1)
	{
		int j = 0;
		
		
		AcGePoint3dArray ptArr;

		if ((flag)|| (_interiorArray[i].length() <2)) ptArr.setLogicalLength(_interiorArray[i].length());
		else  ptArr.setLogicalLength(_interiorArray[i].length()-1);
		
		if ((flag)|| (_interiorArray[i].length() < 2))
		while (j < _interiorArray[i].length())
		{
			
			ptArr[j].set(_interiorArray[i][j].x, _interiorArray[i][j].y, _interiorArray[i][j].z);
			

		
			j++;
		}
		else
		{
				while (j < _interiorArray[i].length()-2)
				{
			
						ptArr[j].set(_interiorArray[i][j].x, _interiorArray[i][j].y, _interiorArray[i][j].z);
						if (sqrt(_interiorArray[i][j].x*_interiorArray[i][j].x + _interiorArray[i][j].y*_interiorArray[i][j].y + _interiorArray[i][j].z*_interiorArray[i][j].z) < 100)
							acutPrintf(_T("The shitty: %d, %d\n"), i, j);

		
				j++;
				}
				j++;
				ptArr[j].set(_interiorArray[i][j].x, _interiorArray[i][j].y, _interiorArray[i][j].z);
			
		}
		//if (i == 10){
		AcDb3dPolyline *pNewPline = new AcDb3dPolyline(AcDb::k3dSimplePoly , ptArr, Adesk::kFalse);
		
		pNewPline->setColorIndex(color);

		AcDbBlockTable *pBlockTable;
		AcDbBlockTableRecord *pBlockTableRecord;


		acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);

		
		
		pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);


		AcDbObjectId plineObjId;
		pBlockTableRecord->appendAcDbEntity(plineObjId, pNewPline);
		
		pBlockTable->close();
		pBlockTableRecord->close();

		//pNewPline->setLayer(_T("0"));
		//pNewPline->setClosed(Adesk::kFalse);
		pNewPline->close();
		//}
		//delete pNewPline;
		
		i++;
	}
}