Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about IfcImageTexture #50

Open
Scarmentado opened this issue Dec 9, 2016 · 0 comments
Open

Question about IfcImageTexture #50

Scarmentado opened this issue Dec 9, 2016 · 0 comments
Milestone

Comments

@Scarmentado
Copy link

Hi Team !

In the following code, I manage to render an IfcSurfaceStyleShading (with a color) but when I try an IfcImageTexture my object disapear, Sure I missed something ! :)
If you could help me ...

using (ITransaction txn = mVarIfcStore.BeginTransaction("Create Point"))
            {
                // Position Zero.
                IfcCartesianPoint myZeroCartesianPoint = mVarIfcStore.Instances.New<IfcCartesianPoint>();
                myZeroCartesianPoint.SetXYZ(0, 0, 0);

                // Position.
                IfcCartesianPoint myLocationPoint = mVarIfcStore.Instances.New<IfcCartesianPoint>();
                myLocationPoint.SetXYZ(location.X, location.Y, location.Z);                

                // Une sphère.
                IfcSphere mySphere = mVarIfcStore.Instances.New<IfcSphere>();
                mySphere.Position = mVarIfcStore.Instances.New<IfcAxis2Placement3D>();
                mySphere.Position.Location = myZeroCartesianPoint;
                mySphere.Radius = new IfcPositiveLengthMeasure(200);

                // Un cylindre.
                IfcRightCircularCylinder myCylinder = mVarIfcStore.Instances.New<IfcRightCircularCylinder>();
                myCylinder.Position = mVarIfcStore.Instances.New<IfcAxis2Placement3D>();
                myCylinder.Position.Location = myZeroCartesianPoint;
                myCylinder.Radius = new IfcPositiveLengthMeasure(20);
                myCylinder.Height = 300;
                
                // L'union des deux.
                IfcBooleanResult myBooleanResult = mVarIfcStore.Instances.New<IfcBooleanResult>();
                myBooleanResult.FirstOperand = mySphere;
                myBooleanResult.SecondOperand = myCylinder;
                myBooleanResult.Operator = IfcBooleanOperator.UNION;
                
                // Le solide.
                IfcCsgSolid mySolid = mVarIfcStore.Instances.New<IfcCsgSolid>();
                mySolid.TreeRootExpression = myBooleanResult;

                // La couleur bleue bizarre.
                IfcColourRgb myColourBlue = mVarIfcStore.Instances.New<IfcColourRgb>();
                myColourBlue.Red = new IfcNormalisedRatioMeasure(0.27);
                myColourBlue.Green = new IfcNormalisedRatioMeasure(0.83);
                myColourBlue.Blue = new IfcNormalisedRatioMeasure(0.73);

                // Le shading bizarre.
                IfcSurfaceStyleShading myIfcSurfaceStyleShading = mVarIfcStore.Instances.New<IfcSurfaceStyleShading>();
                myIfcSurfaceStyleShading.SurfaceColour = myColourBlue;

                // Le style de surface.
                IfcSurfaceStyle mySurfaceStyle = mVarIfcStore.Instances.New<IfcSurfaceStyle>();
                mySurfaceStyle.Styles.Add(myIfcSurfaceStyleShading);

                /***************************************************************************************************************************************************************************************************/
                /************************************************************************************** Essais texture *********************************************************************************************/
                IfcImageTexture myImageTexture = mVarIfcStore.Instances.New<IfcImageTexture>();
                myImageTexture.URLReference = new IfcURIReference(@"https://www.google.fr/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png");

                // La texture.
                IfcSurfaceStyleWithTextures mySurfaceTexture = mVarIfcStore.Instances.New<IfcSurfaceStyleWithTextures>();
                mySurfaceTexture.Textures.Add(myImageTexture);
                mySurfaceStyle.Styles.Clear();
                mySurfaceStyle.Styles.Add(mySurfaceTexture);
                /***************************************************************************************************************************************************************************************************/

                // L'affectation du style au solide.
                IfcStyledItem myStyledItem = mVarIfcStore.Instances.New<IfcStyledItem>();
                myStyledItem.Styles.Add(mySurfaceStyle);
                myStyledItem.Item = mySolid;

                // La représentation 
                IfcShapeRepresentation myShapeRepresentation = mVarIfcStore.Instances.New<IfcShapeRepresentation>();
                myShapeRepresentation.RepresentationType = "CSG";
                myShapeRepresentation.RepresentationIdentifier = "Body";
                myShapeRepresentation.Items.Add(mySolid);
                
                // Le positionnement.
                IfcLocalPlacement myLocalPlacement = mVarIfcStore.Instances.New<IfcLocalPlacement>();
                IfcAxis2Placement3D myAxis2Placement3D = mVarIfcStore.Instances.New<IfcAxis2Placement3D>();
                myAxis2Placement3D.Location = myLocationPoint;
                myAxis2Placement3D.RefDirection = mVarIfcStore.Instances.New<IfcDirection>();
                myAxis2Placement3D.RefDirection.SetXYZ(0, 1, 0);
                myAxis2Placement3D.Axis = mVarIfcStore.Instances.New<IfcDirection>();
                myAxis2Placement3D.Axis.SetXYZ(0, 0, 1);
                myLocalPlacement.RelativePlacement = myAxis2Placement3D;

                // L'objet.
                IfcVirtualElement myVirtualPoint = mVarIfcStore.Instances.New<IfcVirtualElement>();
                myVirtualPoint.Name = "virt point";
                myVirtualPoint.Representation = mVarIfcStore.Instances.New<IfcProductDefinitionShape>();
                myVirtualPoint.Representation.Representations.Add(myShapeRepresentation);
                myVirtualPoint.ObjectPlacement = myLocalPlacement;
                
                // Layer assignment.
                IfcProject myProject = mVarIfcStore.Instances.OfType<IfcProject>().First();
                myShapeRepresentation.ContextOfItems = myProject.RepresentationContexts.First();
                IfcPresentationLayerAssignment myLayer = mVarIfcStore.Instances.OfType<IfcPresentationLayerAssignment>().Where(s => s.Name == "E-ELEC-EQPM-OTLN").First();
                myLayer.AssignedItems.Add(myShapeRepresentation);

                // Hitory
                IfcOwnerHistory myOwnerHistory = mVarIfcStore.OwnerHistoryAddObject as IfcOwnerHistory;
                myVirtualPoint.OwnerHistory.OwningUser = myProject.OwnerHistory.OwningUser;
                myVirtualPoint.OwnerHistory.OwningApplication = myProject.OwnerHistory.OwningApplication;

                txn.Commit();
            }

In advance thank you !

Bye,
Marc

@CBenghi CBenghi added this to the 4.2 milestone May 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants