Exemplo n.º 1
0
        List<GeoLibPointF> pMakeShape(bool returnEarly, ShapeLibrary shape)
        {
            List<GeoLibPointF> mcPoints = new List<GeoLibPointF>(); // overall points container. We'll use this to populate and send back our Point array later.

            Vertex = shape.Vertex;

            // If we have a complex shape, we cannot infer anything from it, so just take the geometry as-is and ship it out.
            if (shape.shapeIndex == (int)CommonVars.shapeNames.complex)
            {
                mcPoints.Clear();
                for (Int32 i = 0; i < Vertex.Count(); i++)
                {
                    if (Vertex[i] != null)
                    {
                        mcPoints.Add(new GeoLibPointF(Vertex[i].X, Vertex[i].Y));
                    }
                }
                return GeoWrangler.close(mcPoints);
            }

            round1 = shape.round1;

            // Iterate the corners to apply the bias from the edges.
#if !QUILTSINGLETHREADED
            Parallel.For(0, round1.Count(), (corner) =>
#else
            for (Int32 corner = 0; corner < round1.Count(); corner++)
#endif
            {
                Vertex[round1[corner].index].X = Vertex[round1[corner].verFace].X;
                Vertex[round1[corner].index].Y = Vertex[round1[corner].horFace].Y;
            }
Exemplo n.º 2
0
        private bool Process(string ifcFilePath, IFCImportOptions options, Document doc)
        {
            TheFileName    = ifcFilePath;
            TheBrepCounter = 0;

            try
            {
                IFCSchemaVersion schemaVersion;
                m_IfcFile     = CreateIFCFile(ifcFilePath, out schemaVersion);
                SchemaVersion = schemaVersion;
            }
            catch (Exception ex)
            {
                Importer.TheLog.LogError(-1, "There was an error reading the IFC file: " + ex.Message + ".  Aborting import.", false);
                return(false);
            }

            Options = options;

            // The DirectShapeLibrary must be reset to potentially remove stale pointers from the last use.
            Document     = doc;
            ShapeLibrary = DirectShapeLibrary.GetDirectShapeLibrary(doc);
            ShapeLibrary.Reset();

            bool readFile = ProcessFile(ifcFilePath);

            if (!readFile)
            {
                return(false);
            }

            m_Transaction = new Transaction(doc);
            bool success = true;

            switch (options.Intent)
            {
            case IFCImportIntent.Reference:
                success = ProcessReference();
                break;
            }
            if (success)
            {
                StoreIFCCreatorInfo(m_IfcFile, doc.ProjectInformation);
            }

            return(success);
        }
Exemplo n.º 3
0
        MyRound[] round1; // container for the rounding data.

        public ComplexShape(List<PatternElement> patternElements, Int32 settingsIndex, ShapeLibrary shape = null)
        {
            pMakeEntropyShape(patternElements, settingsIndex, shape);
        }
Exemplo n.º 4
0
        decimal pDoY(int i)
        {
            decimal y_ = 0m;

            int yRef = pGetRef(i, PatternElement.properties_i.yPosRef);

            // We have a relative positioning situation.
            // Note that this could be cascading so we need to walk the stack

            if (yRef >= 0)
            {
                int sRef = pGetPatternElement(i).getInt(PatternElement.properties_i.yPosSubShapeRef);

                int sPosRef = pGetPatternElement(i).getInt(PatternElement.properties_i.yPosSubShapeRefPos);

                bool refFlipped = pGetPatternElement(yRef).getInt(PatternElement.properties_i.flipV) == 1;

                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.yPos);

                // In the case of an array shape type for the reference, we may still have subshape relative references. To check this, we need to query for an array. If we don't have an array, we're good.
                // Then we also need to query whether the subshape reference is a higher value than the number of subshapes in the shape; the 'array' subshape reference is last in the list.
                bool doY = !pGetPatternElement(yRef).isYArray() || (pGetPatternElement(yRef).isYArray() && (sRef < pGetPatternElement(yRef).getSubShapeCount()));

                int aYRef = yRef;

                // Is the array reference a relative array?
                if (pGetPatternElement(yRef).getInt(PatternElement.properties_i.arrayRef) != 0)
                {
                    aYRef = pGetPatternElement(yRef).getInt(PatternElement.properties_i.arrayRef) - 1;

                    int PSSR = pGetPatternElement(i).getInt(PatternElement.properties_i.yPosSubShapeRef);
                    int PSSC = pGetPatternElement(yRef).getSubShapeCount();
                    if (PSSR == PSSC)
                    {
                        doY = false;
                    }
                }

                if (doY)
                {
                    y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verOffset, 0);
                    if (sRef == 1)
                    {
                        y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verOffset, 1);
                    }
                    if (sRef == 2)
                    {
                        y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 0);
                        y_ -= pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 2);
                        y_ -= pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verOffset, 2);
                    }
                }

                // Process the side case.
                if ((!refFlipped && (sPosRef == (int)CommonVars.subShapeVerLocs.T)) || (refFlipped && (sPosRef == (int)CommonVars.subShapeVerLocs.B)))
                {
                    if (doY)
                    {
                        switch (sRef)
                        {
                            case 0:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 0);
                                break;
                            case 1:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 1);
                                break;
                            case 2:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 2);
                                break;
                        }
                    }
                    else
                    {
                        y_ += Convert.ToDecimal(pBBDimension(bbDims.height, aYRef));
                    }
                }

                if (sPosRef == (int)CommonVars.subShapeVerLocs.M)
                {
                    if (doY)
                    {
                        switch (sRef)
                        {
                            case 0:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 0) / 2;
                                break;
                            case 1:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 1) / 2;
                                break;
                            case 2:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 2) / 2;
                                break;
                        }
                    }
                    else
                    {
                        y_ += Convert.ToDecimal(pBBDimension(bbDims.height, aYRef)) / 2;
                    }
                }

                // Is the reference flipped? If so, we need to flip our value to get the correct result
                if (refFlipped)
                {
                    ShapeLibrary t = new ShapeLibrary(pGetPatternElement(yRef));
                    GeoLibPointF pivot = t.getPivotPoint();

                    bool alignX = pGetPatternElement(yRef).getInt(PatternElement.properties_i.alignX) == 1;
                    bool alignY = pGetPatternElement(yRef).getInt(PatternElement.properties_i.alignY) == 1;
                    y_ = Convert.ToDecimal(GeoWrangler.flip(false, true, alignX, alignY, pivot, new[] { new GeoLibPointF(0, Convert.ToDouble(y_)) })[0].Y);
                }

                if (doY)
                {
                    switch (sRef)
                    {
                        case 0:
                            y_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.verOffset, 0);
                            break;
                        case 1:
                            y_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.verOffset, 1);
                            break;
                        case 2:
                            break;
                    }
                }

                // yRef = pGetRef(yRef, PatternElement.properties_i.yPosRef);
            }

            return y_;

        }
