bool IntStrListHelper::GetIntStrList( const CString& name, AcDbIntArray& intList, AcStringArray& strList ) { AcStringArray entries; if( !ArxDictHelper::GetAllEntries( INT_LIST_DICT, name, entries ) ) return false; int len = entries.length(); bool ret = ( len > 0 && len % 2 == 0 ); if( ret ) // 长度必须为偶数 { intList.removeAll(); strList.removeAll(); for( int i = 0; i < len; i++ ) { if( i % 2 == 0 ) // 偶数位置的元素为整数 { intList.append( _ttoi( entries[i].kACharPtr() ) ); } else // 奇数位置的元素为字符串 { strList.append( entries[i] ); } } } return ret; }
static void AppendNewGoafPolygon( const AcGePoint3dArray& polygons, const AcDbIntArray& polygon_counts, const AcDbIntArray& colinearEdges, const AcDbIntArray& parTypes, const AcGePoint3dArray& ex_spts, const AcGePoint3dArray& ex_epts, const AcGeDoubleArray& ex_dirs, const AcDbIntArray& linePos, int k, AcGePoint3dArray& spts, AcGePoint3dArray& epts, AcGeDoubleArray& dirs, AcDbIntArray& gas_types, AcDbIntArray& gas_linePos ) { int s = 0; for( int i = 0; i < k; i++ ) { s += polygon_counts[i]; } int t = s + polygon_counts[k]; for( int i = s; i < t; i++ ) { if( colinearEdges[i] == 0 ) { spts.append( ex_spts[i] ); epts.append( ex_epts[i] ); dirs.append( ex_dirs ); gas_types.append( parTypes[i] ); gas_linePos.append( linePos[i] ); } } }
Acad::ErrorStatus TailraceGEDraw::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset ) { assertWriteEnabled () ; for( int i = 0; i < indices.length(); i++ ) { int idx = indices.at( i ); if ( idx == 0 ) { m_insertPt += offset; // 插入点偏移 caculPts(); } // if(idx == 1) // { // // 1) 计算x轴的端点坐标 // AcGeVector3d v(AcGeVector3d::kXAxis); // v.rotateBy(m_angle,AcGeVector3d::kZAxis); // v.rotateBy(3.1415926/2,AcGeVector3d::kZAxis); // AcGePoint3d pt = m_insertPt + v*m_lenth; // // // 2) 进行坐标偏移计算 // pt += offset; // // // 坐标相减,得到一个向量,然后得到向量长度 // m_lenth = (pt - m_insertPt).length(); // caculPts(); // } } return Acad::eOk; }
Acad::ErrorStatus DoubleArcTunnelDraw::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset ) { assertWriteEnabled () ; for( int i = 0; i < indices.length(); i++ ) { int idx = indices.at( i ); if ( idx == 0 ) { m_startPt += offset; } if ( idx == 1 ) { m_endPt += offset; } // 弧的中点 if ( idx == 2 ) { m_thirdPt += offset; } } return Acad::eOk; }
// 查找采空区的其它边 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 ); } } }
Acad::ErrorStatus SimpleChimneyDraw::subMoveGripPointsAt ( const AcDbIntArray& indices, const AcGeVector3d& offset ) { assertWriteEnabled () ; for( int i = 0; i < indices.length(); i++ ) { int idx = indices.at( i ); m_pts[idx] += offset; } return Acad::eOk; }
Acad::ErrorStatus SimpleWindLibraryDraw::subMoveGripPointsAt ( const AcDbIntArray& indices, const AcGeVector3d& offset ) { assertWriteEnabled () ; for( int i = 0; i < indices.length(); i++ ) { int idx = indices.at( i ); // 始节点 if ( idx == 0 ) m_insertPt += offset; } return Acad::eOk; }
void ArxDbgUtils::collectVertices(const AcDb2dPolyline* pline, AcGePoint3dArray& pts, AcDbIntArray& types, AcGeDoubleArray& bulges, AcGeDoubleArray& startWidths, AcGeDoubleArray& endWidths, bool& hasWidth) { ASSERT(pline != NULL); ASSERT(pts.isEmpty() && bulges.isEmpty()); hasWidth = false; AcDbObjectIterator* vertexIter = pline->vertexIterator(); ASSERT(vertexIter != NULL); if (vertexIter == NULL) return; AcDb2dVertex* vertex; for (; !vertexIter->done(); vertexIter->step()) { if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) { if (vertex->vertexType() != AcDb::k2dSplineCtlVertex) { pts.append(pline->vertexPosition(*vertex)); // returns WCS bulges.append(vertex->bulge()); startWidths.append(vertex->startWidth()); endWidths.append(vertex->endWidth()); if (vertex->startWidth() || vertex->endWidth()) hasWidth = true; types.append(vertex->vertexType()); } vertex->close(); } } delete vertexIter; ASSERT(pts.isEmpty() == false); if (pline->isClosed()) { AcGePoint3d tmpPt = pts[0]; // used to be a bug in dynamic arrays (not sure if its still there??) pts.append(tmpPt); bulges.append(0.0); int tmpType = types[0]; types.append(tmpType); double tmpWidth = startWidths[0]; startWidths.append(tmpWidth); tmpWidth = endWidths[0]; endWidths.append(tmpWidth); } }
static void FindGoafPolygonLinePos( const AcDbVoidPtrArray& lines, const AcGePoint3dArray& polygons, const AcDbIntArray& polygon_counts, AcDbIntArray& linePos ) { int n = polygon_counts.length(); for( int i = 0; i < n; i++ ) { AcDbIntArray ex_linePos; FindPolygonLinePos( lines, polygons, polygon_counts, i, ex_linePos ); linePos.append( ex_linePos ); } }
static void PartitionGoafPolygons( const AcDbVoidPtrArray& ws_lines, AcGePoint3dArray& polygons, AcDbIntArray& polygon_counts, AcDbIntArray& parTypes ) { for( int i = 0; i < polygon_counts.length(); i++ ) { AcDbIntArray goaf_parTypes; PartitionGoafPolygon( ws_lines, polygons, polygon_counts, i, goaf_parTypes ); parTypes.append( goaf_parTypes ); } }
Acad::ErrorStatus SphereNitrogenPipeDraw::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset ) { assertWriteEnabled () ; for( int i = 0; i < indices.length(); i++ ) { int idx = indices.at( i ); if ( idx == 0 ) { m_pt += offset; // 插入点偏移 } } return Acad::eOk; }
Acad::ErrorStatus PolyLineDirectionDraw::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset ) { assertWriteEnabled () ; for( int i = 0; i < indices.length(); i++ ) { int idx = indices.at( i ); if ( idx == 0 ) { m_insertPt += offset; // 插入点偏移 } } return Acad::eOk; }
bool IntStrListHelper::AddIntStrPair( const CString& name, int intValue, const CString& strValue ) { if( ( name.GetLength() == 0 ) || strValue.GetLength() == 0 ) return false; AcStringArray strList; AcDbIntArray intList; GetIntStrList( name, intList, strList ); if( intList.contains( intValue ) || strList.contains( strValue ) ) return false; intList.append( intValue ); strList.append( strValue ); RemoveIntStrList( name ); return AddIntStrList( name, intList, strList ); }
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 ); } }
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] ) ); } }
void WriteGoafTBGasDataFile( const CString& filepath, const AcGePoint3dArray& vertices, const AcDbIntArray& edges, const AcDbIntArray& faces, const AcDbIntArray& faces_info, const AcDbIntArray& goafs, const GasParam& gp ) { CStdioFile outfile; outfile.Open( filepath, CFile::modeCreate | CFile::modeWrite ); // 写入采空区个数 CString str; str.Format( _T( "%d\n" ), goafs.length() ); outfile.WriteString( str ); // 写入采空区总面积 double area = CaclTotalGoafArea( vertices, edges, faces, faces_info, goafs ); str.Format( _T( "%.4f\n" ), area ); outfile.WriteString( str ); // 写入(采空区+顶底板)瓦斯涌出量之和 double q = gp.f1 + gp.f4 + gp.f5; str.Format( _T( "%.4f\n" ), q ); outfile.WriteString( str ); outfile.Close(); }
Acad::ErrorStatus SingleTunnelDraw::subMoveGripPointsAt ( const AcDbIntArray& indices, const AcGeVector3d& offset ) { assertWriteEnabled () ; //----- This method is never called unless you return eNotImplemented //----- from the new moveGripPointsAt() method below (which is the default implementation) for( int i = 0; i < indices.length(); i++ ) { int idx = indices.at( i ); // 始节点 if ( idx == 0 ) m_startPt += offset; if ( idx == 1 ) m_endPt += offset; } return Acad::eOk; }
bool EvalService::doRegEval( const CString& regulation, const AcDbIntArray& clauses ) { // 规程评价没有实现或者尚未注册 EvalMethod* pEvalMethod = m_pEvalMethodManager->getEvalMethodByName( regulation ); if( pEvalMethod == 0 ) return false; EvalResultGenerator* pEvalResultGenerator = CreateEvalResultGenerator( pEvalMethod ); // 创建数据库操作对象 CDaoDatabase* pDB = createDB( m_evalResultDataBasePath, false ); // 每次评价都重建数据库(删除已存在的数据库) TableCreator* pTableCreator = new TableCreator( pDB ); DataWriter* pDataWriter = new DataWriter( pDB ); int len = clauses.length(); for( int i = 0; i < len; i++ ) { pEvalResultGenerator->startEval(); pEvalResultGenerator->setClauseNum( clauses[i] ); pEvalResultGenerator->initEvalData(); pEvalResultGenerator->createTable( pTableCreator ); pEvalResultGenerator->initEvalObject(); pEvalResultGenerator->writeToTable( pDataWriter ); pEvalResultGenerator->endEval(); } delete pTableCreator; delete pDataWriter; pDB->Close(); delete pDB; delete pEvalResultGenerator; return true; }
Acad::ErrorStatus GasPumpGEDraw::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset ) { assertWriteEnabled () ; int len = indices.length(); for(int i=0;i<len;i++) { int idx = indices.at(i); if(idx == 0) { // 当前夹点是圆心,移动图形 m_startPt += offset; m_endPt += offset; } } return Acad::eOk; }
static void WriteWallFacility( CStdioFile& outfile, const AcDbIntArray& split_faces, const AcDbIntArray& split_faces_info, const AcDbIntArray split_face_edges ) { CString str; str.Format( _T( "%d\n" ), split_face_edges.length() ); outfile.WriteString( str ); }
// 查找所有只关联一条直线的点坐标对应的分支以及方向 void FindInletBoundary( const AcDbObjectIdArray& objIds, const AcDbVoidPtrArray& lines, AcGePoint3dArray& inlet_spts, AcGePoint3dArray& inlet_epts, AcGeDoubleArray& inlet_dirs, AcDbObjectIdArray& inlet_objIds ) { // 查找所有的点 AcGePoint3dArray pts; GetNodePoints( lines, pts ); if( pts.isEmpty() ) return; for( int i = 0; i < pts.length(); i++ ) { // 查找点关联的双线 AcDbIntArray linePos; FindLinesByPoint( lines, pts[i], linePos ); if( linePos.length() != 1 ) continue; // 获取双线的始末点坐标 int pos = linePos[0]; DoubleLine* pLine = ( DoubleLine* )lines[pos]; AcGePoint3d spt, ept; pLine->getSEPoint( spt, ept ); // 判断当前点是始点还是末点 AcGePoint3d line_spt, line_ept; if( spt == pts[i] ) { pLine->getStartPoints( line_spt, line_ept ); } else { pLine->getEndPoints( line_spt, line_ept ); } inlet_spts.append( line_spt ); inlet_epts.append( line_ept ); inlet_dirs.append( pLine->getAngle() ); inlet_objIds.append( objIds[pos] ); } }
void ArxDbgDbAdeskLogo::getCloneReferences(AcDb::DeepCloneType type, AcDbObjectIdArray& refIds, AcDbIntArray& refTypes) const { // these types should have been filtered out. NOTE that kDcObjects // is usually ambiguous and has been mapped to kDcBlock or kDcCopy. ASSERT((type != AcDb::kDcExplode) && (type != AcDb::kDcInsert) && (type != AcDb::kDcInsertCopy) && (type != AcDb::kDcSymTableMerge) && (type != AcDb::kDcXrefBind) && (type != AcDb::kDcXrefInsert) && (type != AcDb::kDcObjects)); if (type == AcDb::kDcCopy) { refIds.append(m_arbitraryRefEnt); refTypes.append(kClone); // you could set this to kNoClone and both would point to the same one. } else if (type == AcDb::kDcBlock) { refIds.append(m_arbitraryRefEnt); refTypes.append(kClone); // LongTransactions (RefEdit) will not allow our object to be checked // out from a block definition unless its accompanying style def is // also in the check out set (which it won't be by default). So, we // have to tell ::deepClone() to fake like it cloned the style definition // so it will pass LongTransaction's checkOut validation. refIds.append(m_logoStyleId); refTypes.append(kFakeClone); } else if (type == AcDb::kDcWblock) { refIds.append(m_arbitraryRefEnt); refTypes.append(kClone); } else if (type == AcDb::kDcWblkObjects) { refIds.append(m_arbitraryRefEnt); refTypes.append(kClone); } else { ASSERT(0); // which context did we not account for? } }
static void FormatIntListMsg( const AcDbIntArray& intList, const AcStringArray& strList, const CString& name, CString& msg ) { msg.Format( _T( "【%s】数据列表:\n" ), name ); int len = intList.length(); for( int i = 0; i < len; i++ ) { msg.AppendFormat( _T( "%d\t%s\n" ), intList[i], strList[i].kACharPtr() ); } }
static double CaclTotalGoafArea( const AcGePoint3dArray& vertices, const AcDbIntArray& edges, const AcDbIntArray& faces, const AcDbIntArray& faces_info, const AcDbIntArray& goafs ) { double S = 0; for( int i = 0; i < goafs.length(); i++ ) { S += FacePolygonArea( vertices, edges, faces, faces_info, goafs[i] ); } return S; }
static void WriteGasBoundaryData( CStdioFile& outfile, const AcGePoint3dArray& gas_spts, const AcGePoint3dArray& gas_epts, const AcGeDoubleArray& gas_dirs, const AcDbIntArray& gas_types, const GasParam& gp, const GasBoundaryDataArray& gas_datas ) { // 两帮平均瓦斯涌出 double q1 = AverageGas( gas_spts, gas_epts, gas_types, gp, 1 ); // 工作面平均瓦斯涌出 //double q2 = AverageGas(gas_spts, gas_epts, gas_types, gp, 2); // 开切眼平均瓦斯涌出 double q3 = AverageGas( gas_spts, gas_epts, gas_types, gp, 3 ); // 瓦斯边界个数 CString str; str.Format( _T( "%d\n" ), gas_types.length() ); outfile.WriteString( str ); // 瓦斯边界数据 for( int i = 0; i < gas_types.length(); i++ ) { switch( gas_types[i] ) { case 1: str.Format( _T( "%.4f\n" ), q1 ); break; case 2: //str.Format(_T("%.4f\n"), q2); str.Format( _T( "%.4f\n" ), CaclWSGas( gas_datas[i].q, gas_spts[i], gas_epts[i] ) ); break; case 3: str.Format( _T( "%.4f\n" ), q3 ); break; } outfile.WriteString( str ); } }
bool IntStrListHelper::AddIntStrList( const CString& name, const AcDbIntArray& intList, const AcStringArray& strList ) { if( ( name.GetLength() == 0 ) || strList.isEmpty() || intList.isEmpty() ) return false; if( intList.length() != strList.length() ) return false; ArxDictTool* pDictTool = ArxDictTool::GetDictTool( INT_LIST_DICT ); bool ret = pDictTool->findKey( name ); if( !ret ) { int len = intList.length(); for( int i = 0; i < len; i++ ) { CString intValue; intValue.Format( _T( "%d" ), intList[i] ); pDictTool->addEntry( name, intValue ); // 偶数位置的元素为整数 pDictTool->addEntry( name, strList[i].kACharPtr() ); // 奇数位置的元素为字符串 } } delete pDictTool; return !ret; }
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() ); } }
Acad::ErrorStatus DoubleTunnelDraw::subMoveGripPointsAt ( const AcDbIntArray& indices, const AcGeVector3d& offset ) { assertWriteEnabled () ; for( int i = 0; i < indices.length(); i++ ) { int idx = indices.at( i ); if ( idx == 0 ) { /*if(m_startPt == m_endPt) { m_startPt += offset; m_endPt += offset; } else {*/ m_startPt += offset; //} updateExtraParams(); } if ( idx == 1 ) { //if(m_startPt == m_endPt) // 始末点重合 //{ // AcGePoint3d pt(m_startPt); // pt.x = pt.x + m_width*0.3; // 外环半径的60% // pt += offset; // m_endPt = pt; //} //else //{ m_endPt += offset; //} updateExtraParams(); } } return Acad::eOk; }
static bool IsPointInGoafPolygon( const AcGePoint3dArray& polygons, const AcDbIntArray& polygon_counts, const AcGePoint3d& pt ) { bool ret = false; for( int i = 0; i < polygon_counts.length(); i++ ) { if( IsPointInGoafPolygon( polygons, polygon_counts, i, pt ) ) { ret = true; break; } } return ret; }
Acad::ErrorStatus ArxDbgDbEntity::moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { if (offset.isZeroLength() == Adesk::kTrue) return Acad::eInvalidOffset; if (indices.length() == 1) { if (indices[0] == 0) { setLocation(m_origin + offset); return Acad::eOk; } } return Acad::eOk; }