Example #1
0
static void AdjustObturationPointSource( const AcGePoint3dArray& polygon, const AcGePoint3dArray& ext_polygon, AcGePoint3dArray& ob_pts )
{
    bool isClockWise = ( ClockWise( polygon ) == -1 );

    int n = ob_pts.length();
    int m = polygon.length();
    for( int i = 0; i < n; i++ )
    {
        int pos = FindPointOnPolygon( ob_pts[i], polygon );
        //acutPrintf(_T("\n点源位置:%d"), pos);
        if( pos != -1 )
        {
            int p1 = ( ( pos == 0 ) ? m - 1 : pos - 1 );
            int p2 = pos;
            int p3 = ( ( pos == m - 1 ) ? 0 : pos + 1 );
            ob_pts[i] = ProjectPointOfTwoLine(
                            polygon[p2],
                            polygon[p3],
                            ext_polygon[p2],
                            ext_polygon[p3],
                            ob_pts[i] );

            // 进行将点源坐标向采空区做微小的调整
            ob_pts[i] = MinorAjustPointSource(
                            isClockWise,
                            polygon[p1],  // 前一个点
                            polygon[p2],            // 当前点
                            polygon[p3],      // 下一个点
                            ob_pts[i] );
        }
    }
}
Example #2
0
int CArxHelper::CreatePLine(AcDbPolyline*& pPolyline, const AcGePoint3dArray& arrPt, double dWith, BOOL bClose)
{
	pPolyline = new AcDbPolyline(arrPt.length());
	for(int i = 0; i < arrPt.length(); i++)
	{
		pPolyline->addVertexAt(i,arrPt.at(i).convert2d(AcGePlane::kXYPlane),0.0);
	}
	pPolyline->setConstantWidth(dWith);
	pPolyline->setClosed(bClose);
	return 0;
}
Example #3
0
static void ExplodeGoafPolygon( const AcGePoint3dArray& polygon,
                                const AcGePoint3dArray& inner_polygon,
                                const AcGePoint3dArray& outer_polygon,
                                AcGePoint3dArray& spts, AcGePoint3dArray& epts )
{
    int n = polygon.length();
    for( int i = 0; i < n; i++ )
    {
        AcGePoint3d spt = polygon[i], ept = polygon[( i + 1 ) % n];

        // 如果向外扩展的坐标没有发生变化
        // 则使向内扩展坐标
        if( spt == outer_polygon[2 * i] || ept == outer_polygon[2 * i + 1] )
        {
            spt = inner_polygon[i];
            ept = inner_polygon[( i + 1 ) % n];
        }
        else
        {
            spt = outer_polygon[2 * i];
            ept = outer_polygon[2 * i + 1];
        }

        spts.append( spt );
        epts.append( ept );
    }
}
Example #4
0
Acad::ErrorStatus
AsdkSmiley::osnapQuad(
    const AcGePoint3d& pickPoint,
    AcGePoint3dArray& snapPoints) const
{
    AcGeVector3d xoff(0,0,0);
    AcGeVector3d yoff(0,0,0);

    // Osnap quad to the face's quad points
    //
    xoff.x = yoff.y = radius();
    AcGePoint3d center( center() );
    snapPoints.append( center + xoff );
    snapPoints.append( center + yoff );
    snapPoints.append( center - xoff );
    snapPoints.append( center - yoff );
    
    // Osnap quad to the eyes' quad points
    //
    AcGePoint3dArray eyearray;
    AcGePoint3d eyecen;
    eyes( eyearray );
    for( int i = 0; i < eyearray.length(); i++ ){
        eyecen = eyearray.at( i );
        xoff.x = meyesize;
        yoff.y = meyesize;
        snapPoints.append( eyecen + xoff );
        snapPoints.append( eyecen + yoff );
        snapPoints.append( eyecen - xoff );
        snapPoints.append( eyecen - yoff );
    }

    return Acad::eOk;
}
Example #5
0
void DrawRect( AcGiWorldDraw* mode, const AcGePoint3d& insertPt, double angle, double width, double height, bool fill )
{
    AcGiSubEntityTraits& traits = mode->subEntityTraits();

    AcGeVector3d v1( AcGeVector3d::kXAxis ), v2( AcGeVector3d::kXAxis );
    v1.rotateBy( angle, AcGeVector3d::kZAxis );
    v2.rotateBy( angle + PI / 2, AcGeVector3d::kZAxis );

    AcGePoint3dArray pts;
    pts.append( CaclPt( insertPt, v1, width, v2, height ) );

    v1.rotateBy( PI, AcGeVector3d::kZAxis );
    pts.append( CaclPt( insertPt, v1, width, v2, height ) );

    v2.rotateBy( PI, AcGeVector3d::kZAxis );
    pts.append( CaclPt( insertPt, v1, width, v2, height ) );

    v1.rotateBy( PI, AcGeVector3d::kZAxis );
    pts.append( CaclPt( insertPt, v1, width, v2, height ) );

    // 是否填充
    AcGiFillType ft = traits.fillType();
    traits.setFillType( fill ? kAcGiFillAlways : kAcGiFillNever );

    mode->geometry().polygon( pts.length(), pts.asArrayPtr() );

    traits.setFillType( ft );
}
Example #6
0
void DrawCmd::DrawChimney( void )
{
    acutPrintf( _T( "\n绘制风筒测试..." ) );

    AcDbObjectId objId = ArxUtilHelper::SelectObject( _T( "请选择一个掘进工作面:" ) );
    if( objId.isNull() ) return;
    if( !ArxUtilHelper::IsEqualType( _T( "TTunnel" ), objId ) ) return;

    AcDbObjectIdArray objIds;
    DrawHelper::GetTagGEById2( objId, _T( "Chimney" ), objIds );
    if( !objIds.isEmpty() )
    {
        AfxMessageBox( _T( "该掘进工作面已设置了风筒!" ) );
        return;
    }

    AcGePoint3dArray pts;
    PolyLineJig jig;
    if( !jig.doJig( pts ) ) return;

    int len = pts.length();
    acutPrintf( _T( "\n点个数:%d" ), len );
    if( len < 2 ) return;

    Chimney* pChimney = new Chimney();
    pChimney->setRelatedGE( objId ); // 关联的图元必须是掘进工作面

    for( int i = 0; i < len; i++ ) pChimney->addControlPoint( pts[i] );

    // 初始化并提交到数据库
    if( !ArxUtilHelper::PostToModelSpace( pChimney ) ) delete pChimney;
}
Example #7
0
// 返回值:
//		0  -- 错误
//		1  -- 顺时针
//	   -1  -- 逆时针
int ClockWise( const AcGePoint3dArray& polygon )
{
    int n = polygon.length();
    if ( n < 3 ) return 0;

    int count = 0;
    for( int i = 0; i < n; i++ )
    {
        int j = ( i + 1 ) % n;
        int k = ( i + 2 ) % n;
        double z  = ( polygon[j].x - polygon[i].x ) * ( polygon[k].y - polygon[j].y );
        z -= ( polygon[j].y - polygon[i].y ) * ( polygon[k].x - polygon[j].x );
        if ( z < 0 )
        {
            count--;
        }
        else if ( z > 0 )
        {
            count++;
        }
    }
    if ( count > 0 )
        return -1;
    else if ( count < 0 )
        return 1;
    else
        return 0;
}
Example #8
0
static void AdjustGoafPolygon( const AcDbVoidPtrArray& lines,
                               const AcGePoint3dArray& polygons,
                               const AcDbIntArray& polygon_counts,
                               const AcDbIntArray& colinearEdges,
                               const AcDbIntArray& parTypes,
                               AcGePoint3dArray& spts,
                               AcGePoint3dArray& epts,
                               AcGeDoubleArray& dirs,
                               AcDbIntArray& gas_types,
                               AcDbIntArray& gas_linePos )
{
    // 查找所有采空区边对应的直线
    AcDbIntArray goaf_linePos;
    FindGoafPolygonLinePos( lines, polygons, polygon_counts, goaf_linePos );

    // 分解所有的分支
    AcGePoint3dArray ex_spts, ex_epts;
    AcGeDoubleArray ex_dirs;
    AdjustAndExplodeGoafPolygons( lines, polygons, polygon_counts, ex_spts, ex_epts, ex_dirs );

    assert( ex_spts.length() == polygons.length() );

    for( int i = 0; i < polygon_counts.length(); i++ )
    {
        AppendNewGoafPolygon(
            polygons, polygon_counts,
            colinearEdges, parTypes,
            ex_spts, ex_epts, ex_dirs,
            goaf_linePos,
            i,
            spts, epts, dirs,
            gas_types,
            gas_linePos );
    }
}
Example #9
0
static void FindPolygonLinePos( const AcDbVoidPtrArray& lines,
                                const AcGePoint3dArray& polygons,
                                const AcDbIntArray& polygon_counts,
                                int k,
                                AcDbIntArray& linePos )
{
    int s = 0;
    for( int i = 0; i < k; i++ )
    {
        s += polygon_counts[i];
    }
    int t = s + polygon_counts[k];

    AcGePoint3dArray polygon;
    for( int i = s; i < t; i++ )
    {
        polygon.append( polygons[i] );
    }

    int n = polygon.length();
    for( int i = 0; i < n; i++ )
    {
        linePos.append( FindLineByPoints( lines, polygon[i], polygon[( i + 1 ) % n] ) );
    }
}
Example #10
0
static void write_back_data( Vector<double>& fnew, AcGePoint3dArray& datas )
{
    int n = datas.length();
    for( int i = 0; i < n; i++ )
    {
        datas[i].z = fnew( i );
    }
}
Example #11
0
Adesk::Boolean
AsdkSmiley::worldDraw(AcGiWorldDraw *wd)
{
    assertReadEnabled();

    AcGeVector3d offset(0,0,0);
    AcGeCircArc3d face = mfacecircle;

    // If dragging, don't fill the smiley
    //
    if( wd->isDragging() ){
        wd->subEntityTraits().setColor( colorIndex() );
        wd->subEntityTraits().setFillType( kAcGiFillNever );
    }
    else
        wd->subEntityTraits().setFillType( kAcGiFillAlways );

    // Give the circle a GS marker of 1
    //
    wd->subEntityTraits().setSelectionMarker( 1 );
    wd->geometry().circle( face.center(), face.radius(), mnormal );

    if( !wd->isDragging() )
        wd->subEntityTraits().setColor( 250 );

    // Give the eyes GS markers of 2 etc.
    //
    AcGePoint3dArray eyearray;

    eyes( eyearray );
    for( int i = 0; i < eyearray.length(); i++ ){
        wd->subEntityTraits().setSelectionMarker( i + 2 );
        wd->geometry().circle( eyearray.at(i) + offset, meyesize, mnormal );
    }

    AcGePoint3d smilecen( mouthCenter() + offset ),
                startpt( mouthLeft() + offset ),
                endpt( mouthRight() + offset );
    AcGeVector3d startvec = startpt - smilecen,
                 endvec = endpt - smilecen;
    double mouthangle = startvec.angleTo( endvec );

    wd->subEntityTraits().setSelectionMarker( eyearray.length() + 2 );
    wd->geometry().circularArc( smilecen, mouthRadius(), mnormal, startvec, mouthangle, kAcGiArcChord );
    return Adesk::kTrue;
}
Acad::ErrorStatus rx_makeSpline(const AcGePoint3dArray&  pts,
			              AcDbSpline*&       pSpline)
{
    Acad::ErrorStatus es = Acad::eOk;

    AcGeDoubleArray knots, weights;
    for (int i = 0; i < pts.length(); i++) {
        weights.append(1.0);
    }

    getUniformKnots(pts.length(), 1, 0, knots);

    pSpline = new AcDbSpline(1, Adesk::kFalse, Adesk::kFalse,
                                Adesk::kFalse, pts, knots, weights);
 
    return es;
}
void ContourLabel::setPoints( const AcGePoint3dArray& cnpts )
{
    assertWriteEnabled();
    if( cnpts.length() > 2 )
    {
        m_pts.removeAll();
        m_pts.append( cnpts );
    }
}
Example #14
0
static void WritePressFacility( CStdioFile& outfile,
                                const AcGePoint3dArray& press_spts,
                                const AcGePoint3dArray& press_epts,
                                const AcGeDoubleArray press_dirs )
{
    CString str;
    str.Format( _T( "%d\n" ), press_spts.length() );
    outfile.WriteString( str );
}
int Additional_Class::GetMINPt( int pos, AcGePoint3dArray PtList )
{
	AcGePoint3d tempPT;
	if (PtList.length() == 0)
	{
		return 0;
	}
	tempPT = PtList[0];
	int res;
	for (int i = 0; i<PtList.length(); i++)
	{
		if(PtList[i][pos] < tempPT[pos])
		{
			tempPT = PtList[i];
			res = i;
		}
	}
	return res;
}
void Additional_Class::Get_PolyLineCoor( AcGePoint3dArray PointArray, LINEINFO &X_Coor_List,LINEINFO &Y_Coor_List )
{
	for (int index=0; index<PointArray.length(); index++)
	{
		CString tempStr;
		tempStr.Format(_T("%.2f"),PointArray[index].x);
		X_Coor_List.push_back(tempStr);
		tempStr.Format(_T("%.2f"),PointArray[index].y);
		Y_Coor_List.push_back(tempStr);
	}
}
static void DrawLinePoints( AcGiWorldDraw* mode, const AcGePoint3dArray& pts )
{
    int len = pts.length();
    for( int i = 0; i < len - 1; i++ )
    {
        AcGePoint3dArray tpts;
        tpts.append( pts[i] );
        tpts.append( pts[i + 1] );
        mode->geometry().worldLine( tpts.asArrayPtr() );
    }
}
Example #18
0
// 查找采空区的其它边
void FindGasBoundary( const AcDbObjectIdArray& objIds,
                      const AcDbVoidPtrArray& lines,
                      AcGePoint3dArray& spts,
                      AcGePoint3dArray& epts,
                      AcGeDoubleArray& dirs,
                      AcDbIntArray& gas_types,
                      AcDbObjectIdArray& gas_objIds )
{
    // 查找所有的采空区
    AcDbObjectIdArray goaf_objIds;
    FindAllGoafs( goaf_objIds );

    // 将采空区多边形转换成一个1维数组
    AcGePoint3dArray polygons;
    AcDbIntArray polygon_counts;
    BuildGoafPolygonArray( goaf_objIds, polygons, polygon_counts );

    // 标记采空区分支是否与其它采空区有共线边
    AcDbIntArray colinearEdges;
    FindPolygonColinearEdges( polygons, polygon_counts, colinearEdges );

    // 查找所有的工作面
    AcDbVoidPtrArray ws_lines;
    FilterLines( lines, ws_lines, true );

    // 划分采空区多边形(工作面、两帮、开切眼)
    AcDbIntArray parTypes;
    PartitionGoafPolygons( ws_lines, polygons, polygon_counts, parTypes );

    assert( parTypes.length() == polygons.length() );

    // 工作面需要特殊处理
    AcDbIntArray gas_linePos;
    AdjustGoafPolygon(
        lines, polygons, polygon_counts,
        colinearEdges, parTypes,
        spts, epts, dirs,
        gas_types, gas_linePos );

    assert( gas_types.length() == gas_linePos.length() );

    for( int i = 0; i < gas_linePos.length(); i++ )
    {
        int pos = gas_linePos[i];
        if( pos != -1 )
        {
            gas_objIds.append( objIds[pos] );
        }
        else
        {
            gas_objIds.append( AcDbObjectId::kNull );
        }
    }
}
Example #19
0
void BuildGoafPolygonArray( const AcDbObjectIdArray& objIds, AcGePoint3dArray& polygons, AcDbIntArray& polygon_counts )
{
    for( int i = 0; i < objIds.length(); i++ )
    {
        // 获取采空区的多边形
        AcGePoint3dArray polygon;
        GetGoafPolygon( objIds[i], polygon );

        polygons.append( polygon );
        polygon_counts.append( polygon.length() );
    }
}
Example #20
0
void DrawPolygon( AcGiWorldDraw* mode, const AcGePoint3dArray& polygon, bool fill )
{
    AcGiSubEntityTraits& traits = mode->subEntityTraits();

    // 是否填充
    AcGiFillType ft = traits.fillType();
    traits.setFillType( fill ? kAcGiFillAlways : kAcGiFillNever );

    mode->geometry().polygon( polygon.length(), polygon.asArrayPtr() );

    traits.setFillType( ft );
}
void
ArxDbgUtils::ucsToWcs(AcGePoint3dArray& ptArray)
{
	AcDbDatabase* db = acdbHostApplicationServices()->workingDatabase();
	ASSERT(db != NULL);

    AcGeMatrix3d m;
    getUcsToWcsMatrix(m, db);

    int len = ptArray.length();
    for (int i=0; i<len; i++)
        ptArray[i] = m * ptArray[i];
}
Example #22
0
void PrintInletBoundary( const AcGePoint3dArray& inlet_spts,
                         const AcGePoint3dArray& inlet_epts,
                         const AcGeDoubleArray& inlet_dirs )
{
    acutPrintf( _T( "打印通风边界: \n" ) );
    int n = inlet_spts.length();
    for( int i = 0; i < n; i++ )
    {
        AcGePoint3d spt = inlet_spts[i], ept = inlet_epts[i];
        double dir = inlet_dirs[i];
        acutPrintf( _T( "  (%.3f, %.3f) --> (%.3f, %.3f) 方向: %.3f\n" ), spt.x, spt.y, ept.x, ept.y, dir );
    }
    acutPrintf( _T( "\n" ) );
}
Example #23
0
void WriteAirLeakDataFile( const CString& filepath,
                           const AcGePoint3dArray al_pts,
                           const AirLeakDataArray& al_datas )
{
    CStdioFile outfile;
    outfile.Open( filepath, CFile::modeCreate | CFile::modeWrite );

    CString str;
    str.Format( _T( "%d\n" ), al_pts.length() );
    outfile.WriteString( str );

    for( int i = 0; i < al_pts.length(); i++ )
    {
        AcGePoint3d pt = al_pts[i];
        str.Format( _T( "%.4f\t%.4f\t%.4f\t" ), pt.x, pt.y, pt.z );

        AirLeakData data = al_datas[i];
        str.AppendFormat( _T( "%.4f\n" ), data.q );

        outfile.WriteString( str );
    }
    outfile.Close();
}
void
ArxDbgEdInputContextReactor::printPoints(const AcGePoint3dArray& pts) const
{
	int len = pts.length();
	if (len == 0)
		return;

	printValue(_T("POINTS"), _T(""));
	
	CString str;
	for (int i=0; i<len; i++) {
		printValue(_T(""), ArxDbgUtils::ptToStr(pts[i], str));
    }
}
void Additional_Class::Get_PolyLine_Point( AcDbObjectId PolyLineId,AcGePoint3dArray &PointArray )
{
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN POLYLINE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENTITY IS NOT POLYLINE"));
		return;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	int num = pPolyLine->numVerts();
	AcGePoint3d Start_temp_PT,End_temp_PT;
	for (int index=0; index<num; index++)
	{
		if (pPolyLine->segType(index) == AcDbPolyline::kLine)
		{
			AcGeLineSeg3d tempLine;
			pPolyLine->getLineSegAt(index,tempLine);
			Start_temp_PT = tempLine.startPoint();
			End_temp_PT = tempLine.endPoint();
			PointArray.append(Start_temp_PT);
			PointArray.append(End_temp_PT);
		}
		else if (pPolyLine->segType(index) == AcDbPolyline::kArc)
		{
			AcGeCircArc2d tempArc;
			pPolyLine->getArcSegAt(index,tempArc);
			Start_temp_PT.set(tempArc.startPoint().x,tempArc.startPoint().y,0);
			End_temp_PT.set(tempArc.endPoint().x,tempArc.endPoint().y,0);
			PointArray.append(Start_temp_PT);
			PointArray.append(End_temp_PT);
		}
	}
	pEnt_Temp->close();
	AcGeIntArray IndexArray;
	for (int i=1; i<PointArray.length();i++)
	{
		if (PointArray[i] == PointArray[i-1])
		{
			IndexArray.append(i);
			PointArray.remove(PointArray[i]);
		}
	}
}
Example #26
0
void PrintGasBoundary( AcGePoint3dArray& spts, AcGePoint3dArray& epts, AcGeDoubleArray& dirs, AcDbIntArray& gas_types )
{
    acutPrintf( _T( "\n打印瓦斯边界: " ) );

    int n = spts.length();
    for( int i = 0; i < n; i++ )
    {
        //acutPrintf(_T("\n  (%.3f, %.3f) --> (%.3f, %.3f)  方向: %.3f  类型: %s"),
        //	spts[i].x, spts[i].y, epts[i].x, epts[i].y, dirs[i], GetGasTypeName(gas_types[i]));

        acutPrintf( _T( "\n  (%.3f, %.3f) --> (%.3f, %.3f)  方向: %.3f  类型: %d" ),
                    spts[i].x, spts[i].y, epts[i].x, epts[i].y, dirs[i], gas_types[i] );
    }
    acutPrintf( _T( "\n" ) );
}
Example #27
0
void WriteNitrogenPipeDataFile( const CString& filepath,
                                const AcGePoint3dArray& n2_pipe_pts,
                                const NitrogenPipeDataArray& n2_pipe_datas )
{
    CStdioFile outfile;
    outfile.Open( filepath, CFile::modeCreate | CFile::modeWrite );

    CString str;
    str.Format( _T( "%d\n" ), n2_pipe_pts.length() );
    outfile.WriteString( str );

    for( int i = 0; i < n2_pipe_pts.length(); i++ )
    {
        AcGePoint3d pt = n2_pipe_pts[i];
        str.Format( _T( "%.4f\t%.4f\t%.4f\t" ), pt.x, pt.y, pt.z );

        NitrogenPipeData data = n2_pipe_datas[i];
        str.AppendFormat( _T( "%.4f\n" ), data.n2 );

        outfile.WriteString( str );
    }

    outfile.Close();
}
Example #28
0
void CreateContourLabels( double z,
                          const AcGePoint3dArray& cnpts,
                          bool bSmooth,
                          const AcGePoint3dArray& tpts,
                          double textHeight )
{
    //acutPrintf(_T("\nz=%.4f, 标注个数:%d"), z, tpts.length());
    int n = tpts.length();
    for( int i = 0; i < n; i++ )
    {
        //acutPrintf(_T("\n\t(%.3f, %.3f)"), tpts[i].x, tpts[i].y);
        CreateContourLabel( z, cnpts, bSmooth, tpts[i], textHeight );
    }
    //acutPrintf(_T("\n"));
}
Example #29
0
void WriteObturationDataFile( const CString& filepath,
                              const AcGePoint3dArray& ob_pts,
                              const ObturationDataArray& ob_datas )
{
    CStdioFile outfile;
    outfile.Open( filepath, CFile::modeCreate | CFile::modeWrite );

    CString str;
    str.Format( _T( "%d\n" ), ob_pts.length() );
    outfile.WriteString( str );

    for( int i = 0; i < ob_pts.length(); i++ )
    {
        AcGePoint3d pt = ob_pts[i];
        str.Format( _T( "%.4f\t%.4f\t%.4f\t" ), pt.x, pt.y, pt.z );

        ObturationData data = ob_datas[i];
        str.AppendFormat( _T( "%.4f\t%.4f\t%.4f\n" ), data.q, data.ch4, data.o2 );

        outfile.WriteString( str );
    }

    outfile.Close();
}
Example #30
0
void DrawRect( AcGiWorldDraw* mode, const AcGePoint3d& pt, double angle, double width, double height, bool fill )
{
    AcGiSubEntityTraits& traits = mode->subEntityTraits();

    AcGePoint3dArray pts;
    BuildRect( pt, angle, width, height, pts );

    // 是否填充
    AcGiFillType ft = traits.fillType();
    traits.setFillType( fill ? kAcGiFillAlways : kAcGiFillNever );

    mode->geometry().polygon( pts.length(), pts.asArrayPtr() );

    traits.setFillType( ft );
}