Exemplo n.º 5
0
        decimal pDoX(int i)
        {
            decimal x_ = 0m;

            int xRef = pGetRef(i, PatternElement.properties_i.xPosRef);

            // We have a relative positioning situation.
            // Note that this could be cascading so we need to walk the stack
            if (xRef >= 0)
            {
                int sRef = pGetPatternElement(i).getInt(PatternElement.properties_i.xPosSubShapeRef);

                int sPosRef = pGetPatternElement(i).getInt(PatternElement.properties_i.xPosSubShapeRefPos);

                bool refFlipped = pGetPatternElement(xRef).getInt(PatternElement.properties_i.flipH) == 1;
                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.xPos);

                // In the case of an array shape type for the reference, we may still have subshape relative references. To check this, we need to query for an array. If we don't have an array, we're good.
                // Then we also need to query whether the subshape reference is a higher value than the number of subshapes in the shape; the 'array' subshape reference is last in the list.
                bool doX = !pGetPatternElement(xRef).isXArray() || (pGetPatternElement(xRef).isXArray() && (sRef < pGetPatternElement(xRef).getSubShapeCount()));

                int aXRef = xRef;
                // Is the array reference a relative array?
                if (pGetPatternElement(xRef).getInt(PatternElement.properties_i.arrayRef) != 0)
                {
                    aXRef = pGetPatternElement(xRef).getInt(PatternElement.properties_i.arrayRef) - 1;

                    int PSSR = pGetPatternElement(i).getInt(PatternElement.properties_i.xPosSubShapeRef);
                    int PSSC = pGetPatternElement(xRef).getSubShapeCount();
                    if (PSSR == PSSC)
                    {
                        doX = false;
                    }
                }

                if (doX)
                {
                    if (sRef == 1)
                    {
                        x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 0);
                        if (pGetPatternElement(xRef).getInt(PatternElement.properties_i.shapeIndex) != (int)CommonVars.shapeNames.Sshape)
                        {
                            if ((pGetPatternElement(xRef).getInt(PatternElement.properties_i.shapeIndex) != (int)CommonVars.shapeNames.Ushape) && (pGetPatternElement(xRef).getInt(PatternElement.properties_i.shapeIndex) != (int)CommonVars.shapeNames.Xshape))
                            {
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 0);
                            }
                            else
                            {
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 1);
                            }
                        }
                    }
                    if (sRef == 2)
                    {
                        x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 0);
                        x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 2);
                    }
                }

                // Process the side case.
                if ((!refFlipped && (sPosRef == (int)CommonVars.subShapeHorLocs.R)) || (refFlipped && (sPosRef == (int)CommonVars.subShapeHorLocs.L)))
                {
                    if (doX)
                    {
                        switch (sRef)
                        {
                            case 0:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 0);
                                break;
                            case 1:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 1);
                                break;
                            case 2:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 2);
                                break;
                        }
                    }
                    else
                    {
                        x_ += Convert.ToDecimal(pBBDimension(bbDims.width, aXRef));
                    }
                }

                if (sPosRef == (int)CommonVars.subShapeHorLocs.M)
                {
                    if (doX)
                    {
                        switch (sRef)
                        {
                            case 0:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 0) / 2;
                                break;
                            case 1:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 1) / 2;
                                break;
                            case 2:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 2) / 2;
                                break;
                        }
                    }
                    else
                    {
                        x_ += Convert.ToDecimal(pBBDimension(bbDims.width, aXRef)) / 2;
                    }
                }

                // Is the reference flipped? If so, we need to flip our value to get the correct result
                if (refFlipped)
                {
                    ShapeLibrary t = new ShapeLibrary(pGetPatternElement(xRef));
                    GeoLibPointF pivot = t.getPivotPoint();

                    bool alignX = pGetPatternElement(xRef).getInt(PatternElement.properties_i.alignX) == 1;
                    bool alignY = pGetPatternElement(xRef).getInt(PatternElement.properties_i.alignY) == 1;
                    x_ = Convert.ToDecimal(GeoWrangler.flip(true, false, alignX, alignY, pivot, new[] { new GeoLibPointF(Convert.ToDouble(x_), 0) })[0].X);
                }

                if (doX)
                {
                    switch (sRef)
                    {
                        case 0:
                            x_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.horOffset, 0);
                            break;
                        case 1:
                            x_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.horOffset, 1);
                            break;
                        case 2:
                            x_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.horOffset, 2);
                            break;
                    }
                }

                // xRef = pGetRef(xRef, PatternElement.properties_i.xPosRef);
            }

            return x_;
        }
