Beispiel #1
0
void
dumpBblock()
{ 
    AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Select the entity by type
	AcBrEntity* pEnt = NULL;
	AcDb::SubentType subType = AcDb::kNullSubentType;
	returnValue = selectEntityByType(pEnt, subType);
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in selectEntityByType:");
		errorReport(returnValue);
		delete pEnt;
    	return;
    }

	AcGeBoundBlock3d bblock;

	returnValue = pEnt->getBoundBlock(bblock);
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in AcBrEntity::getBoundBlock:"); 
		errorReport(returnValue);
		delete pEnt;
		return;
	}
	delete pEnt;

	AcGePoint3d min, max;
	bblock.getMinMaxPoints(min, max);
	bblockReport(min, max);

	return;
}
Beispiel #2
0
// 列出远方当前目录
void cmd_dir(int sockfd) {
    int data_sock, bytes;
    char buf[BUF_SIZE] = {0};
    sendCommand(sockfd, "PASV", "");
    if (getReplyCode(sockfd) != PASV_MODE) {
        printf("Error!");
        return;
    }
    server.sin_port = htons(data_port);
    if ((data_sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
        errorReport("Create socket error!");
    if (connect(data_sock, (struct sockaddr*)&server, sizeof(server)) < 0)
        errorReport("Cannot connect to server!");
    printf("Data connection successfully: %s:%d\n", inet_ntoa(server.sin_addr), ntohs(server.sin_port));

    sendCommand(sockfd, "LIST ", "-al");
    getReplyCode(sockfd);
    printf("\n");
    // 数据连接获取服务器传输的数据
    while ((bytes = read(data_sock, buf, BUF_SIZE - 2)) > 0) {
        buf[bytes] = '\0';
        printf("%s", buf);
    }
    printf("\n");
    close(data_sock);
    getReplyCode(sockfd);
}
Beispiel #3
0
static AcBr::ErrorStatus 
countVertices(const AcBrBrep& brepEntity)
{
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	// make a global vertex traverser
	AcBrBrepVertexTraverser brepVertexTrav;
	returnValue = brepVertexTrav.setBrep(brepEntity);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrBrepVertexTraverser::setBrep:"));
		errorReport(returnValue);
		return returnValue;
	}

	// count the vertices
	int vertexCount = 0;
	while (!brepVertexTrav.done() && (returnValue == AcBr::eOk)) {
	    vertexCount++;
		returnValue = brepVertexTrav.next();
		if (returnValue != AcBr::eOk) {
			acutPrintf(ACRX_T("\n Error in AcBrBrepVertexTraverser::next:"));  
			errorReport(returnValue);
			return returnValue;
		}
	}
	acutPrintf(ACRX_T("\n ***Brep has %d vertices\n"), vertexCount);	  

	return returnValue;
}
Beispiel #4
0
AcBr::ErrorStatus
nodeDump(const AcBrNode& node)
{
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Determine the entity which contains this node
	AcBrEntity* entityAssociated = NULL;
	returnValue = node.getEntityAssociated(entityAssociated);
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in AcBrNode::getEntityAssociated:");
		errorReport(returnValue);
		delete entityAssociated;
		return returnValue;
	}
	entityAssociatedReport(entityAssociated);
	delete entityAssociated;

	AcGePoint3d nodePoint;
	returnValue = node.getPoint(nodePoint);
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in AcBrNode::getPoint:");
        errorReport(returnValue);
		return returnValue;
	}
	acutPrintf("\n Node Point is (");
	acutPrintf ("%lf, ", nodePoint.x);	
	acutPrintf ("%lf, ", nodePoint.y);
	acutPrintf ("%lf", nodePoint.z);
	acutPrintf(")\n");	
	
	return returnValue;
}
Beispiel #5
0
static AcBr::ErrorStatus 
countShells(const AcBrBrep& brepEntity)
{
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	// make a global shell traverser
	AcBrBrepShellTraverser brepShellTrav;
	returnValue = brepShellTrav.setBrep(brepEntity);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrBrepShellTraverser::setBrep:"));
		errorReport(returnValue);
		return returnValue;
	}

	// count the shells
	int shellCount = 0;
	while (!brepShellTrav.done() && (returnValue == AcBr::eOk)) {
	    shellCount++;
		returnValue = brepShellTrav.next();
		if (returnValue != AcBr::eOk) {
			acutPrintf(ACRX_T("\n Error in AcBrBrepShellTraverser::next:"));  
			errorReport(returnValue);
			return returnValue;
		}
	}
	acutPrintf(ACRX_T("\n ***Brep has %d shells\n"), shellCount);	  

	return returnValue;
}
Beispiel #6
0
void customFree(void* data, char* file, int caller_line){
    if(!initialized){
        errorReport(file,caller_line, HEAP_FREE_NOT_ALLOCATED, data);
    }else{
        // tracking node
        MemEntryPtr temp = head;
        while ( temp!=NULL){
            char* offset = ((char*) temp) +ENTRY_SIZE;
            if( offset < (char*) data &&  (char*) data < offset + temp->size){
                // MEMORY IS FREED WHERE IT IS NOT ALLOCATED
                errorReport(file,caller_line,HEAP_FREE_MIDDLE,data);
                return;
            }else if(offset == (char*) data){
                if(temp->isFree==true){
                    // MEMORY WAS FREED - REDUNDANTLY FREE THE MEMORY
                    errorReport(file,caller_line,HEAP_FREE_REDUNDANT,data);
                    fprintf(stderr,"\tDid you free it at line %d in %s ?\n",temp->lineFree,temp->fileFree);
                    return;
                }else{  
                    // FREE THE MEMORY
                    temp->isFree = true;
                    temp->fileFree = file;
                    temp->lineFree = caller_line;
                    // Merge it with previous free chunked
                    if(temp->prev!=NULL && temp->prev->isFree){
                        //Expand the available size of the previous node
                        temp->prev->size+=(temp->size+ENTRY_SIZE) ;
                        // Reassign the node's pointers
                        if(temp->next!=NULL)
                            temp->next->prev= temp->prev;
                        temp->prev->next = temp->next;
                        //Make the tracking node the previous node
                        temp=temp->prev;
                    }
                    if(temp->next!=NULL && temp->next->isFree){
                        temp->size +=  temp->next->size + ENTRY_SIZE;
                        temp->next = temp->next->next;
                        if(temp->next!=NULL){
                            temp->next->prev = temp;
                        }
                    }
                    break;
                }
            }else{
                // Get to the next memory entry
                temp = temp->next;
            }
        }
        // Get to the end of the memory array
        if(temp==NULL)
            errorReport(file,caller_line,HEAP_FREE_NOT_ALLOCATED,data);
    }
    
}
void
dumpModel()
{
    AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Select the entity by type
	AcBrEntity* pEnt = NULL;
	AcDb::SubentType subType = AcDb::kNullSubentType;
	returnValue = selectEntityByType(pEnt, subType);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in selectEntityByType:"));
		errorReport(returnValue);
		delete pEnt;
    	return;
    }

	switch (subType) {
	case AcDb::kNullSubentType:
		// brep
		returnValue	= brepDump((const AcBrBrep&)(*pEnt));
		if (returnValue != AcBr::eOk) {
			acutPrintf(ACRX_T("\n Error in brepDump:")); 
			errorReport(returnValue);
			return;
		}
		break;
    case AcDb::kFaceSubentType:
		// face
		returnValue = faceDump((const AcBrFace&)(*pEnt));
		if (returnValue != AcBr::eOk) {
			acutPrintf(ACRX_T("\n Error in faceDump:"));
			errorReport(returnValue);
			return;
		}
        break;
    case AcDb::kEdgeSubentType:
	    // edge
		returnValue = edgeDump((const AcBrEdge&)(*pEnt));
		if (returnValue != AcBr::eOk) {
			acutPrintf(ACRX_T("\n Error in edgeDump:"));
			errorReport(returnValue);
			return;
		}
		break;  
    default:
        acutPrintf(ACRX_T("\n dumpModel: unsupported subentity type: %d\n"), subType);
        return;
	}
	delete pEnt;

	return;
}
Beispiel #8
0
// 下载服务器的一个文件
void cmd_get(int sockfd, char* cmd) {
    int i = 0, data_sock, bytes;
    char filename[BUF_SIZE], buf[BUF_SIZE];
    while (i < strlen(cmd) && cmd[i] != ' ') i++;
    if (i == strlen(cmd)) {
        printf("Command error: %s\n", cmd);
        return;
    }
    while (i < strlen(cmd) && cmd[i] == ' ') i++;
    if (i == strlen(cmd)) {
        printf("Command error: %s\n", cmd);
        return;
    }
    strncpy(filename, cmd+i, strlen(cmd+i)+1);

    sendCommand(sockfd, "TYPE ", "I");
    getReplyCode(sockfd);
    sendCommand(sockfd, "PASV", "");
    if (getReplyCode(sockfd) != PASV_MODE) {
        printf("Error!\n");
        return;
    }
    server.sin_port = htons(data_port);
    if ((data_sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
        errorReport("Create socket error!");

    if (connect(data_sock, (struct sockaddr*)&server, sizeof(server)) < 0)
        errorReport("Cannot connect to server!");
    printf("Data connection successfully: %s:%d\n", inet_ntoa(server.sin_addr), ntohs(server.sin_port));
    sendCommand(sockfd, "RETR ", filename);
    if (getReplyCode(sockfd) == NO_SUCH_FILE) {
        close(sockfd);
        return;
    }

    FILE* dst_file;
    if ((dst_file = fopen(filename, "wb")) == NULL) {
        printf("Error!");
        close(sockfd);
        return;
    }
    while ((bytes = read(data_sock, buf, BUF_SIZE)) > 0)
        fwrite(buf, 1, bytes, dst_file);

    close(data_sock);
    getReplyCode(sockfd);
    fclose(dst_file);
}
Beispiel #9
0
// Utility function to extract a useful, bounded curve with native
// curve definition data, from the external (bounded) curve
AcBr::ErrorStatus
getNativeCurve(const AcBrEdge& edgeEntity,
               AcGeCurve3d*&   curveGeometry,
               AcGeCurve3d*&   nativeGeometry)
{
    AcBr::ErrorStatus returnValue = edgeEntity.getCurve(curveGeometry);  
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in AcBrEdge::getCurve:");
        errorReport(returnValue);
        return returnValue;
	}
	if (curveGeometry == NULL) {
		acutPrintf("\n getNativeCurve: external 3d curve is undefined\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (curveGeometry->type() != kExternalCurve3d) {
		acutPrintf("\n getNativeCurve: curve is not an external 3d curve\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve3d*)curveGeometry)->isDefined()) {
		acutPrintf("\n getNativeCurve: external 3d curve is undefined\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve3d*)curveGeometry)->isNativeCurve(nativeGeometry)
	    || (nativeGeometry == NULL)) {
		acutPrintf("\n getNativeCurve: native 3d curve is undefined\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
    return returnValue;
}
Beispiel #10
0
// Utility function to extract a useful 2d nurb curve with native
// definition data, from the external paramcurve
AcBr::ErrorStatus
getNativeParamCurve(const AcBrLoopEdgeTraverser& loopEdge,
                    AcGeCurve2d*&                pcurveGeometry,
                    AcGeNurbCurve2d&             nurbGeometry)
{
    AcBr::ErrorStatus returnValue = loopEdge.getParamCurve(pcurveGeometry);  
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in AcBrLoopEdgeTraverser::getParamCurve:");
        errorReport(returnValue);
        return returnValue;
	}
	if (pcurveGeometry == NULL) {
		acutPrintf("\n getNativeParamCurve: external param curve is undefined\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (pcurveGeometry->type() != kExternalCurve2d) {
		acutPrintf("\n getNativeParamCurve: parameter curve is not an external 2d curve\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve2d*)pcurveGeometry)->isDefined()) {
		acutPrintf("\n getNativeParamCurve: external param curve is undefined\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve2d*)pcurveGeometry)->isNurbCurve(nurbGeometry)) {
		acutPrintf("\n getNativeParamCurve: native 2d nurb curve is undefined\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
    return returnValue;
}
Beispiel #11
0
// Utility function to extract a useful, bounded and oriented curve
// with native curve definition data, from the external (bounded) curve
AcBr::ErrorStatus
getNativeOrientedCurve(const AcBrLoopEdgeTraverser& loopEdge,
                       AcGeCurve3d*&                curveGeometry,
                       AcGeCurve3d*&                nativeGeometry)
{
    AcBr::ErrorStatus returnValue = loopEdge.getOrientedCurve(curveGeometry);  
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrLoopEdgeTraverser::getOrientedCurve:"));
        errorReport(returnValue);
        return returnValue;
	}
	if (curveGeometry == NULL) {
		acutPrintf(ACRX_T("\n getNativeOrientedCurve: external 3d curve is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (curveGeometry->type() != kExternalCurve3d) {
		acutPrintf(ACRX_T("\n getNativeOrientedCurve: curve is not an external 3d curve\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve3d*)curveGeometry)->isDefined()) {
		acutPrintf(ACRX_T("\n getNativeOrientedCurve: external 3d curve is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve3d*)curveGeometry)->isNativeCurve(nativeGeometry)
	    || (nativeGeometry == NULL)) {
		acutPrintf(ACRX_T("\n getNativeOrientedCurve: native 3d curve is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
    return returnValue;
}
Beispiel #12
0
/* main
 *
 *	do some main stuff.
 */
int main( int argc, char ** argv )
{
	basic_program * bp;
	basic_line * bl;


	printf( "0\n" );
	/* set up our program space */
	bp = newProgram();
	if( !bp ) {
		errorReport( kErrorMalloc, 1 );
		return 0;
	}

	/* display version info */
	cmd_info( bp, NULL );

	bl = consumeString( bp, program[0] );
	bl = consumeString( bp, program[1] );
	bl = consumeString( bp, program[2] );
	bl = consumeString( bp, program[3] );
	bl = consumeString( bp, program[4] );

	/* and run the program, if we should... */
	printf( "Running program\n" );
	runProgram( bp, 0 );
	while( run_poll( bp ) );

	/* just show access of variables */
	printf( "Variable 'a' is %ld\n", getVariableNumber( bp->variables, "a" ));

	deleteProgram( bp );

	return 0;
}
Beispiel #13
0
int main(int argc, char **argv)
{
    CTexture *image1 = NULL;
    CTexture *image2 = NULL;

    if(argc != 3)
    {
        printUsage();
    }
    else
    {
        image1 = loadImage(argv[1]);
        image2 = loadImage(argv[2]);
    }

    CMetricRMS rms;

    CTexture *diff = rms.Analyze(image1, image2);

    CTextureManager::WriteTextureToPNG("diff.png", diff);

    std::fstream errorReport("error.txt", std::ios_base::out);
    errorReport << "ErrorR = " << rms.GetErrorR() << std::endl;
    errorReport << "ErrorG = " << rms.GetErrorG() << std::endl;
    errorReport << "ErrorB = " << rms.GetErrorB() << std::endl;
    errorReport << "Error  = " << rms.GetError() << std::endl;
    errorReport.close();

    return 0;
}
Beispiel #14
0
// 发送命令,参数为 socket号 、 命令标示 和 命令参数
void sendCommand(int sock_fd, const char* cmd, const char* info) {
    char buf[BUF_SIZE] = {0};
    strcpy(buf, cmd);
    strcat(buf, info);
    strcat(buf, "\r\n");
    if (send(sock_fd, buf, strlen(buf), 0) < 0)
        errorReport("Send command error!");
}
Beispiel #15
0
// 连接到服务器,参数为 IP地址 和 端口号,返回是否连接成功的编号
int connectToHost(char* ip, char* pt) {
    int sockfd;
    int port = atoi(pt);
    if (port <= 0 || port >= 65536)
        errorReport("Invalid Port Number!");
    server.sin_family = AF_INET;
    server.sin_port = htons(port);
    if ((server.sin_addr.s_addr = inet_addr(ip)) < 0) {
        if ((hent = gethostbyname(ip)) != 0)
            memcpy(&server.sin_addr, hent->h_addr, sizeof(&(server.sin_addr)));
        else
            errorReport("Invalid Host!");
    }
    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
        errorReport("Create Socket Error!");
    if (connect(sockfd, (struct sockaddr*)&server, sizeof(server)) < 0)
        errorReport("Cannot connect to server!");
    printf("Successfully connect to server: %s:%d\n", inet_ntoa(server.sin_addr), ntohs(server.sin_port));
    return sockfd;
}
	void GLESv1_GraphManager::endScene()
	{
		if(!eglSwapBuffers(mDisplay, mSurface))
		{
			Pegas_log_warning("GraphicsService::update:");
			Pegas_log_warning("!eglSwapBuffers");
			Pegas_log_warning("mDisplay = %d [%X]", mDisplay, mDisplay);
			Pegas_log_warning("mSurface = %d [%X]", mSurface, mSurface);

			errorReport("eglSwapBuffers");
			destroy();
		}
	}
void
pointContainment()
{
    AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Select the entity by type
	AcBrEntity* pEnt = NULL;
	AcDb::SubentType subType = AcDb::kNullSubentType;
	returnValue = selectEntityByType(pEnt, subType);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in selectEntityByType:"));
		errorReport(returnValue);
		delete pEnt;
    	return;
    }

	// Query the point by AutoCAD pick
	AcGePoint3d testPt;
	acedGetPoint(NULL, ACRX_T("\n Pick point for containment test: \n"), asDblArray(testPt));

    AcGe::PointContainment containment = AcGe::kOutside;
    AcBrEntity* container = NULL;

    returnValue = pEnt->getPointContainment(testPt, containment, container);
    if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrEntity::getPointContainment:"));
		errorReport(returnValue);
		delete pEnt;
    	return;
    }

    ptContainmentReport(containment, container);

	delete container;
	delete pEnt;

	return;
}
Beispiel #18
0
AcBr::ErrorStatus
nodeDisplay(const AcBrNode& node, AcGePoint3dArray& pts)
{
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	AcGePoint3d nodePoint;	
	returnValue = node.getPoint(nodePoint);
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in AcBrNode::getPoint:");
        errorReport(returnValue);
		return returnValue;
	}
    pts.append((const AcGePoint3d&)nodePoint);
    
	return returnValue;
}
Beispiel #19
0
ClientConnection::ClientConnection(QObject *parent) :
    QObject(parent)
{
    tcpSocket = new QTcpSocket(this);
    /*Get info from the config file*/
    QSettings *config = new QSettings("../Common/config.ini",QSettings::IniFormat);
    config->setIniCodec("UTF8");
    config->beginGroup("information");
    QString ip=config->value("HostAddress").toString();
    int portNumber = config->value("portNumber").toInt();
    ipAddress = QHostAddress(ip);
    port = portNumber;
    config->endGroup();

    connect(tcpSocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(errorReport()));
}
void
trimSurface()
{								  
    AcBr::ErrorStatus returnValue = AcBr::eOk;
    Acad::ErrorStatus acadReturnValue = eOk;

    // Get the subentity path for a face
	AcDbFullSubentPath subPath(kNullSubent);
	acadReturnValue = selectEntity(AcDb::kFaceSubentType, subPath);
	if (acadReturnValue != eOk) {
		acutPrintf(ACRX_T("\n Error in getPath: %d"), acadReturnValue);
		return;
	}

	// Make a face entity to access the surface
	AcBrFace faceEntity;
	returnValue = faceEntity.set(subPath);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrFace::set:"));
		errorReport(returnValue);
		return;
	}

	// Query the style for trimmed surface dump
	Adesk::Boolean trimmed = Adesk::kTrue;
    ACHAR opt[128];
   	while (Adesk::kTrue) {
		acutPrintf(ACRX_T("\nSelect Style for Trimmed Surface Dump: "));
		acedInitGet(NULL, ACRX_T("Nurb Trimmed"));
		if (acedGetKword(ACRX_T("Nurb/<Trimmed>: "), opt) == RTCAN) return;

        // Map the user input to a valid dump style
		if ((_tcscmp(opt, ACRX_T("Trimmed")) == 0) || (_tcscmp(opt, ACRX_T("")) == 0)) {
            trimmed = Adesk::kTrue;
            break;
        } else if ((_tcscmp(opt, ACRX_T("Nurb")) == 0)) {
            trimmed = Adesk::kFalse;
            break;
	    }
    }

	(trimmed) ? faceToTrimmedSurface(faceEntity) : faceToNurbSurface(faceEntity);

	return;
}
Beispiel #21
0
INT WINAPI WinMain(HINSTANCE, HINSTANCE, PSTR, INT) {
	
	Q_INIT_RESOURCE(CrashReporter);
	
	QApplication app(__argc, __argv);
	
#else

int main(int argc, char **argv) {
	
	Q_INIT_RESOURCE(CrashReporter);
	
	QApplication app(argc, argv);
	
#endif
	
	Logger::initialize();
	
	LogWarning << "Arx Crash Reporter starting!";
	
	QString sharedMemoryName;
	const QStringList args = app.arguments();
	QStringList::const_iterator itArgs;
	for (itArgs = args.constBegin(); itArgs != args.constEnd(); ++itArgs) {
		if((*itArgs).startsWith("-crashinfo=")) {
			QString crashInfo = (*itArgs);
			crashInfo.remove("-crashinfo=");
			sharedMemoryName = crashInfo;
		}
	}
	
	if(sharedMemoryName.isEmpty()) {
		LogError << "Missing -crashinfo parameter!";
		return EXIT_FAILURE;
	}
	
	ErrorReport errorReport(sharedMemoryName);
	
	ErrorReportDialog errorReportDlg(errorReport);
	errorReportDlg.show();
	
	return app.exec();
}
Beispiel #22
0
AcBr::ErrorStatus
brepDump(const AcBrBrep& brepEntity)
{ 
    AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Validate the brep vs. the brep "owner"
	AcBrBrep brepOwner;
	returnValue = brepEntity.getBrep(brepOwner);
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in AcBrBrep::getBrep:");
		errorReport(returnValue);
		return returnValue;
	}
	if (!brepEntity.isEqualTo(&brepOwner)) {
		acutPrintf("\n Brep owner is out of sync with brep!");
		return (AcBr::ErrorStatus)Acad::eAmbiguousOutput;
	}

	// Query traversal direction for brep dump 
	Adesk::Boolean downwards = Adesk::kTrue;
    char opt[128];
   	while (Adesk::kTrue) {
		acutPrintf("\nSelect Traversal Direction for Brep Dump: ");
		acedInitGet(NULL, "Upwards Downwards");
		if (acedGetKword("Upwards/<Downwards>: ", opt) == RTCAN)
			return returnValue;

        // Map the user input to a valid traversal direction
		if ((strcmp(opt, "Downwards") == 0) || (strcmp(opt, "") == 0)) {
            downwards = Adesk::kTrue;
            break;
        } else if ((strcmp(opt, "Upwards") == 0)) {
            downwards = Adesk::kFalse;
            break;
	    }
    }

	// Switchable dump based on upwards vs. downwards traversal
	if (downwards) brepDumpDown(brepEntity);
	else brepDumpUp(brepEntity);

	return returnValue;
}
Beispiel #23
0
void* customMalloc(unsigned size, char* file, int caller_line){
    if(!initialized){
        // Initialize the head
        head = (MemEntryPtr) mem;
        head->prev = NULL;
        head->next = NULL;
        head->isFree = true;
        head->fileFree = NULL;
        head->lineFree = 0;
        head->size = HEAP_SIZE - ENTRY_SIZE;
        initialized = true;
    }
    MemEntryPtr temp = head;
    
    // While the tracking node is non NULL
    while(temp!=NULL){
        // the node is freed
        if( temp->isFree && temp->size >= size + ENTRY_SIZE ){
            // If find a big-enough chunk and is not freed
            MemEntryPtr newEntry = (MemEntryPtr) ( ((char*)temp) + ENTRY_SIZE + size);
            //Change the node's pointers
            newEntry->prev = temp;
            newEntry->next = temp->next;
            temp->next = newEntry;
            if(newEntry->next!=NULL){
                newEntry->next->prev = newEntry;
            }
            newEntry->isFree = true; 
            //Tweak the current available size of the entry
            newEntry->size = temp->size - size - ENTRY_SIZE;

            temp->isFree = false;
            temp->size = size;
            return (void*) ((char*) temp)+ENTRY_SIZE;
        }
        temp = temp->next;
    }
    // No space to filled in
    errorReport(file,caller_line, HEAP_MALLOC_INSUFFICIENT, 0);
    return NULL; 

}
Beispiel #24
0
// 运行客户端
void run(char* ip, char* pt) {
    int  sockfd = connectToHost(ip, pt);
    if (getReplyCode(sockfd) != SERVICE_READY)
        errorReport("Service Connect Error!");
    while (userLogin(sockfd) != 0)      // 调用登录函数userLogin
        printf("Please try again.\n");
    int isQuit = 0;
    char buf[BUF_SIZE];
    while (!isQuit) {
        printf("[Client command] ");
        fgets(buf, sizeof(buf), stdin);
        switch (cmdToNum(buf)) {
            case GET:
                cmd_get(sockfd, buf);
                break;
            case PUT:
                cmd_put(sockfd, buf);
                break;
            case PWD:
                cmd_pwd(sockfd);
                break;
            case DIR:
                cmd_dir(sockfd);
                break;
            case CD:
                cmd_cd(sockfd, buf);
                break;
            case HELP:
                cmd_help();
                break;
            case QUIT:
                cmd_quit(sockfd);
                isQuit = 1;
                break;
            default:
                cmd_help();
                break;
        }
    }
    close(sockfd);
}
Beispiel #25
0
// Utility function to extract a useful, unbounded surface with native
// surface definition data, from the external bounded surface
AcBr::ErrorStatus
getNativeSurface(const AcBrFace& faceEntity,
                 AcGeSurface*&   surfaceGeometry,
                 AcGeSurface*&   nativeGeometry)
{
    AcBr::ErrorStatus returnValue = faceEntity.getSurface(surfaceGeometry);  
	if (returnValue != AcBr::eOk) {
		acutPrintf("\n Error in AcBrFace::getSurface:");
    	errorReport(returnValue);
        return returnValue;
	}
	if (surfaceGeometry == NULL) {
		acutPrintf("\n getNativeSurface: external bounded surface is undefined\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (surfaceGeometry->type() != kExternalBoundedSurface) {
		acutPrintf("\n getNativeSurface: surface is not an external bounded surface\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	AcGeExternalSurface baseGeometry;
	((AcGeExternalBoundedSurface*)surfaceGeometry)->getBaseSurface(baseGeometry);
	if (!baseGeometry.isDefined()) {
		acutPrintf("\n getNativeSurface: external surface is undefined\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!baseGeometry.isNativeSurface(nativeGeometry)
	    || (nativeGeometry == NULL)) {
		acutPrintf("\n getNativeSurface: native surface is undefined\n");
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
    return returnValue;
}
int main(int argc,char *argv[]){
	#ifdef _DEBUG_					//调试时启用内存泄露检测工具
	printf("DEBUG !!!!!!!!!!!!!!!!!!!!!!!\n\n\n");
	atexit(report_mem_leak);		//
	#endif							//
	
	//UI start
	
	//-------------------------------------------------------------------
	//初始化-------------------------------------------------------------
	//-------------------------------------------------------------------
	//1.将发送的命令转换成正确的格式
	asciiToHex(UPS_COMMUNICATION_INI,UPS_COMMUNICATION_INI_DECODE);
	asciiToHex(UPS_CMD_ACCEPT,UPS_CMD_ACCEPT_DECODE);
	asciiToHex(UPS_CMD_01,UPS_CMD_01_DECODE);
	asciiToHex(UPS_CMD_02,UPS_CMD_02_DECODE);
	asciiToHex(UPS_CMD_03,UPS_CMD_03_DECODE);
	asciiToHex(UPS_CMD_06,UPS_CMD_06_DECODE);
	asciiToHex(UPS_CMD_07,UPS_CMD_07_DECODE);
	asciiToHex(UPS_CMD_24,UPS_CMD_24_DECODE);
	asciiToHex(UPS_CMD_27,UPS_CMD_27_DECODE);
	asciiToHex(UPS_CMD_31,UPS_CMD_31_DECODE);
	asciiToHex(UPS_CMD_32,UPS_CMD_32_DECODE);
	asciiToHex(UPS_CMD_3B,UPS_CMD_3B_DECODE);
	asciiToHex(UPS_CMD_42,UPS_CMD_42_DECODE);
	//UI show "ok"
	
	//2.读取配置文件参数
	char *value_buf	=	(char*)	malloc(MAX_CHAR_PER_PARA);		//临时变量
	char *key_buf	=	(char*)	malloc(MAX_CHAR_PER_CONF);		//临时变量
	KEY_VAL config_file,	*config_file_ptr1=&config_file,	*config_file_ptr2=NULL;
	if(analyzeConfFile("config",&config_file)){
		//read file successfully
	}
	else{
		//file not existed
	}
	errorReport();								//
	for(int i=0;i<NUM_OF_UPS;i++){								//读取配置文件参数的设定值
		sprintf(key_buf,"com_num_%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].LINK_COM_NUM=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"READ_INTERVAL_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].READ_INTERVAL=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"READ_MULTIPLIER_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].READ_MULTIPLIER=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"READ_CONSTANT_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].READ_CONSTANT=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"WRITE_MULTIPLIER_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].WRITE_MULTIPLIER=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"WRITE_CONSTANT_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].WRITE_CONSTANT=atoi(value_buf);//
		}
		else{
			
		}
	}
	#ifdef _DEBUG_
	printf("%d %d %d %d\n\n",_2023ups[0].LINK_COM_NUM,_2023ups[1].LINK_COM_NUM,_2023ups[2].LINK_COM_NUM,_2023ups[3].LINK_COM_NUM);
	for(int i=0;i<NUM_OF_UPS;i++){
		printf("%d %d %d %d %d\n",_2023ups[i].READ_INTERVAL,_2023ups[i].READ_MULTIPLIER,_2023ups[i].READ_CONSTANT,\
		_2023ups[i].WRITE_MULTIPLIER,_2023ups[i].WRITE_CONSTANT);
	}
	#endif
	free(value_buf);
	free(key_buf);
	while(config_file_ptr1!=NULL){
		config_file_ptr2=config_file_ptr1;
		config_file_ptr1=config_file_ptr1->next;
		free(config_file_ptr2);
	}
	
	//3.初始化相应串口
	char com[20];
	for(int i=0;i<NUM_OF_UPS;i++){			//打开串口,配置相应参数
		memset(com,0,20);
		if(_2023ups[i].LINK_COM_NUM	>	0){		// _2023ups[i].LINK_COM_NUM从配置文件读取,>0有效	
			_2023ups[i].UPS_SET_ACTIVE=TRUE;
			//gtk_switch_set_active(itemValue[i][9],TRUE);
			//_2023ups[i].UPS_ALARM_ENABLE=TRUE;
			#ifdef _DEBUG_
			printf("start com%d communication\n",_2023ups[i].LINK_COM_NUM);
			#endif
			sprintf(com,"\\\\.\\COM%d",_2023ups[i].LINK_COM_NUM);
			_2023ups[i].UPS_COM_HANDLE=initialCom(com,1024);
			if(_2023ups[i].UPS_COM_HANDLE == INVALID_HANDLE_VALUE){
				//需要加入异常处理及日志记录
				errorReport();
				printf("Open Com%d Error shit\n",_2023ups[i].LINK_COM_NUM);
				//
				exit(0);
			}
			COMMTIMEOUTS timeouts={_2023ups[i].READ_INTERVAL,_2023ups[i].READ_MULTIPLIER,\
				_2023ups[i].READ_CONSTANT,_2023ups[i].WRITE_MULTIPLIER,_2023ups[i].WRITE_CONSTANT};
			if(setComTimeout(_2023ups[i].UPS_COM_HANDLE,timeouts))
				printf("set com timeout ok\n");
				//需要加入异常处理及日志记录
			if(setComPara(_2023ups[i].UPS_COM_HANDLE,_24_N_8_1))
				printf("set com parameter ok\n");	
				//需要加入异常处理及日志记录
		}
		else {
			_2023ups[i].UPS_SET_ACTIVE=FALSE;
		}
	}

	GtkApplication *app;
	app = gtk_application_new ("org.gtk.ups_monitor_v3", G_APPLICATION_FLAGS_NONE);
	int status;
	g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
	g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
	//5.创建一个线程,用来发送接收串口数据
	//	#ifndef NO_DATA_THREAD
	HANDLE sendDataThreadProc=CreateThread(NULL,0,sendDataViaCom,NULL,0,NULL);
	printf("Start data transmision\n");
	//	#endif
	status = g_application_run (G_APPLICATION (app), argc, argv);
	g_object_unref (app);
	return 0;
}
AcBr::ErrorStatus
selectEntityByType(AcBrEntity*& pEnt, AcDb::SubentType& subType)
{
	Acad::ErrorStatus acadReturnValue = Acad::eOk;
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Query validation level
	AcBr::ValidationLevel vlevel = validationLevel();

	// Query the subentity type
	subType = subtype();

	// Query whether to select a database entity or create a new one
	Adesk::Boolean context = (subType != AcDb::kNullSubentType)
		? Adesk::kFalse : localContext();

	if (!context) {
		// Query the subentity by AutoCAD pick and get the subentity path
		AcDbFullSubentPath subPath(kNullSubent);
		acadReturnValue = selectEntity(subType, subPath);
		if (acadReturnValue != Acad::eOk) {
			acutPrintf(ACRX_T("\n Error in selectEntity: %d"), acadReturnValue);
			return (AcBr::ErrorStatus)acadReturnValue;
		}

		// Call the appropriate subentity constructor
		switch (subType) {
		case AcDb::kNullSubentType:
    		pEnt = new AcBrBrep();
			break;
		case AcDb::kFaceSubentType:
    		pEnt = new AcBrFace();
			break;
		case AcDb::kEdgeSubentType:
    		pEnt = new AcBrEdge();
			break;  
		default:
			acutPrintf(ACRX_T("\n selectEntityByType: unsupported subentity type: %d\n"), subType);
			returnValue = (AcBr::ErrorStatus)Acad::eWrongSubentityType;
			return returnValue;
		}
		if (pEnt == NULL) {
			acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n"));
			returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
			return returnValue;
		}

		returnValue = pEnt->set(subPath);
		if (returnValue != AcBr::eOk) {
    		acutPrintf(ACRX_T("\n Error in AcBrEntity::set:"));
    		errorReport(returnValue);
    		return returnValue;
		}
	} else {
		// Create the entity as a local object
		AcDbEntity* pEntity;
		acadReturnValue = createEntity(pEntity);
		if (acadReturnValue != Acad::eOk) {
			acutPrintf(ACRX_T("\n Error in createEntity: %d"), acadReturnValue);
			return (AcBr::ErrorStatus)acadReturnValue;
		}
		if (pEntity == NULL) {
			acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n"));
			returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
			return returnValue;
		}

    	pEnt = new AcBrBrep();
		if (pEnt == NULL) {
			acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n"));
			returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
			return returnValue;
		}

		returnValue = ((AcBrBrep*)pEnt)->set((const AcDbEntity&)*pEntity);
		if (returnValue != AcBr::eOk) {
    		acutPrintf(ACRX_T("\n Error in AcBrEntity::set:"));
    		errorReport(returnValue);
    		return returnValue;
		}
	}

	returnValue = pEnt->setValidationLevel(vlevel);
	if (returnValue != AcBr::eOk) {
    	acutPrintf(ACRX_T("\n Error in AcBrEntity::setValidationLevel:"));
    	errorReport(returnValue);
    	return returnValue;
	}

	return returnValue;
}
Beispiel #28
0
// 显示远方当前目录
void cmd_pwd(int sockfd) {
    sendCommand(sockfd, "PWD", "");
    if (getReplyCode(sockfd) != PATHNAME_CREATE)
        errorReport("Wrong reply for PWD!");
}
Beispiel #29
0
AcBr::ErrorStatus
faceDump(const AcBrFace& faceEntity)
{ 
    AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Verify that AcBr was explicitly and not implicitly loaded,
	// by testing ObjectARX functions (which are unavailable unless
	// explicitly loaded)
    if (faceEntity.isA() == NULL) {
        acutPrintf(ACRX_T("\n faceDump: AcBrEntity::isA() failed\n"));
        return returnValue;
    }
    if (!faceEntity.isKindOf(AcBrFace::desc())) {
        acutPrintf(ACRX_T("\n faceDump: AcBrEntity::isKindOf() failed\n"));
        return returnValue;
    }
	AcBrEntity* entClass = (AcBrEntity*)&faceEntity;
	AcBrEdge* pEdge = AcBrEdge::cast(entClass);  
	if (pEdge != NULL) {
		acutPrintf(ACRX_T("\n faceDump: AcBrEntity::cast() failed\n"));
        return (AcBrErrorStatus)Acad::eNotThatKindOfClass;
	} 

	AcGe::EntityId entId;
	returnValue = faceEntity.getSurfaceType(entId);  
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrFace::getSurfaceType:"));
		errorReport(returnValue);
        return returnValue;
	}

	AcGeSurface* surfaceGeometry = NULL;
    AcGeSurface* nativeGeometry = NULL;

	// NOTE: ignore unsupported geometry types for now, since we already know
	// that elliptic cylinders and elliptic cones are rejected by AcGe, but we
	// can still perform useful evaluations on the external bounded surface.
	returnValue = getNativeSurface(faceEntity, surfaceGeometry, nativeGeometry);  
	if ((returnValue != AcBr::eOk) && (returnValue
		!= (AcBrErrorStatus)Acad::eInvalidInput)) {
		acutPrintf(ACRX_T("\n Error in getNativeSurface:"));
		errorReport(returnValue);
        delete surfaceGeometry;
        delete nativeGeometry;
        return returnValue;
	}

	switch (entId) {
	case(kPlane):
	{ 
		acutPrintf(ACRX_T("\nSurface Type: Plane\n"));
        AcGePlane* planeGeometry = (AcGePlane*)nativeGeometry;
        AcGePoint3d pt = planeGeometry->pointOnPlane();
        AcGeVector3d normal = planeGeometry->normal();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Point on Plane is ("));
		acutPrintf (ACRX_T("%lf , "), pt.x);	
		acutPrintf (ACRX_T("%lf , "), pt.y);
		acutPrintf (ACRX_T("%lf "), pt.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Plane normal direction is ("));
		acutPrintf (ACRX_T("%lf , "), normal.x);	
		acutPrintf (ACRX_T("%lf , "), normal.y);
		acutPrintf (ACRX_T("%lf "), normal.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    } 
	
	case(kSphere):
    {
		acutPrintf(ACRX_T("\nSurface Type: Sphere\n"));
        AcGeSphere* sphereGeometry = (AcGeSphere*)nativeGeometry;
        AcGePoint3d centre = sphereGeometry->center();
		double ang1, ang2, ang3, ang4;
        sphereGeometry->getAnglesInU(ang1, ang2);
        sphereGeometry->getAnglesInV(ang3, ang4);
        AcGePoint3d north = sphereGeometry->northPole();
        AcGePoint3d south = sphereGeometry->southPole();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Sphere centre is ("));
		acutPrintf (ACRX_T("%lf , "), centre.x);	
		acutPrintf (ACRX_T("%lf , "), centre.y);
		acutPrintf (ACRX_T("%lf "), centre.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Sphere radius is %lf\n"), sphereGeometry->radius());
		acutPrintf(ACRX_T(" Sphere start angle in U is %lf\n"), ang1);
		acutPrintf(ACRX_T(" Sphere end angle in U is %lf\n"), ang2);
		acutPrintf(ACRX_T(" Sphere start angle in V is %lf\n"), ang3);
		acutPrintf(ACRX_T(" Sphere end angle in V is %lf\n"), ang4);
		acutPrintf(ACRX_T(" Sphere north pole is ("));
		acutPrintf (ACRX_T("%lf , "), north.x);	
		acutPrintf (ACRX_T("%lf , "), north.y);
		acutPrintf (ACRX_T("%lf "), north.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Sphere south pole is ("));
		acutPrintf (ACRX_T("%lf , "), south.x);	
		acutPrintf (ACRX_T("%lf , "), south.y);
		acutPrintf (ACRX_T("%lf "), south.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    }
	
	case(kTorus):
    {
		acutPrintf(ACRX_T("\nSurface Type: Torus\n"));
        AcGeTorus* torusGeometry = (AcGeTorus*)nativeGeometry;
        AcGePoint3d centre = torusGeometry->center();
		double ang1, ang2, ang3, ang4;
        torusGeometry->getAnglesInU(ang1, ang2);
        torusGeometry->getAnglesInV(ang3, ang4);
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Torus centre is ("));
		acutPrintf (ACRX_T("%lf , "), centre.x);	
		acutPrintf (ACRX_T("%lf , "), centre.y);
		acutPrintf (ACRX_T("%lf "), centre.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Torus major radius is %lf\n"), torusGeometry->majorRadius());
		acutPrintf(ACRX_T(" Torus minor radius is %lf\n"), torusGeometry->minorRadius());
		acutPrintf(ACRX_T(" Torus start angle in U is %lf\n"), ang1);
		acutPrintf(ACRX_T(" Torus end angle in U is %lf\n"), ang2);
		acutPrintf(ACRX_T(" Torus start angle in V is %lf\n"), ang3);
		acutPrintf(ACRX_T(" Torus end angle in V is %lf\n"), ang4);
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;	
	}	
	
	case(kCylinder):
    {
		acutPrintf(ACRX_T("\nSurface Type: Circular Cylinder\n"));
        AcGeCylinder* cylinderGeometry = (AcGeCylinder*)nativeGeometry;
        AcGePoint3d origin = cylinderGeometry->origin();
		double ang1, ang2;
        cylinderGeometry->getAngles(ang1, ang2);
        AcGeInterval ht;
        cylinderGeometry->getHeight(ht);
        double height = ht.upperBound() - ht.lowerBound();
        AcGeVector3d refAxis = cylinderGeometry->refAxis();
        AcGeVector3d symAxis = cylinderGeometry->axisOfSymmetry();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Circular Cylinder origin is ("));
		acutPrintf (ACRX_T("%lf , "), origin.x);	
		acutPrintf (ACRX_T("%lf , "), origin.y);
		acutPrintf (ACRX_T("%lf "), origin.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cylinder radius is %lf\n"), cylinderGeometry->radius());
		acutPrintf(ACRX_T(" Circular Cylinder start angle is %lf\n"), ang1);
		acutPrintf(ACRX_T(" Circular Cylinder end angle is %lf\n"), ang2);
		if (cylinderGeometry->isClosedInU())
			acutPrintf(ACRX_T(" Circular Cylinder height is %lf\n"), height);
        else acutPrintf(ACRX_T(" Circular Cylinder is not closed in U\n"));
		acutPrintf(ACRX_T(" Circular Cylinder reference axis is ("));
		acutPrintf (ACRX_T("%lf , "), refAxis.x);	
		acutPrintf (ACRX_T("%lf , "), refAxis.y);
		acutPrintf (ACRX_T("%lf "), refAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cylinder axis of symmetry is ("));
		acutPrintf (ACRX_T("%lf , "), symAxis.x);	
		acutPrintf (ACRX_T("%lf , "), symAxis.y);
		acutPrintf (ACRX_T("%lf "), symAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    }

	case(kCone):
    {
		acutPrintf(ACRX_T("\nSurface Type: Circular Cone\n"));
        AcGeCone* coneGeometry = (AcGeCone*)nativeGeometry;
        AcGePoint3d centre = coneGeometry->baseCenter();
		double ang1, ang2;
        coneGeometry->getAngles(ang1, ang2);
        AcGeVector3d axis1 = coneGeometry->axisOfSymmetry();
        AcGeVector3d axis2 = coneGeometry->refAxis();
        AcGePoint3d apex = coneGeometry->apex();
		double cosAng, sinAng;
        coneGeometry->getHalfAngle(cosAng, sinAng);
        AcGeInterval ht;
        coneGeometry->getHeight(ht);
        double height = ht.upperBound() - ht.lowerBound();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Circular Cone base centre is ("));
		acutPrintf (ACRX_T("%lf , "), centre.x);	
		acutPrintf (ACRX_T("%lf , "), centre.y);
		acutPrintf (ACRX_T("%lf "), centre.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cone base radius is %lf\n"), coneGeometry->baseRadius());
		acutPrintf(ACRX_T(" Circular Cone start angle is %lf\n"), ang1);
		acutPrintf(ACRX_T(" Circular Cone end angle is %lf\n"), ang2);
		acutPrintf(ACRX_T(" Circular Cone axis of symmetry is ("));
		acutPrintf (ACRX_T("%lf , "), axis1.x);	
		acutPrintf (ACRX_T("%lf , "), axis1.y);
		acutPrintf (ACRX_T("%lf "), axis1.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cone reference axis is ("));
		acutPrintf (ACRX_T("%lf , "), axis2.x);	
		acutPrintf (ACRX_T("%lf , "), axis2.y);
		acutPrintf (ACRX_T("%lf "), axis2.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cone apex is ("));
		acutPrintf (ACRX_T("%lf , "), apex.x);	
		acutPrintf (ACRX_T("%lf , "), apex.y);
		acutPrintf (ACRX_T("%lf "), apex.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cone cosine of major half-angle is %lf\n"), cosAng);
		acutPrintf(ACRX_T(" Circular Cone sine of major half-angle is %lf\n"), sinAng);
		if (coneGeometry->isClosedInU())
			acutPrintf(ACRX_T(" Circular Cone height is %lf\n"), height);
        else acutPrintf(ACRX_T(" Circular Cone is not closed in U\n"));
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    }
	
	case(kNurbSurface):
    {
		acutPrintf(ACRX_T("\nSurface Type: NURB Surface\n"));
        AcGeNurbSurface* nurbGeometry = (AcGeNurbSurface*)nativeGeometry;
		int nCtrlPtsU = nurbGeometry->numControlPointsInU();
		int nCtrlPtsV = nurbGeometry->numControlPointsInV();
		int nKnotsU = nurbGeometry->numKnotsInU();
		int nKnotsV = nurbGeometry->numKnotsInV();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" NURB Surface degree in U is %d\n"), nurbGeometry->degreeInU());
		acutPrintf(ACRX_T(" NURB Surface degree in V is %d\n"), nurbGeometry->degreeInV());
		acutPrintf(ACRX_T(" NURB Surface number of control points in U is %d\n"), nCtrlPtsU);
		acutPrintf(ACRX_T(" NURB Surface number of control points in V is %d\n"), nCtrlPtsV);
		acutPrintf(ACRX_T(" NURB Surface number of knots in U is %d\n"), nKnotsU);
		acutPrintf(ACRX_T(" NURB Surface number of knots in V is %d\n"), nKnotsV);
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    }
	
	// NOTE: This surface is not yet supported in AcGe, so we infer the definition
	// data by analysing evaluated data on the external bounded surface.
	case(kEllipCylinder):
	{
		acutPrintf(ACRX_T("\nSurface Type: Elliptic Cylinder\n"));
        AcGePoint3d p0 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, 0.0));
        AcGePoint3d p1 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, kPi));
        AcGePoint3d p2 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, kHalfPi));
        AcGePoint3d origin(((p0.x + p1.x) / 2.0),
			               ((p0.y + p1.y) / 2.0),
						   ((p0.z + p1.z) / 2.0));
        AcGeVector3d majAxis = p0 - origin;
        AcGeVector3d minAxis = p2 - origin;
        AcGeVector3d symAxis = (majAxis.crossProduct(minAxis)).normalize();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Elliptic Cylinder origin is ("));
		acutPrintf (ACRX_T("%lf , "), origin.x);	
		acutPrintf (ACRX_T("%lf , "), origin.y);
		acutPrintf (ACRX_T("%lf "), origin.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cylinder major radius is %lf\n"), majAxis.length());
		acutPrintf(ACRX_T(" Elliptic Cylinder minor radius is %lf\n"), minAxis.length());
		acutPrintf(ACRX_T(" Elliptic Cylinder major axis is ("));
		acutPrintf (ACRX_T("%lf , "), majAxis.x);	
		acutPrintf (ACRX_T("%lf , "), majAxis.y);
		acutPrintf (ACRX_T("%lf "), majAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cylinder minor axis is ("));
		acutPrintf (ACRX_T("%lf , "), minAxis.x);	
		acutPrintf (ACRX_T("%lf , "), minAxis.y);
		acutPrintf (ACRX_T("%lf "), minAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cylinder axis of symmetry is ("));
		acutPrintf (ACRX_T("%lf , "), symAxis.x);	
		acutPrintf (ACRX_T("%lf , "), symAxis.y);
		acutPrintf (ACRX_T("%lf "), symAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
	}

	// NOTE: This surface is not yet supported in AcGe, so we infer the definition
	// data by analysing evaluated data on the external bounded surface.
	case(kEllipCone):
	{
		acutPrintf(ACRX_T("\nSurface Type: Elliptic Cone\n"));
        AcGePoint3d p0 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, 0.0));
        AcGePoint3d p1 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, kPi));
        AcGePoint3d p2 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, kHalfPi));
        AcGePoint3d p3 = surfaceGeometry->evalPoint(AcGePoint2d(1.0, 0.0));
        AcGePoint3d centre(((p0.x + p1.x) / 2.0),
			               ((p0.y + p1.y) / 2.0),
						   ((p0.z + p1.z) / 2.0));
        AcGeVector3d majAxis = p0 - centre;
        AcGeVector3d minAxis = p2 - centre;
        AcGeVector3d symAxis = (majAxis.crossProduct(minAxis)).normalize();
		double halfAng = kHalfPi - majAxis.angleTo(p3 - p0);
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Elliptic Cone base centre is ("));
		acutPrintf (ACRX_T("%lf , "), centre.x);	
		acutPrintf (ACRX_T("%lf , "), centre.y);
		acutPrintf (ACRX_T("%lf "), centre.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cone base major radius is %lf\n"), majAxis.length());
		acutPrintf(ACRX_T(" Elliptic Cone base minor radius is %lf\n"), minAxis.length());
		acutPrintf(ACRX_T(" Elliptic Cone major axis is ("));
		acutPrintf (ACRX_T("%lf , "), majAxis.x);	
		acutPrintf (ACRX_T("%lf , "), majAxis.y);
		acutPrintf (ACRX_T("%lf "), majAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cone minor axis is ("));
		acutPrintf (ACRX_T("%lf , "), minAxis.x);	
		acutPrintf (ACRX_T("%lf , "), minAxis.y);
		acutPrintf (ACRX_T("%lf "), minAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cone axis of symmetry is ("));
		acutPrintf (ACRX_T("%lf , "), symAxis.x);	
		acutPrintf (ACRX_T("%lf , "), symAxis.y);
		acutPrintf (ACRX_T("%lf "), symAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cone cosine of major half-angle is %lf\n"), cos(halfAng));
		acutPrintf(ACRX_T(" Elliptic Cone sine of major half-angle is %lf\n"), sin(halfAng));
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
	}

	default:
		acutPrintf(ACRX_T("\nSurface Type: Unexpected Non Surface\n"));
		return (AcBrErrorStatus)Acad::eInvalidInput;
	} // end switch(entId)	
    
	delete nativeGeometry;

	// Evaluate the surface - note that the u,v bounds will not consider any
	// holes in the surface. To compute a u,v zone of exclusion for evaluation,
	// check for additional (i.e., inner) loops and get the bounding boxes for
	// the loops, then convert those to parameter space boxes. There is no
	// particular guarantee that outer loop(s) are the first in the face-loop
	// list, however, and we currently have no way to query a loop to find out
	// which type it is. Still, the maximal u,v parameter range will be useful
	// for most surfaces and most evaluation purposes.
	AcGeInterval uParam;
	AcGeInterval vParam;
	((AcGeExternalBoundedSurface*)surfaceGeometry)->getEnvelope(uParam, vParam);
    // Make sure the u,v values are legal and the envelope is bounded
    if ((uParam.isBounded()) && (vParam.isBounded())) {
		AcGePoint2d midRange;
		midRange.x = uParam.lowerBound() + (uParam.length() / 2.0);
		midRange.y = vParam.lowerBound() + (vParam.length() / 2.0);
		AcGePoint3d pointOnSurface =
			((AcGeExternalBoundedSurface*)surfaceGeometry)->evalPoint(midRange);
		acutPrintf(ACRX_T("\nSurface Evaluation Begin:\n"));
		acutPrintf(ACRX_T(" Parameter space bounds are (("));
        acutPrintf(ACRX_T("%lf, "), uParam.lowerBound());
        acutPrintf(ACRX_T("%lf "), uParam.upperBound());
        acutPrintf(ACRX_T("), (\n"));
        acutPrintf(ACRX_T("%lf, "), vParam.lowerBound());
        acutPrintf(ACRX_T("%lf "), vParam.upperBound());
        acutPrintf(ACRX_T("))\n"));
		acutPrintf(ACRX_T(" Parameter space mid-range is ("));
        acutPrintf(ACRX_T(" %lf, "), midRange.x);
        acutPrintf(ACRX_T("%lf "), midRange.y);
        acutPrintf(ACRX_T(")\n"));
		acutPrintf(ACRX_T(" Point on surface is ("));
		acutPrintf (ACRX_T("%lf , "), pointOnSurface.x);	
		acutPrintf (ACRX_T("%lf , "), pointOnSurface.y);
		acutPrintf (ACRX_T("%lf "), pointOnSurface.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Evaluation End\n"));
    }
	delete surfaceGeometry;

	Adesk::Boolean oriented;
	returnValue = faceEntity.getOrientToSurface(oriented);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrFace::getOrientToSurface:"));
        errorReport(returnValue);
		return returnValue;
	} 
	oriented ? acutPrintf(ACRX_T("\nSurface Orientation is Positive\n"))
	    : acutPrintf(ACRX_T("\nSurface Orientation is Negative\n"));

	return returnValue;
}
Beispiel #30
0
AcBr::ErrorStatus
meshDump(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;
	}

	// count the elements
	int elemCount = 0;
	while (!meshElemTrav.done() && (returnValue == AcBr::eOk) && !acedUsrBrk()) {
	    elemCount++;
	    acutPrintf("\n ***Element No: %d \n", elemCount);

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

		AcGeVector3d normal;
		returnValue = currentElem.getNormal(normal);
		if (returnValue != AcBr::eOk) {	
			acutPrintf("\n Error in AcBrElement2d::getNormal:"); 
			errorReport(returnValue);
			return returnValue;
		}
        acutPrintf("\n Element Normal is (");
        acutPrintf ("%lf, ", normal.x);	
        acutPrintf ("%lf, ", normal.y);
        acutPrintf ("%lf", normal.z);
        acutPrintf(")\n");	

    	// Determine the entity which contains this element
    	AcBrEntity* entityAssociated = NULL;
    	returnValue = currentElem.getEntityAssociated(entityAssociated);
    	if (returnValue != AcBr::eOk) {
    		acutPrintf("\n Error in AcBrElement2d::getEntityAssociated:");
    		errorReport(returnValue);
    		delete entityAssociated;
    		return returnValue;
    	}
    	entityAssociatedReport(entityAssociated);
    	delete entityAssociated;

    	// count the nodes
		int nodeCount = 0;
		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)) { 
		    nodeCount++;

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

			// dump the node geometry data
			returnValue = nodeDump(node);
	    	if (returnValue != AcBr::eOk) {
				acutPrintf("\n Error in nodeDump:");
			    errorReport(returnValue);
			    return returnValue;
		    }

			// dump the node surface data
			AcGePoint2d point;
			returnValue = elemNodeTrav.getParamPoint(point);
		    if (returnValue != AcBr::eOk) {	
			    acutPrintf("\n Error in AcBrElement2dNodeTraverser::getParamPoint:"); 
			    errorReport(returnValue);
			    return returnValue;
		    }
        	acutPrintf("\n Node Param Point is (");
        	acutPrintf ("%lf, ", point.x);	
        	acutPrintf ("%lf, ", point.y);
        	acutPrintf(")\n");

			AcGeVector3d normal;
			returnValue = elemNodeTrav.getSurfaceNormal(normal);
		    if (returnValue != AcBr::eOk) {	
			    acutPrintf("\n Error in AcBrElement2dNodeTraverser::getSurfaceNormal:"); 
			    errorReport(returnValue);
			    return returnValue;
		    }
        	acutPrintf("\n Node Surface Normal is (");
        	acutPrintf ("%lf, ", normal.x);	
        	acutPrintf ("%lf, ", normal.y);
        	acutPrintf ("%lf", normal.z);
        	acutPrintf(")\n");	

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

	    acutPrintf("\n ****Element No. %d has %d nodes\n", elemCount, nodeCount);	  

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

	}  // end mesh while

	acutPrintf("\n ***Mesh has %d elements\n", elemCount);	  

	return returnValue;
}