Exemplo n.º 6
0
        private bool Process(string ifcFilePath, IFCImportOptions options, Document doc)
        {
            // Manually set to false if necessary for debugging.
            CleanEntitiesAfterCreate = true;

            TheFileName    = ifcFilePath;
            TheBrepCounter = 0;

            Log = IFCImportLog.CreateLog(ifcFilePath + ".log.html");

            try
            {
                IFCSchemaVersion schemaVersion;
                m_IfcFile     = CreateIFCFile(ifcFilePath, out schemaVersion);
                SchemaVersion = schemaVersion;
            }
            catch (Exception ex)
            {
                Log.LogError(-1, "There was an error reading the IFC file: " + ex.Message + ".  Aborting import.", false);
                return(false);
            }

            Options = options;

            Document     = doc;
            ShapeLibrary = DirectShapeLibrary.GetDirectShapeLibrary(doc);
            ShapeLibrary.Reset();

            IFCFileReadOptions readOptions = new IFCFileReadOptions();

            readOptions.FileName          = ifcFilePath;
            readOptions.XMLConfigFileName = Path.Combine(RevitProgramPath, "EDM\\ifcXMLconfiguration.xml");

            int numErrors   = 0;
            int numWarnings = 0;

            try
            {
                Importer.TheCache.StatusBar.Set(String.Format(Resources.IFCReadingFile, TheFileName));
                m_IfcFile.Read(readOptions, out numErrors, out numWarnings);
            }
            catch (Exception ex)
            {
                Log.LogError(-1, "There was an error reading the IFC file: " + ex.Message + ".  Aborting import.", false);
                return(false);
            }

            if (numErrors > 0 || numWarnings > 0)
            {
                if (numErrors > 0)
                {
                    if (numWarnings > 0)
                    {
                        Log.LogError(-1, "There were " + numErrors + " errors and " + numWarnings + " reading the IFC file.  Please look at the log information at the end of this report for more information.", false);
                    }
                    else
                    {
                        Log.LogError(-1, "There were " + numErrors + " errors reading the IFC file.  Please look at the log information at the end of this report for more information.", false);
                    }
                }
                else
                {
                    Log.LogWarning(-1, "There were " + numWarnings + " warnings reading the IFC file.  Please look at the log information at the end of this report for more information.", false);
                }
            }

            m_Transaction = new Transaction(doc);
            switch (options.Intent)
            {
            case IFCImportIntent.Reference:
                InitializeOpenTransaction("Open IFC Reference File");

                //If there is more than one project, we will be ignoring all but the first one.
                IList <IFCAnyHandle> projects = IFCImportFile.TheFile.GetInstances(IFCEntityType.IfcProject, false);
                if (projects.Count == 0)
                {
                    Log.LogError(-1, "There were no IfcProjects found in the file.  Aborting import.", false);
                    return(false);
                }
                else
                {
                    IFCProject.ProcessIFCProject(projects[0]);
                }
                break;
            }

            return(true);
        }